0

I am not sure if I understand this error at all. Anyone with experience using graphql_flutter package please help out. Totally new to Flutter and graphql. But so far I have figured the backend.

My mutation works in graphiql, trying to make it work in flutter. This is error that shows up when I hover over those red lines.

ERROR - The argument type 'Column Function(MultiSourceResult Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult)' can't be assigned to the parameter type 'Widget Function(MultiSourceResult Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult?)'. (Documentation)

Here is the snip - enter image description here

class GraphQlMutations {

  String createUser() { return"""
    mutation createUser(\$id: String!, \$name: String!, \$email: String!) {
      createUser(objects: [{ id: $id, name: $name, code: $code }]) {
        returning {
          id
          name
          email
        }
      }
    }
  """;
  } 
}

1 Answer 1

8

Compare both declarations in your error and see the difference:

Column Function(MultiSourceResult Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult)
Widget Function(MultiSourceResult Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult?)

Since Column is a Widget, the only real difference is the nullability of QueryResult. Therefore, change

builder: (RunMutation createUser, QueryResult result)

to

builder: (RunMutation createUser, QueryResult? result)

and handle the case where the result is null.

1
  • Thanks Enzo, I was able to get the error out with the null check fix you mentioned, any idea why my mutation doesn't insert any data? I have added the added the query to the original post for reference.
    – Sumchans
    Commented Jul 3, 2021 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.