search
This query can be used to fetch information about search facets, products and suggestions according to a given search term.
Usage​
Arguments
first*IntNumber of items that should return from the complete result list.
afterStringPagination argument, indicating the cursor corresponding to the item after which the results should be fetched.
sortStoreSortSearch result sorting mode, where StoreSort is an Enum with one of the possible values: price_desc, price_asc, orders_desc, name_desc, name_asc, release_desc, discount_desc and score_desc.
termStringSearch term.
selectedFacetsIStoreSelectedFacetArray of search facets (IStoreSelectedFacet), each with key and value.
- Query
- Response
query ($first: Int!){
search (first: $first) {
product {
# StoreProductConnection fields
},
suggestions {
# StoreSuggestions fields
},
facets {
# StoreFacet fields
}
}
}
Below you can see a list of all fields that can be queried with search. Click on the links to learn more details about each field.
StoreSearchResultfacets: [StoreFacet!]!StoreSuggestions: StoreSuggestions!StoreProductConnectionpageInfo: StorePageInfohasNextPage: boolean!hasPreviousPage: boolean!startCursor: string!endCursor: string!totalCount: int!
edges: [StoreProductEdge]!node: StoreProduct!- Product information. Check StoreProduct to see all possible fields.
cursor: string!
Example​
- Get the keys, labels, label values, and value amounts from the first three facets in the search result from the
woodenterm.
query {
search (first:3, term:"wooden") {
facets {
key,
label,
values {
quantity
}
}
}
}
- Get cursors, names, SKU IDs, and image URLs for the 10 products after the product with cursor
10in the search from thesteelterm. Also, get the total quantity of results in the complete list and whether there are more results for next page.
query {
search (first: 10, after: "10", term:"steel") {
products {
pageInfo {
hasNextPage,
totalCount
},
edges {
node {
name,
sku,
image {
url
}
},
cursor
}
}
}
}
- Get terms values, term counts, product names, and SKU IDs for the first five sugestions from a list sorted from higher to lower discount in the search result from the
tableterm.
query {
search (first:5, sort: discount_desc, term:"table") {
suggestions {
terms {
value,
count
},
products {
name,
sku
}
}
}
}
- Get information about facets, products and suggestions at once.
query {
search (first:5, after:"5", term:"wooden", sort:score_desc) {
products {
pageInfo {
totalCount,
hasNextPage,
endCursor
},
edges {
node {
name,
sku,
slug,
image {
url,
alternateName
}
},
cursor
}
},
suggestions {
terms {
value,
count
},
products {
name,
slug,
description
}
},
facets {
key,
label,
values {
value,
selected
},
type
}
}
}