javascript - Apollo GraphQL 不断接收请求,没有进行查询或突变
问题描述
我正在学习 GraphQL,即将完成本教程,这在以前从未发生过。
问题是 GraphQL 服务器在浏览器中打开 GraphQL Playground 后继续接收请求,即使没有进行查询或突变。
我看到服务器返回了这些类型的响应:
{
"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 中(尽管目前此功能存在问题)。
您可以调整相关设置(单击 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 有关,因此它是无害的,不会影响连接到您服务器的任何其他客户端。
推荐阅读
- vue.js - Nuxt - 返回根目录时如何保留存储状态(主页)
- java - Windows、Gradle 和 Cucumber 组合在生成报告时抛出 IOException
- excel-formula - 根据 Excel 中的累积和返回列号
- powershell - 检查 ADusers 的属性 export-csv 并包含 null
- c# - 未找到 CredDB.CEF
- javascript - Angular 6 - *ngFor:在 JSON 数据中附加选择选项
- mysql - Sql - 查询以获取表中的记录总数
- python - Python while 循环永远不会结束(在 numworks 计算器上)
- node.js - 添加用户交互教程以响应 webapp
- ignite - 在 ignite 中查找并置数据