【发布时间】:2020-11-26 15:45:35
【问题描述】:
Graphql 架构:
type SDKConfig @model
@key(name: "byPublisher", fields: ["publisher_id", "id"]){
id: ID!
publisher_id: ID!
facebook_app_id: String
adjust_app_token: String
}
type GameConfig @model
@auth(rules: [
{allow: owner},
{allow: groups, groupsField: "groups"}]){
id: ID!
game_name: String!
bundle_identifier: String!
sdkConfigs: [SDKConfig] @connection(keyName: "byPublisher", fields: ["id"])
groups: [String]
}
突变:
export const createGameConfig = /* GraphQL */ `
mutation CreateGameConfig(
$input: CreateGameConfigInput!
$condition: ModelGameConfigConditionInput
) {
createGameConfig(input: $input, condition: $condition) {
id
game_name
bundle_identifier
sdkConfigs {
items {
id
publisher_id
facebook_app_id
adjust_app_token
createdAt
updatedAt
}
nextToken
}
groups
createdAt
updatedAt
owner
}
}
`;
反应函数:
async function createGame() {
try {
const newgame = {
"game_name": "deneme",
"bundle_identifier": "com.magiclab.deneme",
sdkConfigs: [
{ "publisher_id": 5,
"facebook_app_id": "fb12313",
"adjust_app_token": "adjusttoken123123",
}
]
}
await API.graphql(graphqlOperation(createGameConfig, {input: newgame}))
} catch (err) {
console.log('error creating game sdk config:', err)
}
}
错误信息:
“变量输入包含一个字段名称'sdkConfigs',该字段名称未为输入对象类型'CreateGameConfigInput'定义”
我想在对象中创建一个对象数组。如何修复 graphql 的输入对象?
【问题讨论】:
-
@xadm 我试过了。但不工作。返回相同的错误
-
检查 >>>输入类型
-
如果未定义,则看起来不支持这种“嵌套突变”
标签: javascript reactjs graphql aws-amplify