A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I have been using GraphQL for some time on other stores and everything has been working perfectly.
Introduced this to a new store today, and i am getting very random results.
From what i can see the Query for GraphQL i am running appears to be searching in more than just the SKU field. When searching for words or other strings in the SKU Variable
i can see results that are matched in the body_html (As if the Query is also searching in there)
Is this common? or do i have a typo / mistake in my Query.
Query:
query ($first: Int, $sku: String)
{ productVariants(first: $first, query: $sku) {
edges {
node {
title
id
sku
product {
title
}
inventoryItem {
id
inventoryLevels(first: 3) {
edges {
node {
id
available
location {
id
name
address {
city
}
}
}
}
}
}
}
}
}
}
And my Variables.
{
"first": 5,
"sku":"555"
}
In this case the SKU is searching for 555, the product it returns has a SKU of 12574, When i do a product lookup using the Rest API, i can see that 555 appears in the Body_html.
So when i replace 555 with a string found in the body_html it also returns that line, Making me thing i have an error / formatting issue in my GraphQL Query / Structure
Would appreciate any guidance on this
I know what the issue is:
query ($first: Int, $sku: String)
{ productVariants(first: $first, query: $sku) {
edges {
node {
This needs to be something like:
query ($first: Int)
{ productVariants(first: $first, query: "sku:555") {
edges {
node {
As it needed to be a variable, i was unsure how to format it, I fudged the variable but and now appears to be working.
I am interested in the correct formatting for query: sku: $sku Though
Here is the fudge:
{
"first": 5,
"sku": "sku:555"
}
Basically passing the search field sku: in the variable