You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to pass a variable into a query, but keep running into issues and I'm not sure exactly why.
My query looks like this...
let queryVar = client.variable('currentTags', 'String!', currentTags); // currentTags = 'camping OR green'
console.log(queryVar); // echoes out the VariableDefinition, which looks correct
client.send(gql(client)
`query ($currentTags: String!) {
shop {
products(first: 5, query: $currentTags) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
id
title
options {
name
values
}
variants(first: 25) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
title
selectedOptions {
name
value
}
image {
src
}
price
}
}
}
images(first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
src
}
}
}
}
}
}
}
}
`, [queryVar]).then((res) => {
console.log('res is ', res);
});
But I keep getting issues like expected Hash to be a Array if I pass the variable like [{currentTags: currentTags}] and an error like Variable currentTags of type String! was provided invalid value if I pass the variable like above.
Any suggestions?
The text was updated successfully, but these errors were encountered:
Howdy everyone.
I'm attempting to pass a variable into a query, but keep running into issues and I'm not sure exactly why.
My query looks like this...
But I keep getting issues like
expected Hash to be a Array
if I pass the variable like[{currentTags: currentTags}]
and an error likeVariable currentTags of type String! was provided invalid value
if I pass the variable like above.Any suggestions?
The text was updated successfully, but these errors were encountered: