我对graphql和AWS Amplify都是新手,所以请原谅任何无知:)
我有一个这样的graphql模式:
type Location @model @auth(rules: [{allow: owner}]){
street: String
city: String
state: String
zip: String
}
type Trip @model @auth(rules: [{allow: owner}]){
id: String!
...
location: Location
}
我正在尝试使用这样的突变请求同时创建位置和行程:
mutation {
createTrip(input: {
id: "someIdentifier",
location: {
street: "somewhere"
}
}) {
id
location {
street
}
}
}
但我收到这样的错误:
{
"data": null,
"errors": [
{
"path": null,
"locations": [
{
"line": 2,
"column": 21,
"sourceName": null
}
],
"message": "Validation error of type WrongType: argument 'input' with value '...' contains a field not in 'CreateTripInput': 'location' @ 'createTrip'"
}
]
}
检查生成的schema.graphql
文件,我看到输入模型上确实没有location
对象:
input CreateTripInput {
id: String!
...
}
如何让 amplify 生成正确的输入模式,以便我可以同时创建 Trip 和 location 对象?