upsert<_Model extends GraphqlModel> method
Future<Response?>
upsert<_Model extends GraphqlModel>(
- _Model instance, {
- Query? query,
- ModelRepository<
GraphqlModel> ? repository,
Insert or update a model instance
Implementation
@override
Future<Response?> upsert<_Model extends GraphqlModel>(instance, {query, repository}) async {
final adapter = modelDictionary.adapterFor[_Model]!;
final variables = await adapter.toGraphql(instance, provider: this, repository: repository);
final request = GraphqlRequest<_Model>(
action: QueryAction.upsert,
instance: instance,
modelDictionary: modelDictionary,
query: query,
variableNamespace: variableNamespace,
variables: variables,
).request;
if (request == null) return null;
await for (final resp in link.request(request)) {
return resp;
}
return null;
}