search
This query can be used to fetch information about search facets, products and suggestions according to a given search term.
Usage​
Arguments
first
*Int
Number of items that should return from the complete result list.
after
String
Pagination argument, indicating the cursor corresponding to the item after which the results should be fetched.
sort
StoreSort
Search 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
.
term
String
Search term.
selectedFacets
IStoreSelectedFacet
Array 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.
StoreSearchResult
facets
: [StoreFacet!]!StoreSuggestions
: StoreSuggestions!StoreProductConnection
pageInfo
: 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
wooden
term.
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
10
in the search from thesteel
term. 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
table
term.
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
}
}
}