Syntle
Syntle

Reputation: 5174

Variable "x" of required type "Type!" was not provided

I am getting the following error messages with the error code 400, I have tried the same mutation query in GraphQL playground and it worked, but it won't work through nuxt.

enter image description here

$apollo.mutate({
  mutation: gql`
    mutation Session(
      $accessToken: String!
      $refreshToken: String!
      $expiresIn: Int!
      $scope: String!
    ) {
      setSession(
        accessToken: $accessToken
        refreshToken: $refreshToken
        expiresIn: $expiresIn
        scope: $scope
      ) {
        id
        expiresIn
      }
    }
  `,
  variables() {
    return {
      accessToken: 'accessTkenTest',
      refreshToken: 'refreshTkenTest',
      expiresIn: 1000,
      scope: 'connections email',
    }
  },
})

Upvotes: 0

Views: 591

Answers (1)

Daniel Rearden
Daniel Rearden

Reputation: 84667

variables should be an object, not a function:

variables: {
  accessToken: 'accessTkenTest',
  refreshToken: 'refreshTkenTest',
  expiresIn: 1000,
  scope: 'connections email',
},

Upvotes: 1

Related Questions