Skip to content

variables not being sent with the mutation #1283

Answered by smolinari
smolinari asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@smolinari
Comment options

@Akryum
Comment options

@smolinari
Comment options

@Akryum
Comment options

@smolinari
Comment options

Answer selected by smolinari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants