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 Getproducts {
    products {
        edges {
            node {
                id
                name
                summary
                description
                thumbnail
            }
        }
    }
}
Product Fields¶
Each product contains the following fields:
Basic Information¶
- id: Unique identifier
- name: Product name
- summary: Short product description
- description: Full product description (HTML formatted)
- slug: URL-friendly product identifier
- thumbnail: Product thumbnail image URL
- alias: Alternative product identifier
- metaTitle: SEO title
- metaDescription: 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 information
- relatedTo: Related products
- collections: Product collections
- tags: Product tags
- category: 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 {
    categories {
        edges {
            node {
                id
                name
                description
                metaTitle
                metaDescription
            }
        }
    }
}
Collections¶
Fetch product collections:
query GetCollections {
    collections {
        edges {
            node {
                id
                name
            }
        }
    }
}
Product Tags¶
Fetch product tags:
query GetProductTags {
    tags {
        edges {
            node {
                id
                name
            }
        }
    }
}
Search and Filtering¶
The API supports comprehensive search and filtering capabilities:
Search¶
query SearchProducts {
    products(search: "keyword") {
        edges {
            node {
                id
                name
            }
        }
    }
}
Available Filters¶
- name: Filter by product name
- summary: Filter by product summary
- description: Filter by product description
- category: Filter by category ID
- categoryName: Filter by category name
- brand: Filter by brand name
- collection: Filter by collection ID
- relatedTo: Filter by related product names
Example with Multiple Filters¶
query FilteredProducts {
    products(
        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 {
    products(first: 10, after: "cursor") {
        pageInfo {
            hasNextPage
            endCursor
        }
        edges {
            cursor
            node {
                id
                name
            }
        }
    }
}
Pagination Parameters¶
- first: Number of items to fetch
- after: Cursor for the next page
- before: Cursor for the previous page
- last: Number of items to fetch from the end
PageInfo Fields¶
- hasNextPage: Boolean indicating if more items exist
- endCursor: Cursor for the last item in the current page
- hasPreviousPage: Boolean indicating if previous items exist
- startCursor: 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.