Apollo GraphQL 不断接收请求,没有进行任何查询或更改 [英] Apollo GraphQL keeps receiving requests with no queries or mutations being made

查看:32
本文介绍了Apollo GraphQL 不断接收请求,没有进行任何查询或更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was learning GraphQL and about to finish the tutorial and this never happened before.

问题是在浏览器中打开 GraphQL Playground 后,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.

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

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

推荐答案

这是预期的行为.

GraphQL Playground 向您的服务器发出内省查询.它使用该查询的结果为您的查询提供验证和自动完成.Playground 会重复向您的服务器发送该查询(默认情况下每 2 秒一次),以便如果您的架构发生更改,这些更改可以立即反映在 UI 中(尽管有 目前此功能存在问题).

GraphQL Playground issues an 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 with this feature at the moment).

您可以调整相关设置(单击 Playground 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:

  '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 相关,因此它是无害的,不会影响连接到您服务器的任何其他客户端.

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.

这篇关于Apollo GraphQL 不断接收请求,没有进行任何查询或更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆