crispengari
crispengari

Reputation: 9321

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

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 });

....

Upvotes: 2

Views: 2932

Answers (1)

pmancia
pmancia

Reputation: 76

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(),
  ],
});

Upvotes: 4

Related Questions