[英]Relay Schema Cache not updating
I'm getting the following message in the developer console: " 我在开发人员控制台中收到以下消息:
Uncaught Error: GraphQL validation error.
未捕获的错误:GraphQL验证错误。
Cannot query field XXXX in YYYY.js.
Try updating your GraphQL schema if an argument/field/type was recently added如果最近添加了参数/字段/类型,请尝试更新您的GraphQL模式
I have already tried running npm start in order to update the schema. 我已经尝试过运行npm start来更新架构。 What am I doing wrong?
我究竟做错了什么?
You may want to create a build function for your updating your client schema, and include a script within your package.json to run this automatically using nodemon. 您可能想要创建一个用于更新客户端架构的构建函数,并在package.json中包含一个脚本,以使用nodemon自动运行此脚本。
This is the script that I use. 这是我使用的脚本。
#!/usr/bin/env babel-node --optional es7.asyncFunctions
import fs from 'fs'
import path from 'path'
import Schema from './schema.js'
import touch from 'touch'
import { graphql } from 'graphql'
import { introspectionQuery, printSchema } from 'graphql/utilities'
const p = '../../../client/schema-build/schema.json';
// Save JSON of full schema introspection for Babel Relay Plugin to use
(async () => {
var result = await (graphql(Schema, introspectionQuery))
if (result.errors) {
console.error(
'ERROR introspecting schema: ',
JSON.stringify(result.errors, null, 2)
)
} else {
fs.writeFileSync(
path.join(__dirname, p),
JSON.stringify(result, null, 2)
)
touch('../../../client/index.js', {}, () => {
process.exit(0)
})
}
})()
// Save user readable type system shorthand of schema
fs.writeFileSync(
path.join(__dirname, p),
printSchema(Schema)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.