How can i set my ApolloServer to open a graphql playground instead of the apollographql sandbox by default?

Viewed 1553

My question is how can i set this graphql playground extension as my default playground instead of using the default sandbox when i visited http://hocalhost/port/graphql. Is there any option that i can set during the creation of the ApolloServer instance that can configure that?.

...
const apolloServer = new ApolloServer({
    schema: await buildSchema({
      validate: false,
      resolvers: [HelloResolver, UserResolver],
    }),
    context: ({ req, res }) => ({ em: orm.em, req, res }),
  });
  await apolloServer.start();
  apolloServer.applyMiddleware({ app });

....
1 Answers

Use the GraphQL Playground plugin and provide it to your Apollo Server constructor. For more info checkout Apollo Docs.

import {
  ApolloServerPluginLandingPageGraphQLPlayground
} from "apollo-server-core";

const apolloServer = new ApolloServer({
  ...
  plugins: [
    ApolloServerPluginLandingPageGraphQLPlayground(),
  ],
});

Related