Open DarkLite1 opened 4 years ago
Anything you pass to mutate()
is merged with anything you pass to useSetLanguageMutation({variables: ... })
so it can work both ways.
In your case uou can pass your variables directly to mutate()
, you don't need to pass them to useSetLanguageMutation({variables: ...})
also.
The functions created by this library are thin wrappers around vue-apollo's composition API, you can find some documentation here: https://v4.apollo.vuejs.org/guide-composable/mutation.html
@DarkLite1 I was having the same issue, so thanks for posting the question and ask for documentation.
To extend on what @cdrx mentioned, you cannot "initialize" the mutate by const { mutate, loading, error, onDone } = useSetLanguageMutation()
You need to initialize it with an empty object. const { mutate, loading, error, onDone } = useSetLanguageMutation({})
Then you can call mutate({ language: newLanguage })
Describe the bug Currently there's no example on how to use the
useUpdateBooksMutation
or something similar in the docs. It would be great if someone with knowledge could provide a simple example whereloading
,error
onDone
andmutation
are used.Additional context
Consider this mutation:
For this to work I created a file called
setLanguage.graphql
for graphql-codegen (a full options object as used in the Playground would've been better but I don't have that skill yet):Using this in a component in
Settings.vue
looks like this:Questions/unclear
I don't understand why the function
useSetLanguageMutation
needs to be initialized with avariables
value already? It would be great if one could just do this:On a side note, when calling the
mutate()
function, the one that really executes the mutation, are theloading
and otherconst
returned byuseSetLanguageMutation
still usable?I'm sorry for these stupid questions, but as you can see I'm a noob and would love to have a more detailed example or at least one example on how to properly use the
useMutation
generated by the graphql codegen. It would even be better if it would include an example on how to update the cache too, but this is of course out of scope for the codegen. I tried to follow this example but it's for react.Thank you anyhow for reading this far.