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;
}
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
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