简体   繁体   English

Apollo GraphQL 不断接收请求,没有进行查询或突变

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

I was learning GraphQL and about to finish the tutorial and this never happened before.我正在学习 GraphQL 并且即将完成本教程,这从未发生过。

The problem is that the GraphQL server keeps receiving requests after opening GraphQL Playground in the browser even though no query or mutation is made.问题是 GraphQL 服务器在浏览器中打开 GraphQL Playground 后仍继续接收请求,即使没有进行查询或突变。

I see these sort of responses being returned by the server:我看到服务器返回了这些类型的响应:

{
    "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\""
      }
    ]
}

This is expected behavior.这是预期的行为。

GraphQL Playground issues an introspection query to your server. GraphQL Playground 向您的服务器发出自省查询 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 with this feature at the moment). Playground 将重复发送该查询到您的服务器(默认每 2 秒),因此如果您的架构发生更改,这些更改可以立即反映在 UI 中(尽管目前此功能存在问题)。

You can adjust the relevant settings (click on the settings icon in the top right corner of the Playground UI) to either change the polling frequency or turn it off entirely:您可以调整相关设置(单击 Playground 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

However, the behavior you're seeing is only related to Playground so it's harmless and won't impact any other clients connecting to your server.但是,您看到的行为仅与 Playground 有关,因此它是无害的,不会影响连接到您服务器的任何其他客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM