Example GraphQL queries for Products
Less than to read
- Two lists of five products by product category, sorted by code in descending order, with aliases
- Two lists of five products by product category (using fragment syntax)
- First five products sorted by code in ascending order, with pagination and filtered using variable with default value
Two lists of five products by product category, sorted by code in descending order, with aliases
{
sage {
x3Products {
subcoProduct: product(filter: "{productCategory: 'SUBCO'}", first: 5, orderBy: "{ code: -1 }") {
edges {
node {
code
productCategory
accountingCode
description1
localizedDescription1
}
}
}
sfiniProduct: product(filter: "{productCategory: 'SFINI'}", first: 5, orderBy: "{ code: -1 }") {
edges {
node {
code
productCategory
accountingCode
description1
localizedDescription1
}
}
}
}
}
}
Two lists of five products by product category (using fragment syntax)
{
sage {
x3Products {
leftComparison: product(filter: "{productCategory: 'SUBCO'}") {
...comparisonFields
}
rightComparison: product(filter: "{productCategory: 'SFINI'}") {
...comparisonFields
}
}
}
}
fragment comparisonFields on Sage_X3Products_Product_Connection {
edges {
node {
code
productCategory
accountingCode
description1
localizedDescription1
}
}
}
First five products sorted by code in ascending order, with pagination and filtered using variable with default value
# If you need to use another value than the default value of
# $productFilter, just put it in the Query Variables zone, e.g :
# {"productFilter" : "{productCategory: 'SUBCO'}"}
query ProductsInCategory($productFilter: String = "{productCategory: 'SFINI'}") {
sage {
x3Products {
product(filter: $productFilter, first: 5, orderBy: "{ code: 1 }") {
edges {
node {
code
productCategory
accountingCode
description1
localizedDescription1
}
cursor
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}