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,
},
);
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 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),
);
},
);
...