Skip to content

schemas

@evolve-framework/schemas · v1.0.0

The contract every Evolve backend speaks. It holds the GraphQL schema a storefront queries: carts, catalog, checkout, orders and quotes, and the content pages a CMS serves. It also holds the JSON Schemas of the events and notifications services send each other. Every commerce engine and CMS package serves this one schema, so a storefront can switch from one engine or CMS to another without changing a query.

When to use

  • You are generating resolver types for an engine, or for a project module that serves part of the contract.
  • A module serves a part of the schema and needs its type definitions, such as the cart, with or without the B2B fields.
  • A resolver answers a paginated field and should clamp and describe pages the way every other engine does.
  • A service validates an internal event or notification against its JSON Schema.

Get started

  1. Install the package with the peer dependencies it needs. It comes from the Evolve registry, which needs a one-time sign-in.

    pnpm add @evolve-framework/schemas graphql
    Requirements1
    graphql>= 16.0.0 < 17.0.0

For example:

import { defineCommerceCodegen } from "@evolve-framework/schemas";
// codegen.ts: resolver types for the parts of the contract an engine serves,
// with the scalar mapping every engine shares.
export default defineCommerceCodegen({
schemaFiles: ["cart.ts", "catalog.ts", "order.ts"],
schemaOptions: { includeB2B: true },
});

Entry points

@evolve-framework/schemasresolveGraphQLSchema and defineCommerceCodegen, the shared SDL snippets, and the resolver helpers: resolvePaginationArgs and buildPagination, resolveOrderKey, filterAddresses and filterAssociates, and cartPreviewImages and cartDefaultName131 exports