我在创建可以用babel-relay-plugin解析而不会出错的schema.json文件时遇到问题。看一下中继的example文件夹中包含的schema.json文件,我试图在GraphiQL中复制查询,但似乎无法正确处理。我正在使用Laravel作为后端。我可以通过GraphiQL或向GraphQL端点发送请求并保存响应来完成此操作吗?
尝试解析schema.json文件时发生的错误:
Cannot read property 'reduce' of undefined while parsing file: /Users/username/Sites/Homestead/Code/ineedmg-graphql/resources/assets/js/app.js
最后一次使用GraphiQL的尝试:
{
__schema {
queryType {
name
},
types {
kind,
name,
description,
fields {
name,
description,
type {
name,
kind,
ofType {
name
description
}
}
isDeprecated,
deprecationReason,
},
inputFields {
name
description
}
interfaces {
kind
name
description
},
enumValues {
name
description
isDeprecated
deprecationReason
}
},
mutationType {
name
},
directives {
name,
description,
onOperation,
onFragment,
onField,
args {
name
description
defaultValue
}
}
}
}
是的!如果看一下示例,可以看到它们schema.json
通过执行查询来生成文件:https : //github.com/relayjs/relay-starter-kit/blob/84da9351d100f97e6ed4f08bc70a893779e61c29/scripts/updateSchema.js#L11
该查询实际上只是来自graphql-js的特定查询:https : //github.com/graphql/graphql-js/blob/v0.4.12/src/utilities/introspectionQuery.js#L11-L89。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句