Graphql ApolloServer2.0:游乐场设置中的奇怪条目

Graphql ApolloServer2.0:游乐场设置中的奇怪条目,graphql,apollo-server,Graphql,Apollo Server,我正在使用Express运行Apollo Server 2.0,以创建GraphQL API的原型。以下是我的ApolloServer init的外观(我的服务器脚本的一部分): 按照上的建议,我将设置值抽象为一个单独的JSON文件,如下所示: // playground.json { "general.betaUpdates": false, "editor.cursorShape": "line", "editor.fontSize": 14, "editor.fontFam

我正在使用Express运行Apollo Server 2.0,以创建GraphQL API的原型。以下是我的ApolloServer init的外观(我的服务器脚本的一部分):

按照上的建议,我将设置值抽象为一个单独的JSON文件,如下所示:

// playground.json
{
  "general.betaUpdates": false,
  "editor.cursorShape": "line",
  "editor.fontSize": 14,
  "editor.fontFamily": "'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace",
  "editor.theme": "dark",
  "editor.reuseHeaders": true,
  "prettier.printWidth": 80,
  "request.credentials": "omit",
  "tracing.hideTracingResponse": true
}
这个设置工作得很好。除了运行服务器并在浏览器中查看加载到游乐场中的设置外,我注意到JSON中有一些奇怪但无害的条目:

{
  "0": ".",
  "1": "/",
  "2": "p",
  "3": "l",
  "4": "a",
  "5": "y",
  "6": "g",
  "7": "r",
  "8": "o",
  "9": "u",
  "10": "n",
  "11": "d",
  "12": ".",
  "13": "j",
  "14": "s",
  "15": "o",
  "16": "n",
  "general.betaUpdates": false,
  "editor.cursorShape": "line",
  "editor.fontSize": 14,
  "editor.fontFamily": "'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace",
  "editor.theme": "dark",
  "editor.reuseHeaders": true,
  "prettier.printWidth": 80,
  "request.credentials": "omit",
  "tracing.hideTracingResponse": true
}

知道可能会出现什么问题吗?

操场设置应该是对象,但您提供了字符串。您可以使用
require
来解决这个问题

const server = new ApolloServer({
  typeDefs,
  resolvers,
  playground: {
    endpoint: `/blog/`,
    settings: require('./playground.json')
  }
});
服务器仅提供默认设置。浏览器具有本地设置并可进行编辑

const server = new ApolloServer({
  typeDefs,
  resolvers,
  playground: {
    endpoint: `/blog/`,
    settings: require('./playground.json')
  }
});