createMutation<DataType, ErrorType, VariablesType> method
Mutation<DataType, ErrorType, VariablesType>
createMutation<DataType, ErrorType, VariablesType>(
- String key,
- MutationFn<
DataType, VariablesType> mutationFn, { - RetryConfig? retryConfig,
Creates a new Mutation
If a Mutation with the same key already exists, it'll return the
existing Mutation and update the properties of the existing Mutation
Implementation
Mutation<DataType, ErrorType, VariablesType>
createMutation<DataType, ErrorType, VariablesType>(
String key,
MutationFn<DataType, VariablesType> mutationFn, {
RetryConfig? retryConfig,
}) {
final mutation = cache.mutations
.firstWhere(
(query) => query.key == key,
orElse: () => Mutation<DataType, ErrorType, VariablesType>(
key,
mutationFn,
retryConfig: retryConfig ?? this.retryConfig,
),
)
.cast<DataType, ErrorType, VariablesType>();
mutation.updateMutationFn(mutationFn);
cache.addMutation(mutation);
return mutation;
}