简体   繁体   English

GraphQL 中继自省查询失败:类型“查询”上的未知字段“__type”

[英]GraphQL Relay introspection query fails: Unknown field '__type' on type 'Query'

I have a React application with a GraphQL client (Relay).我有一个带有 GraphQL 客户端(中继)的 React 应用程序。 I need to make an introspection query to get all the types of a certain enum.我需要进行自省查询以获取某个枚举的所有类型。 This is my query:这是我的查询:

import { graphql } from 'react-relay'

export const corporationTypeEnumQuery = graphql`
  query corporationTypeEnumQuery {
    __type(name: "CorporationTypeEnum") {
      enumValues {
        name
      }
    }
  }
`

When I try to compile the app, Relay throws the following error:当我尝试编译应用程序时,Relay 抛出以下错误:

Unknown field '__type' on type 'Query'

When I try the exact same query on GraphIQL (the playground that the server offers me), there is no error, and the query is successful.当我在 GraphIQL(服务器为我提供的操场)上尝试完全相同的查询时,没有错误,并且查询成功。

Please tell me what could be wrong with my GraphQL query.请告诉我我的 GraphQL 查询可能有什么问题。 Any suggestions are well received.任何建议都受到欢迎。

The __type must be part of your schema. __type必须是架构的一部分。 Graphql spec by default said this should be hidden and not part of schema.. You need to extend your server to expose it or manually put them to schema.. Graphql 规范默认说这应该是隐藏的,而不是模式的一部分。你需要扩展你的服务器来公开它或手动将它们放到模式中。

Server can handle that but compiler not since it require explicit definition in .graphql服务器可以处理,但编译器不能处理,因为它需要在.graphql进行显式定义

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

相关问题 收到错误:类型为“查询” [GraphQL,Relay,React]的字段“用户”上的未知参数“ id” - Getting error : Unknown argument “id” on field “user” of type “Query” [GraphQL, Relay, React] GraphQL / Relay架构无法在“CreateLinkPayload”类型上查询字段“store” - GraphQL/Relay Schema Cannot query field “store” on type “CreateLinkPayload” 如何在 GraphQL (Relay) 中查询和改变数组类型? - How to query and mutate array type in GraphQL (Relay)? 有什么方法可以读取带有查询自省的类型的 GraphQL 指令? - Is there any way to read GraphQL Directives on a Type with Query Introspection? GraphQL-“类型为“查询”的字段“allNews”上的“未知参数“国家/地区”。”, - GraphQL-"Unknown argument \"country\" on field \"allNews\" of type \"Query\".", 错误:未知类型“查询”。 在 assertValidSDL (GRAPHQL) - Error: Unknown type "Query". at assertValidSDL (GRAPHQL) GraphQL 查询中的错误显示未知类型“ContentfulSizes” - Error in GraphQL query it says Unknown type "ContentfulSizes" GraphQL /中继架构“无法查询字段...” - GraphQL/Relay Schema “Cannot query field…” 无法在类型“用户”graphql 上查询字段“密码” - Cannot query field 'password' on type 'User' graphql 使用Relay和GraphQL进行查询 - Query with Relay and GraphQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM