如何禁用阿波罗沙箱并启动 Playground?

问题描述

我正在使用 apollo-server,当我需要访问操场时,我只输入了 localhost:4000 并且我可以访问操场,但是现在当我尝试访问操场时被重定向到沙箱,问题是是关于如何禁用该行为并启动游乐场而不是沙箱。

谢谢。

解决方法

您遇到的这一变化可能是由于从 Apollo Server v2 升级到 v3(可能是意外或自动)造成的。 The v3.0.0 release of Apollo Server 发生在 10 天前。

Apollo Server v3 更改了服务器登陆页面的默认行为,但您仍然可以按照 these instructions 配置 GraphQL Playground。

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

const server = new ApolloServer({
  typeDefs,resolvers,plugins: [
    ApolloServerPluginLandingPageGraphQLPlayground(),],});