-
Hi, Working with v4 and composition API. What might I be doing wrong, if the variables aren't being sent with the mutation data? I have two refs for username and password, the refs are v-models for the input fields. The only way I can make the mutation work, is to add the variables in the template call of the mutation method. <template>
<q-dialog ref="dialogRef">
<q-card square bordered class="q-pa-lg shadow-1">
<q-card-section>
<q-form class="q-gutter-md">
<q-input square filled clearable v-model="username" type="email" label="username" />
<q-input square filled clearable v-model="password" type="password" label="password" />
</q-form>
</q-card-section>
<q-card-actions class="q-px-md">
<q-btn unelevated color="light-green-7" size="lg" class="full-width" label="Login" @click="login({username: username, password: password})"/> //<--- this!!!
</q-card-actions>
<q-card-section class="text-center q-pa-none">
<p class="text-grey-6">Not registered? Create an Account</p>
</q-card-section>
</q-card>
</q-dialog>
</template> I'm using Quasar Framework. Could it have something to do with using Quasar's dialog plugin? Scott |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Ok. I've got the answer. Should have read the docs a little more carefully. (maybe the docs can be improved to not show a non-working example 🤔). At any rate, making variables a return of an arrow function fixed the problem. const { mutate: login } = useMutation(gql`mutation login ($password: String!, $username: String!){
login(password: $password, username: $username){
accessToken
}
}`,
() => ({ // <-- this!!!!!
variables: {
username: username.value,
password: password.value
},
update: async (cache , { data: { login: { accessToken} } }) =>{
.....
})) Scott |
Beta Was this translation helpful? Give feedback.
Ok. I've got the answer. Should have read the docs a little more carefully. (maybe the docs can be improved to not show a non-working example 🤔). At any rate, making variables a return of an arrow function fixed the problem.
Scott