Product and Related Queries¶
Introduction¶
Welcome to the NXTBN E-commerce GraphQL API documentation! This guide will help you integrate e-commerce functionality into your frontend application using GraphQL queries. This documentation is designed for developer and covers all essential aspects of product and related data retrieval and filtering.
The storefront graphql playground located here: http://127.0.0.1:8000/graphql/
Table of Contents¶
Basic Product Queries¶
Fetching a Single Product¶
To fetch a single product, use the product
query with a required ID
:
query GetProduct {
product(slug: "YOUR_PRODUCT_SLUG") {
id
name
summary
description
slug
price
thumbnail
metaTitle
metaDescription
}
}
Fetching a Single Product with default variant and Price¶
To fetch a single product along with its default variant and price, use the following query:
query GetProductWithDefaultVariant {
product(slug: "YOUR_PRODUCT_SLUG") {
id
name
summary
description
slug
thumbnail
metaTitle
metaDescription
defaultVariant {
id
name
price
}
}
}
fetching a single product with all variant¶
query GetProductWithAllVariants {
product(slug: "YOUR_PRODUCT_SLUG") {
id
name
summary
description
slug
thumbnail
metaTitle
metaDescription
variants {
name
id
price
priceRaw
priceWithoutSymbol
}
}
}
Fetching Multiple Products¶
To get a list of all products:
query GetAllProducts {
allProducts {
edges {
node {
id
name
summary
description
thumbnail
}
}
}
}
Product Fields¶
Each product contains the following fields:
Basic Information¶
id
: Unique identifiername
: Product namesummary
: Short product descriptiondescription
: Full product description (HTML formatted)slug
: URL-friendly product identifierthumbnail
: Product thumbnail image URLalias
: Alternative product identifiermetaTitle
: SEO titlemetaDescription
: SEO description
Variants¶
Products can have multiple variants with different prices and attributes:
query GetProductVariants {
product(id: "ID") {
variants {
id
name
price # Price with currency symbol
priceWithoutSymbol # Price without currency symbol
priceRaw # Raw price value
}
}
}
Related Data¶
brand
: Product brand informationrelatedTo
: Related productscollections
: Product collectionstags
: Product tagscategory
: Product category
Categories¶
Hierarchical Categories¶
Fetch categories in a tree structure:
query GetCategoryHierarchy {
categoriesHierarchical {
edges {
node {
id
name
description
children {
id
name
description
}
}
}
}
}
Flat Categories¶
Fetch all categories in a flat structure:
query GetCategories {
allCategories {
edges {
node {
id
name
description
metaTitle
metaDescription
}
}
}
}
Collections¶
Fetch product collections:
query GetCollections {
allCollections {
edges {
node {
id
name
}
}
}
}
Product Tags¶
Fetch product tags:
query GetProductTags {
allTags {
edges {
node {
id
name
}
}
}
}
Search and Filtering¶
The API supports comprehensive search and filtering capabilities:
Search¶
query SearchProducts {
allProducts(search: "keyword") {
edges {
node {
id
name
}
}
}
}
Available Filters¶
name
: Filter by product namesummary
: Filter by product summarydescription
: Filter by product descriptioncategory
: Filter by category IDcategoryName
: Filter by category namebrand
: Filter by brand namecollection
: Filter by collection IDrelatedTo
: Filter by related product names
Example with Multiple Filters¶
query FilteredProducts {
allProducts(
name_Icontains: "shirt"
categoryName_Icontains: "clothing"
brand_Icontains: "nike"
) {
edges {
node {
id
name
}
}
}
}
Pagination¶
The API uses cursor-based pagination for efficient data loading:
query PaginatedProducts {
allProducts(first: 10, after: "cursor") {
pageInfo {
hasNextPage
endCursor
}
edges {
cursor
node {
id
name
}
}
}
}
Pagination Parameters¶
first
: Number of items to fetchafter
: Cursor for the next pagebefore
: Cursor for the previous pagelast
: Number of items to fetch from the end
PageInfo Fields¶
hasNextPage
: Boolean indicating if more items existendCursor
: Cursor for the last item in the current pagehasPreviousPage
: Boolean indicating if previous items existstartCursor
: Cursor for the first item in the current page
Remember that all queries return data in a standardized format with edges and nodes, making it consistent to work with paginated and non-paginated data.