Search code examples
node.jsgraphqlapolloapollo-clientapollo-server

Fetch graphQL query response bypass graphQL playground in the browser


I am using graphql apollo server and i have some queries and path is like:

http://localhost:4000/demo

after it redirects to that apollo playground and I can test my queries there

Now I am trying to fetching data from a query which should by pass the playground like below querystring:

http://localhost:4000/demo?query=queryName()

It is working fine with postman when i hit above url but when i am hitting on browser it is taking me on the apollo playground that should not happen

I have tried to disable the playground but it is not working for me

Please help me how i can directly get the query response from a url on the browser

Thanks


Solution

  • I got the answer from the below question

    Is there any option to disable playground when in production mode?

    I have to configure apollo server like below:

    import { ApolloServerPluginLandingPageGraphQLPlayground,
             ApolloServerPluginLandingPageDisabled } from 'apollo-server-core';
    new ApolloServer({
      plugins: [
        process.env.NODE_ENV === 'production'
          ? ApolloServerPluginLandingPageDisabled()
          : ApolloServerPluginLandingPageGraphQLPlayground(),
      ],
    });