简体   繁体   English

Flutter_graphql变异不会触发apollo服务器解析器

[英]Flutter_graphql mutation not triggering apollo server resolver

I'm creating a Flutter application and reusing a appolographql server. 我正在创建一个Flutter应用程序并重用appolographql服务器。 The issue is that when i'm Mutating in Flutter, the resolver function is not being triggered. 问题是,当我在Flutter中进行Mutting时,解析器函数不会被触发。

The resolver is being triggered when using the playground, but not with flutter. 使用操场时会触发旋转变压器,但不会出现颤动。

This is the Flutter code : 这是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);
  },
),

This is the request body the server receives in the case of a flutter mutation 这是服务器在颤振突变的情况下接收的请求体

{ 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
' }

This is the request body the server receives in the case of a playground mutation 这是服务器在操场变异的情况下接收的请求体

{operationName:null,
variables:{},
query:
 mutation {\n  
   createOrUpdateHorse(horse: {id: 1, status: \"alo\"}, entityid: 5) 
{\n    
  id\n
  status\n  
}\n
}\n
}

Which version of graphql_flutter are you using? 您使用的是哪个版本的graphql_flutter? in version ^1.0.1 - mutation looks so: 在版本^ 1.0.1中 - 突变看起来如此:

r'''
mutation createOrUpdateHorse(
        $horse: HorseInput,
        $entityid: ID
        ){
        action: createOrUpdateHorse(
          input: {
            horse: $horse,
            entityid: $entityid
          }){
            id
            name
            status
            rating
          }
      } 
'''

My bad it was a stupid mistake, I forgot the "!" 我的坏是一个愚蠢的错误,我忘记了“!” for HorseInput!. 对于HorseInput!。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM