Skip to content

Latest commit

 

History

History
129 lines (100 loc) · 2.29 KB

changelog-v2-v3.md

File metadata and controls

129 lines (100 loc) · 2.29 KB

Migrating from v2 – v3

Replace document with documentNode

We are deprecating the document property from both QueryOptions and MutationOptions, and will be completely removed from the API in the future. Instead we encourage you to switch to documentNode which is AST based.

Before:

const int nRepositories = 50;

final QueryOptions options = QueryOptions(
    document: readRepositories,
    variables: <String, dynamic>{
        'nRepositories': nRepositories,
    },
);

After:

const int nRepositories = 50;

final QueryOptions options = QueryOptions(
    documentNode: gql(readRepositories),
    variables: <String, dynamic>{
        'nRepositories': nRepositories,
    },
);

Error Handling - exception replaces error

Replace results.error with results.exception

Before:

final QueryResult result = await _client.query(options);

if (result.hasError) {
    print(result.error.toString());
}
...

After:

final QueryResult result = await _client.query(options);

if (result.hasException) {
    print(result.exception.toString());
}
...

Mutation Callbacks have been Moved to MutationOptions

Mutation options have been moved to MutationOptions from the Mutation widget.

Before:

Mutation(
  options: MutationOptions(
    document: addStar,
  ),
  builder: (
    RunMutation runMutation,
    QueryResult result,
  ) {
    return FloatingActionButton(
      onPressed: () => runMutation({
        'starrableId': <A_STARTABLE_REPOSITORY_ID>,
      }),
      tooltip: 'Star',
      child: Icon(Icons.star),
    );
  },
  update: (Cache cache, QueryResult result) {
    return cache;
  },
  onCompleted: (dynamic resultData) {
    print(resultData);
  },
);

...

After:

...

Mutation(
  options: MutationOptions(
    documentNode: gql(addStar), 
    update: (Cache cache, QueryResult result) {
      return cache;
    },
    onCompleted: (dynamic resultData) {
      print(resultData);
    },
  ),
  builder: (
    RunMutation runMutation,
    QueryResult result,
  ) {
    return FloatingActionButton(
      onPressed: () => runMutation({
        'starrableId': <A_STARTABLE_REPOSITORY_ID>,
      }),
      tooltip: 'Star',
      child: Icon(Icons.star),
    );
  },
);

...