[英]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.