question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In production with apollo-server-express 2.0.4 Playground is visible, with 2.0.0 is not.

See original GitHub issue

REPRODUCTION HERE: https://brainy-spaghetti.glitch.me

With "apollo-server-express": "2.0.4" and NODE_ENV=production the Playground is visible.

With "apollo-server-express": "2.0.0" and NODE_ENV=production I have this: GET query missing.

Something is wrong?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
nderscorecommented, Aug 26, 2018

Confirmed the issue. Sorry for the confusion.

https://github.com/apollographql/apollo-server/blob/412be208c1b60c2f77333eec2840b64990ea7935/packages/apollo-server-core/src/playground.ts#L39

It’s likely due to the default value of {} for the playground config here.

3reactions
nderscorecommented, Aug 25, 2018

The default behavior of apollo-server’s integrated graphql-playground is for it to be disabled (along with introspection queries) when NODE_ENV=production.

This behavior can be over-ridden when you set the playground option in config.

In 2.0.0, the graphql playground could be enabled when NODE_ENV=production if you explicitly set the playground option to true, but provided no way to enable the playground with a custom config object.

In 2.0.2, this was adjusted to allow a custom config to enable the playground in production. Now, a truthy value will enable the playground, while a falsey value will disable it.


If you want to disable the playground in production while using a custom config in your local/development environment, you could do something like this:

const GRAPHQL_PLAYGROUND_CONFIG = {
  folderName: 'Foo',
  settings: {
    'editor.cursorShape': 'line',
    'editor.fontSize': 14,
    'editor.reuseHeaders': true,
    'editor.theme': 'dark'
  }
};

const server = new ApolloServer({
  playground: process.env.NODE_ENV === 'production' ? false : GRAPHQL_PLAYGROUND_CONFIG,
  schema: mySchema
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating to v2.0 - Apollo GraphQL Docs
If the server is only functioning as a GraphQL server, it's no longer necessary to run your own HTTP server (like express )....
Read more >
Apollo Server Express - Playground cannot be reached
Server cannot be reached/no visible schema but still able to execute a query. To fix this you should have this as in your...
Read more >
apollo-server-fastify | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
GraphQL: Migrating From Apollo-Server-Express 1.0 To 2.0
Body-Parser Is Baked In. Version 2.0.0 doesn't require importing the Body-Parser package, so if not needed elsewhere, you can uninstall it. 3 ...
Read more >
Integrate TypeScript with GraphQL using TypeGraphQL
apollo -server-express is the express and connect integration of a ... The class-validator library allows the use of decorator and non ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found