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

标签 javascript node.js typescript graphql apollo

我正在学习 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到您的服务器。它使用该查询的结果为您的查询提供验证和自动完成。 Playground 会重复将该查询发送到您的服务器(默认情况下每 2 秒一次),因此如果您的架构发生变化,这些更改可以立即反射(reflect)在 UI 中(尽管目前 an issue 具有此功能)。

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

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

关于javascript - Apollo GraphQL 不断接收请求,没有进行任何查询或更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58038945/

相关文章:

javascript - 数值数组排序()

javascript - 在 JS 中使用 this 与使用变量

angular - 无法使用 angular 2+ 获取模板引用值

node.js - 如何配置我的 Nodejs 应用程序以仅响应 SSL 连接?

typescript - 如何在 TypeScript 的循环内导入外部模块?

javascript - 在 .Net core 的 Angular 应用程序中访问 Api Url

javascript - 将 HTML 列表项更改为在导航栏中处于事件状态

javascript - 随机横幅只显示第一张图片

node.js - 无法让 Gulp 运行 : cannot find module 'gulp-util'

node.js - 在异步插件中正确使用 HandleScope