Skip to content

GraphQL variable not working. #225

Answered by kettanaito
gajrajantino asked this question in Q&A
Discussion options

You must be logged in to vote

If you take a look at the Network tab and inspect the request you're making, you will see that there are no variables being sent by Apollo:

If there are no variables in the original request, then MSW cannot possibly know about them. For all the library cares, the variables were intentionally empty.

The issue here is in how you're using your $take and $skip variables. Looks like Apollo does some query sanitization and if you're not using your variables anywhere in your query, they will be removed. To fix this, forward your variables to any of the fields of your query:

const getSku = gql`
  query getSku($take: Int!, $skip: Int!) {
+   data
-   data(take: $take, skip: $skip)
  }
`

With this…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@gajrajantino
Comment options

@gajrajantino
Comment options

Comment options

You must be logged in to vote
1 reply
@gajrajantino
Comment options

Answer selected by gajrajantino
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