From 70b6945200b8047952c5de15b100e79dd90f364b Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Wed, 18 Oct 2023 11:00:05 +0600 Subject: [PATCH] docs: add dynamic mutation --- docs/docs/basics/Mutations.mdx | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/docs/basics/Mutations.mdx b/docs/docs/basics/Mutations.mdx index 30789a4..6f60504 100644 --- a/docs/docs/basics/Mutations.mdx +++ b/docs/docs/basics/Mutations.mdx @@ -215,4 +215,36 @@ You can use the `Mutation.reset` method to reset the mutation to its initial sta ```dart await mutation.reset(); -``` \ No newline at end of file +``` + +### Dynamic key + +You can use Dart's string interpolation to dynamically generate the key for a mutation. This is useful when you want +separate mutations that has same data type but are triggered by different events. + + + + +```dart +MutationBuilder, dynamic, Map, dynamic>( + 'sign-up?provider=$authProvider', + (variable) => auth.signUp(variable, provider: authProvider), +) +``` + + + + +```dart +final mutation = useMutation, dynamic, Map, dynamic>( + 'sign-up?provider=$authProvider', + (variable) => auth.signUp(variable, provider: authProvider), +) +``` + + + + +> For every `authProvider` a new mutation will be created and will be cached separately. Which are also isolated from each other. + +> Btw, `authProvider` and `auth.signUp` are imaginary variables and methods \ No newline at end of file