facebook - 为 GitHub 获取 GraphQl __schema
问题描述
我正在尝试使用 get-graphql-schema 获取 GitHub 的架构,但出现错误:-
# npm install -g get-graphql-schema
# get-graphql-schema https://api.github.com/graphql
*TypeError: Cannot read property '__schema' of undefined
at Object.buildClientSchema
(C:\Users\Aaron\AppData\Roaming\npm\node_modules\get-graphql-schema\node_modules\graphql\utilities\buildClientSchema.js:48:43)*
我对 Facebook 也有同样的看法,我不确定这是不是因为他们没有给出模式,或者它是否是get-graphql-schema的错误。
如何在 GraphiQL 资源管理器中以编程方式使用 GraphQl 通常获取架构?
解决方案
好的,这是一个以编程方式查询 __schema 条目的 GraphQL 脚本:-
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
description
args {
...InputValue
}
onOperation
onFragment
onField
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
https://gist.github.com/AaronNGray/c873c093f7015389cd7358d7270e1e1e
推荐阅读
- scala - 映射列表时使用归纳结构的Scala案例匹配失败
- javascript - 在 React 中使用 axios 下载单个文件为 pdf 和多个文件为 zip
- python - 为 pandas 中的每个类按平均值查找具有代表性的观察值
- api - 使用 curl 发布“使用错误/非法格式或缺少 URL”
- python - 如何在networkx图中显示连接列表?
- mysql - 如何添加一个mysql列值作为where查询条件的关键字?
- mysql - 如何在 SQL 中正确插入 CSV 文件?
- reactjs - 如何从 React Native 中的子组件访问父级中的多个状态
- autodesk-forge - Forge Autodesk:标记拖动事件触发器
- flutter - 调整窗口大小时如何设置新状态?