-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphql playground doesn't load when offline #1421
Comments
@wmertens Do you mean using playground in production? Or is this about using playground locally? |
using the playground locally, while developing your app. It is served from a CDN. It would be nice if the assets were local instead. |
Same issue here, I need to be able to use GraphQL Playground without an internet connection. Happy to look in to this issue if anyone has any pointers. Some more details: Following the introduction tutorial and loading http://localhost:4000 returns an html response. The top of the html response contains:
It would be good to have the option to include graphql-playground-react as a devDependency and serve these files from localhost rather than cdn.jsdelivr.net. |
Related:
const getCdnMarkup = options => `
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
}/build/static/css/index.css" />
<link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
}/build/favicon.png" />
<script src="//cdn.jsdelivr.net/npm/graphql-playground-react@${
options.version
}/build/static/js/middleware.js"></script> https://www.npmjs.com/package/@apollographql/graphql-playground-html I'm not sure where the source is to https://github.com/apollographql/graphql-playground/tree/master/packages/graphql-playground-html |
I guess having the option to override Either that or serving the assets from Express and using the running apollo server url. |
Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421
* renderPlaygroundPage - cdnUrl config option Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421 * don't insert @ in cdn url if no version given If version is not passed then don't append @ to the cdn url. This is to aid serving from localhost from a folder with no given version number. See #845
Any update on this issue? |
@anodynos graphql/graphql-playground#845 was merged in today and will be in the next release of graphql-playground-html. However, Apollo Server uses a fork - @apollographql/graphql-playground-html I need someone from the Apollo team to let me know where this fork lives so I can open a PR for this fix, or for them to let me know what the process will be for including this in their fork. Once this is done, offline support can be done as per this project: https://github.com/penx/graphql-server-example Or someone from the Apollo team could feed in to my comments on this WIP PR: |
scoped graphql-playground-html was added in 8ea36d8 by @martijnwalraven
config?: GraphQLConfigData; was changed to config?: any; (and the associated import removed) @martijnwalraven was the use of scoped graphql-playground-html meant to be temporary? Does this fork live anywhere? How do we go about getting changes in to it? |
I don't think it's temporary, because upstream has a dependency on The fork currently lives at https://github.com/apollographql/graphql-playground/tree/remove-graphql-config. Rebasing those changes on top of the upstream |
@martijnwalraven My changes should be in the next release of |
@penx I think all changes should be fine. I'd like us to stay synchronized with upstream, with the exception of those dependencies. |
* renderPlaygroundPage - cdnUrl config option Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421 * don't insert @ in cdn url if no version given If version is not passed then don't append @ to the cdn url. This is to aid serving from localhost from a folder with no given version number. See #845
Hi @martijnwalraven - Just wondering when the change to support offline playground resources will be merged in? Many thanks! |
Any progress with this issue, I have never noticed the need until now and it’s quite annoying. |
@OlivierJM - I've now got this working by implementing the following:
https://cdn.jsdelivr.net/npm/graphql-playground-react@1.7.10/build/static/css/index.css to: ./favicon.png And used used http-server to server them.
|
Thanks for pointing this out, I will set this up in advance in case. |
The latest Apollo Server is rebased on the latest from the upstream project which should support this! |
Need Graphql playground work offline/slow network for Apollo Server 2.x which means work without the static resources from CDN. |
I try to use playground offline with import { gql, IResolvers } from 'apollo-server';
import express from 'express';
import path from 'path';
import { ApolloServer } from 'apollo-server-express';
const typeDefs = gql`
type Query {
name: String
}
`;
const resolvers: IResolvers = {
Query: {
name: () => 'name',
},
};
const PORT = process.env.PORT || 3000;
const app = express();
const staticRoot = path.resolve(__dirname, '../../node_modules');
app.use('/node_modules', express.static(staticRoot));
const server = new ApolloServer({ typeDefs, resolvers, playground: { cdnUrl: './node_modules' } });
server.applyMiddleware({ app });
app.listen(PORT, () => {
console.log(`🚀 Server ready at http://localhost:${PORT}${server.graphqlPath}`);
}); But it doesn't working. The browser try to request
|
There is another solution I came up with. If you are working on other network/locally you can clone this project: and run the CDN locally for your/your environment's needs. |
* renderPlaygroundPage - cdnUrl config option Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421 * don't insert @ in cdn url if no version given If version is not passed then don't append @ to the cdn url. This is to aid serving from localhost from a folder with no given version number. See graphql#845
* renderPlaygroundPage - cdnUrl config option Allow the cdn url to be passed in to renderPlaygroundPage as an option. This is to support graphql-playground being used offline by tools such as Apollo Server. See apollographql/apollo-server#1421 * don't insert @ in cdn url if no version given If version is not passed then don't append @ to the cdn url. This is to aid serving from localhost from a folder with no given version number. See #845
You can't use the playground to test the graphql API while offline (e.g. when working on a train)
The text was updated successfully, but these errors were encountered: