https://www.shopify.com/partners/blog/query-argument-graphql
https://shopify.dev/api/usage/search-syntax
NOTE: the query syntax is presented stupidly in graphiql/grapql there is not an equal sign to start the query string:
So it’s # query: “price:<51 AND product_type:* AND has_only_default_variant:true”
NOT # query= “price:<51 AND product_type:* AND has_only_default_variant:true”
Install the graphiql app https://shopify.dev/apps/tools/graphiql-admin-api and explore the documentation of the nodes to identify properties you can use in query parameters.
product with a specific size, available in two specific colors, from a specific product type, and under the $50 price belonging to a specific collection. The size and the color would be the variants here
Please lead with and unwind your descriptions when seeking help with API structure , yes provide background but avoid burying the lead.
- In specific collection
- specific product type under the $50 price
- product VARIANT with OPTION a specific size
- that is available
- in two specific colors
There is no way to query by product|variant option AND also filter it with a querystring
If you try to go down through collections to products to variants, filter querying along the way you may hit this error:
Cannot filter by query if the collection is a custom collection
Here sample queries I threw together
query productVariants{
# , query: "collection:'Home page' AND price:<51 AND product_type:* AND managed:true"
# use managed true , inventory_quantity:<0 for inventory you care about
productVariants(first:10, , query: "price:<51 AND managed:true") {
edges{
node{
title
price
inventoryItem {
tracked
}
selectedOptions {
name
value
}
}
}
}
}
query collections {
collections(first: 10, query: "title:'Home page'") {
edges {
node {
title
id
}
}
}
}
You’ll want to change has_only_default_variant:true to false has_only_default_variant:false
query products{
products(
first: 10
query: "price:<51 AND product_type:* AND has_only_default_variant:true"
) {
edges {
node {
id
hasOnlyDefaultVariant
title
collections(first: 10) {
edges {
node {
id
title
}
}
}
inCollection(id: "gid://shopify/Collection/70598819862")
priceRangeV2 {
minVariantPrice {
amount
}
}
productType
options {
values
name
id
}
variants(first: 10) {
edges {
node {
id
}
}
}
}
}
}
}
And a combine example that cannot use query argument on a ProductConnection
query MyQuery {
collection(id: "gid://shopify/Collection/70598819862") {
id
title
ruleSet {
rules {
column
relation
condition
}
}
products(
first: 10
# if you try to use the below query you hit this problem:"" Cannot filter by query if the collection is a custom collection "
# query: "price:<51 AND product_type:* AND has_only_default_variant:true"
) {
edges {
node {
id
hasOnlyDefaultVariant
title
collections(first: 10) {
edges {
node {
id
title
}
}
}
inCollection(id: "gid://shopify/Collection/70598819862")
priceRangeV2 {
minVariantPrice {
amount
}
}
productType
options {
values
name
id
}
variants(first: 10) {
edges {
node {
id
selectedOptions {
name
value
}
}
}
}
}
}
}
}
}