Skip to content
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

Getting graphql-playground-react to work when offline #1734

Closed
wants to merge 7 commits into from

Conversation

penx
Copy link

@penx penx commented Sep 26, 2018

Partially fixes #1421

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@apollo-cla
Copy link

@penx: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@ghost ghost added the ⛲️ feature New addition or enhancement to existing solutions label Sep 26, 2018
@penx
Copy link
Author

penx commented Sep 26, 2018

Another option, once graphql/graphql-playground#845 is in @apollographql/graphql-playground-html, is to rely on the parent application to implement this static server and supply the appropriate cdnUrl as a config option, thereby bypassing any need for a code change in apollo-server, other than maybe documentation/how to.

According to this comment, though, this may already be fixed making this PR redundant:
#295 (comment)

@abernix can you confirm? You referenced issue #1421 but didn't close #1421 so not sure

@penx
Copy link
Author

penx commented Sep 26, 2018

Working example that doesn't need a modification to apollo-server-express here:

https://github.com/penx/graphql-server-example

Up to the maintainers where you want to take this. Let me know if you want me to do anything - would be great if you can get graphql/graphql-playground#845 in to your fork once merged, this should be all that's needed for now.

@abernix
Copy link
Member

abernix commented Oct 25, 2018

Another option, once prisma/graphql-playground#845

Good news! That landed and should be included in Apollo Server once #1855 lands.

Your workaround you provided in #1734 is great and along the lines of what I was looking at! I had been considering using server-static since it might have a better chance of working in the various integration flavors of Apollo Server than express.static (e.g. apollo-server-hapi, apollo-server-koa, etc.), but I do think we should consider making this a more permanent resident of Apollo Server since, as you know, it's not possible to run Playground offline. That said, I do think it should still be configurable since the serving of those HTML assets might not be desirable or possible in some environments, for example where only a single endpoint is available.

@penx
Copy link
Author

penx commented Mar 18, 2019

decide on best way to mount a node_module as a static asset, given that the location of the node_module on disk may not be easily determined (e.g. when using npm link)

I think this can be done using require.resolve

app.use(
  '/graphql-playground-react',
  express.static(require.resolve('graphql-playground-react')),
);

@penx penx changed the title WIP: getting graphql-playground-react to work when offline Getting graphql-playground-react to work when offline Mar 18, 2019
@penx
Copy link
Author

penx commented Mar 18, 2019

@abernix I just made a couple of updates - do you reckon this can be merged in? Or did you want to go a different route?

@abernix
Copy link
Member

abernix commented Jul 24, 2019

I realize this is quite old at this point but, due to the extra weight of the graphql-playground-react bundle, which is often undesirable in serverless environments or workers where bundle size is critical, I'm mostly tempted to recommend resolving this via documentation, rather than actually bundling the entirety of the React bundle GraphQL Playground into Apollo Server.

For example, it's still possible to just set playground: false and directly use, for example, graphql-playground-middleware-express, right? Thoughts?

@StefanFeederle
Copy link

I would favour including the bundled assets by default and having a config value for serverless deployments.

@abernix abernix closed this Jun 24, 2020
@abernix abernix reopened this Jun 25, 2020
@abernix abernix changed the base branch from master to main June 25, 2020 09:05
@glasser
Copy link
Member

glasser commented Oct 4, 2022

GraphQL Playground's maintainers have retired the project. It is not the default experience as of last year's Apollo Server 3 and won't be distributed as a maintained part of Apollo Server starting with Apollo Server 4 (imminent). So we are not going to improve it. Sorry for the delay!

@glasser glasser closed this Oct 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⛲️ feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graphql playground doesn't load when offline
5 participants