Skip to content

Understanding the Schema

Bagisto Headless uses a powerful GraphQL API to communicate between the Next.js storefront and the Laravel backend. This document provides an overview of how the schema is organized and the key entities you will interact with.

1. Schema Organization

The GraphQL integration is modularly organized in src/graphql/, divided by core e-commerce domains:

ModuleResponsibility
catalogProduct listings, individual details, and category trees.
cartCart management, adding/removing items, and merging tokens.
checkoutMulti-step checkout, addresses, shipping, and payments.
customerAuthentication, registration, login and verify-customer
themeStorefront configuration, banners, and static page content.

2. Core Entity Relationships

3. Key Type Definitions

We use TypeScript interfaces to mirror the GraphQL types, providing full type safety across the frontend.

TypeDescriptionFile
ProductCoreMinimal product data for grids (ID, SKU, Price, Image).types/product.types.ts
ProductDetailedComplete product metadata including cross-sells and variants.types/product.types.ts
PageInfoStandard Relay-style pagination metadata.types/product.types.ts
CategoryHierarchical data with support for localized translations.catelog/queries

4. Pagination Pattern

Most listing queries (Products, Search, Categories) follow a Relay-style pagination pattern using Edges and Nodes.

graphql
query GetProducts {
  products(first: 10) {
    totalCount
    pageInfo {
      hasNextPage
      endCursor
    }
    edges {
      node {
        id
        name
        price
      }
    }
  }
}
  • Edges: An array of objects containing the item (Node) and potentially metadata about that specific connection.
  • Node: The actual data object (e.g., the Product).
  • PageInfo: Indicators of whether more pages exist and the cursors for fetching them.

📖 Continue Reading:

Released under the MIT License.