我如何设置我的 ApolloServer 以默认打开 graphql 游乐场而不是 apollographql 沙箱?

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

我的问题是当我访问 http://hocalhost/port/graphql 时如何设置 this graphql playground extension as my default playground instead of using the default sandbox。在创建可以配置的 ApolloServer 实例期间,我可以设置任何选项吗?

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

....

使用 GraphQL Playground 插件 并将其提供给您的 Apollo Server 构造函数For more info checkout Apollo Docs.

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

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