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
query MyNamedQueryWithAliases {
x3MasterData {
product {
subcoProduct: query (filter: "{productCategory: 'SUBCO'}", first: 5, orderBy: "{ code: -1 }") {
edges {
node {
code
accountingCode {
_id
type
accountingCode
localizedDescription
localizedShortDescription
_etag
_createStamp
_updateStamp
}
description1
localizedDescription1
productCategory{
code
}
}
}
}
sfiniProduct: query(filter: "{productCategory: 'SFINI'}", first: 5, orderBy: "{ code: -1 }") {
edges {
node {
code
accountingCode {
_id
type
accountingCode
localizedDescription
localizedShortDescription
_etag
_createStamp
_updateStamp
}
description1
localizedDescription1
productCategory{
code
}
}
}
}
}
}
}
Two lists of five products by product category (using fragment syntax)
query MyNamedQueryWithAliasesAndFragment {
x3MasterData {
product {
leftComparison: query(filter: "{productCategory: 'SUBCO'}") {
...comparisonFields
}
rightComparison: query(filter: "{productCategory: 'SFINI'}") {
...comparisonFields
}
}
}
}
fragment comparisonFields on Product_Query {
edges {
node {
code
productCategory {
code
}
accountingCode {
accountingCode
}
description1
localizedDescription1
}
}
}
First five products sorted by code in ascending order, with pagination and filtered using variable with default value
query ProductsInCategory($productFilter: String = "{productCategory: 'SFINI'}") {
x3MasterData {
product {
query(filter: $productFilter, first: 5, orderBy: "{ code: 1 }") {
edges {
node {
code
productCategory {
code
}
accountingCode {
accountingCode
}
description1
localizedDescription1
}
cursor
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}