EnterpriseInput 输入中 "tools" 的正确类型是什么?
what would be the correct type for "tools" in EnterpriseInput input?
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: Tool
}
type Enterprise {
id: ID!
cnpj: String!
name: String!
email: String!
password: String!
tools: [Tool]
}
type Tool {
id: ID!
name: String!
brand: String!
cod: String!
qnt: Int!
}
type Query {
enterprises: [Enterprise]
enterprise( id: ID!): Enterprise
}
type Mutation {
createEnterprise( input: EnterpriseInput!): Enterprise!
# updateEnterprise( id: ID!, input: EnterpriseInput!): Enterprise!
deleteEnterprise( id: ID!): Boolean,
}
控制台上的错误消息:
C:\Users\Elias\code\web\backEnd-gestordeferramentas\node_modules\graphql\type\validate.js:69
throw new Error(errors.map(function (error) {
^
Error: The type of EnterpriseInput.tools must be Input Type but got: Tool.
at assertValidSchema (C:\Users\Elias\code\web\backEnd-…
在突变中,您不能使用标准对象类型,而必须改用输入类型。在输入类型中你必须使用输入类型
所以不用
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: Tool
}
试试这个
input ToolInput {
id: ID!
name: String!
brand: String!
cod: String!
qnt: Int!
}
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: ToolInput
}
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: Tool
}
type Enterprise {
id: ID!
cnpj: String!
name: String!
email: String!
password: String!
tools: [Tool]
}
type Tool {
id: ID!
name: String!
brand: String!
cod: String!
qnt: Int!
}
type Query {
enterprises: [Enterprise]
enterprise( id: ID!): Enterprise
}
type Mutation {
createEnterprise( input: EnterpriseInput!): Enterprise!
# updateEnterprise( id: ID!, input: EnterpriseInput!): Enterprise!
deleteEnterprise( id: ID!): Boolean,
}
控制台上的错误消息:
C:\Users\Elias\code\web\backEnd-gestordeferramentas\node_modules\graphql\type\validate.js:69
throw new Error(errors.map(function (error) {
^
Error: The type of EnterpriseInput.tools must be Input Type but got: Tool.
at assertValidSchema (C:\Users\Elias\code\web\backEnd-…
在突变中,您不能使用标准对象类型,而必须改用输入类型。在输入类型中你必须使用输入类型
所以不用
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: Tool
}
试试这个
input ToolInput {
id: ID!
name: String!
brand: String!
cod: String!
qnt: Int!
}
input EnterpriseInput {
cnpj: String
name: String
email: String
password: String
tools: ToolInput
}