【发布时间】:2019-10-08 00:37:54
【问题描述】:
我正在创建一个 Flutter 应用程序并重用一个 appolographql 服务器。 问题是当我在 Flutter 中变异时,解析器功能没有被触发。
解析器在使用 Playground 时被触发,但不是 Flutter。
这是 Flutter 代码:
Mutation(
options: MutationOptions(
document: r"""
mutation createOrUpdateHorse($horse:HorseInput,$entityid:ID) {
createOrUpdateHorse(horse:$horse,entityid:$entityid) {
id
name
status
rating
}
}
""",
// variables: {
// "horse": {"id": 1, "status": "bu"},
// "entityid": 1
// },
),
builder: (
RunMutation runMutation,
QueryResult result,
) {
return IconButton(
icon: Icon(Icons.cloud_upload),
onPressed: () => runMutation({
"horse": {"id": 1, "status": "bu"},
"entityid": 1
}),
);
},
onCompleted: (resultData) {
print(resultData);
},
),
这是在颤振突变的情况下服务器收到的请求正文
{ operationName: 'createOrUpdateHorse',
variables: { entityid: 1, horse: { id: 1, status: 'bu' } },
query:
'mutation createOrUpdateHorse($horse:HorseInput,$entityid:ID) {\n createOrUpdateHorse(horse:$horse,entityid:$entityid) {\n
id\n
status\n
}\n
}\n
' }
这是在 Playground 突变的情况下服务器收到的请求正文
{operationName:null,
variables:{},
query:
mutation {\n
createOrUpdateHorse(horse: {id: 1, status: \"alo\"}, entityid: 5)
{\n
id\n
status\n
}\n
}\n
}
【问题讨论】:
标签: flutter graphql apollo-server