contract

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package contract builds a fixed content model and compares the public API generated from it (OpenAPI document, GraphQL introspection) with the snapshots in api/, so changes to the API surface are visible in review and checked for breaking changes in CI.

After an intended change, regenerate the snapshots:

UPDATE_API_CONTRACT=1 go test ./internal/openapi ./internal/graphql -run TestAPIContract

Index

Constants

View Source
const IntrospectionQuery = `` /* 893-byte string literal not displayed */

IntrospectionQuery is the standard GraphQL introspection query.

Variables

This section is empty.

Functions

func Compare

func Compare(name string, got []byte) error

Compare checks got against the snapshot, or rewrites the snapshot when UPDATE_API_CONTRACT is set. It returns a readable error on a mismatch.

func Encode

func Encode(v any) ([]byte, error)

Encode returns a stable, indented JSON encoding: object keys are sorted, and lists of named objects (GraphQL types, fields, arguments, enum values) are sorted by name, since their order is not part of the contract.

func Path

func Path(name string) string

Path is the snapshot file name under api/ in the repository.

func Seed

func Seed() error

Seed creates a content model that uses every attribute type, a component, singletons, relations and localized attributes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL