[英]Unable to generate auto generated files in relay compiler for mutations
我正在尝试使用ReactJs
作为前端、 GraphQL
作为服务层和Relay
作为服务层和前端之间的通信来创建一个 Web 应用程序。
在此我在服务层创建了一个突变并集成到前端。最后尝试使用以下命令生成文件
中继编译器 --src ./src --schema ./schema.graphql
get-graphql-schema http://localhost:6001/xampr > schema.graphql
通过抛出此错误,这些都不起作用
编写js
错误:
您提供了一个带有验证错误的 GraphQL 文档:未知类型“GetActivityMessagesRequestInput”。 Services/Auth/GetActivityMessagesMutation.js (2:49) 1: 2: mutation GetActivityMessagesMutation($input:GetActivityMessagesRequestInput!) { ^3: getActivityMessagesRequest(input : $input){ error 命令失败,退出代码 100。
找不到 GraphQL
堆栈为空无法将未定义转换为 graphQL 查询
我的中继脚本标签是
"relay": "relay-compiler --src ./src --schema ./schema.graphql --watchman false"
试图卸载并重新安装所有软件包
"relay": "relay-compiler --src ./src --schema ./schema.graphql --watchman false"
无法使用中继编译器创建生成的变异文件
根据错误消息, GetActivityMessagesRequestInput
不是您的架构中定义的有效 graphQL input
。
检查您的服务器架构是否存在该input
定义,否则查看传递给该突变的正确input
是什么。 您不妨直接调用scalar input
。
它可能是GetActivityMessagesCreateInput
。
举例说明我的意思。
signin(email: String!, password: String!): AuthPayload! updateProfile(data: UserUpdateInput!, id: ID): User!
如果我像这样调用符号突变
mutation SignIn ($input: SignInMutationInput!) { signin(input: $input){ user: { id, email } token }
它将返回与您相同的错误,说You supplied a GraphQL document with validation errors:Unknown type "SignInMutationInput"
为了解决上述问题,我可以在我的服务器中创建一个自定义输入类型,称为input SignInMutationInput { email: String! password: String! }
input SignInMutationInput { email: String! password: String! }
input SignInMutationInput { email: String! password: String! }
或更改我打电话,像这样的突变的方式;
mutation SignIn ($email: String!, $password: String! ) { signin(email: $email, password: $password){ user: { id, email } token }
我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.