Apollo GraphQL 不断接收请求,没有进行任何查询或更改

Apollo GraphQL keeps receiving requests with no queries or mutations being made

我正在学习 GraphQL 并即将完成本教程,这在以前从未发生过。

问题是在浏览器中打开 GraphQL Playground 后,GraphQL 服务器一直在接收请求,即使没有进行查询或更改也是如此。

我看到服务器返回了这些类型的响应:

{
    "name":"deprecated",
    "description":"Marks an element of a GraphQL schema as no longer supported.",
    "locations":[
      "FIELD_DEFINITION",
      "ENUM_VALUE"
    ],
    "args":[
      {
          "name":"reason",
          "description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).",
          "type":{
            "kind":"SCALAR",
            "name":"String",
            "ofType":null
          },
          "defaultValue":"\"No longer supported\""
      }
    ]
}

这是预期的行为。

GraphQL Playground 目前发布了具有此功能的 introspection query to your server. It uses the result of that query to provide validation and autocompletion for your queries. Playground will send that query to your server repeatedly (every 2 seconds by default) so that if your schema changes, these changes can be immediately reflected in the UI (although there's an issue

您可以调整相关设置(点击游乐场右上角的设置图标UI)来更改轮询频率或完全关闭它:

  'schema.polling.enable': true, // enables automatic schema polling
  'schema.polling.endpointFilter': '*localhost*', // endpoint filter for schema polling
  'schema.polling.interval': 2000, // schema polling interval in ms

但是,您看到的行为仅与 Playground 有关,因此它是无害的,不会影响连接到您服务器的任何其他客户端。