我正在尝试创建一个以ReactJs
为前端,GraphQL
为服务层,Relay
为服务层和前端之间的通信的Web应用程序。
在此,我在服务层中创建了一个突变,并集成在前端。最后尝试使用以下命令生成文件
-
relay-compiler --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: 突变 GetActivityMessagesMutation($input:GetActivityMessagesRequestInput!){ ^3: getActivityMessagesRequest(input : $input){ 错误命令失败,退出代码为 100。 -
未找到 GraphQL
-
堆栈为空,无法将未定义转换为图形QL查询
我的中继脚本标签是
"relay": "relay-compiler --src ./src --schema ./schema.graphql --watchman false"
已尝试卸载重新安装所有软件包
"relay": "relay-compiler --src ./src --schema ./schema.graphql --watchman false"
无法使用中继编译器创建生成的突变文件
根据错误消息,GetActivityMessagesRequestInput
不是架构中定义的有效 graphQLinput
。
检查服务器架构中是否存在该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! }
OR 的自定义输入类型 改变我这样称呼突变的方式;
mutation SignIn ($email: String!, $password: String! ) {
signin(email: $email, password: $password){
user: { id, email }
token
}
我希望这有所帮助。