Graphql-flutter: not found in type: 'mutation_root': Undefined location when used with hasura

Created on 28 Jul 2019  路  3Comments  路  Source: zino-app/graphql-flutter

Describe the bug
I am trying to use the package with hasura qraphql, when I try to insert data using mutation I have the following error:

I/flutter ( 3689): [field "insert_mobile_tokens" not found in type: 'mutation_root': Undefined location]

are there any options that I miss?


this is my code


    String addToken =  r'''
    mutation addToken{
  insert_mobile_tokens(objects: {token_string: "dgdfg", os_type: "android"}) {
    returning {
      id
    }
  }
}

''';


    final MutationOptions options = MutationOptions(
      document: addToken,

      variables: <String, dynamic>{
//        'token': push_token,
      },
    );
    final QueryResult result = await Client.mutate(options);

    if (result.hasErrors) {
      print(result.errors);
      return;
    }

    final bool isStarrred =
    result.data['action']['starrable']['viewerHasStarred'] as bool;

    if (isStarrred) {
      print('Thanks for your star!');
      return;
    }


docs & examples link needs more info question

Most helpful comment

Probably you figure it out. However for any future questions. This error is thrown by Hasura when you don't have permissions. You must add in this case Insert permissions for the table you are inserting into. Also important since you are returning id, you must have permissions also for select. Since Hasura does first Insert and then select for your returning.

I am sure this can be closed now. @mainawycliffe

All 3 comments

I haven't worked with Hasura before, so am not able to help you since the error is being generated by Hasura. One thing i have noticed, is that you are passing a variable to you mutation, which doesn't accept variables. Also can you try and run the query on GraphiQL and see if it works.

For more help, please provide a reproducible example.

Probably you figure it out. However for any future questions. This error is thrown by Hasura when you don't have permissions. You must add in this case Insert permissions for the table you are inserting into. Also important since you are returning id, you must have permissions also for select. Since Hasura does first Insert and then select for your returning.

I am sure this can be closed now. @mainawycliffe

closing as this looks more like a server side / usage issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wisdom0063 picture Wisdom0063  路  26Comments

chimon2000 picture chimon2000  路  24Comments

micimize picture micimize  路  14Comments

rajihawa picture rajihawa  路  19Comments

dali546 picture dali546  路  17Comments