Create - WunderGraph

Usage

Exclude

By default, all top-level nodes will be included in the schema unless explicitly excluded.

npx wgc contract create <name> --source <federated-graph-name> --exclude internal -r <routing-url>

Include

Child nodes inherit inclusion from their parent unless explicitly excluded. For example, an included Object would include all its field unless explicitly excluded. Similarly, an included field would include all its field arguments unless explicitly excluded.

By default, no top-level nodes will be included in the schema unless explicitly included.

npx wgc contract create <name> --source <federated-graph-name> --include public -r <routing-url>

Include and exclude together

Minimum Requirements
Package Minimum version
wgc 0.126.2

The include and exclude tag sets must be mutually exclusive. If the same tag is added to both the include and exclude sets, an error will be returned.

If both include and exclude tags are provided, the behaviour is thus:

  1. The schema starts blank (no nodes)
  2. Top-level (parent) nodes (Enums, Inputs, Interfaces, Objects, Scalars, and Unions) are included if they define a specified tag to include.
  3. Child-level nodes (Enum values, Input fields, Interface fields, Object fields) are also included unless the child defines a specified tag to exclude.
  4. Argument nodes (Object field arguments and Interface field arguments) are included if the corresponding field is included unless the field argument defines a specified tag to exclude.
npx wgc contract create <name> --source <federated-graph-name> --include public --exclude internal -r <routing-url>

Description

The npx wgc contract create command allows you to create a contract from a federated graph or monograph by providing tags to exclude from the schema. This will create a new contract graph linked to the source graph.

Parameters

Required Options

-r , --routing-url: The routing URL of your router. This URL defines the endpoint where the router will be accessible. The contract graph will be accessible through this router. --source: The name of the source graph from which contract is created.

Options

Examples

Create a contract graph named production-external from the source graph schema of production that excludes all schema elements tagged with internal or experimental:

npx wgc contract create production-external --source production --exclude internal experimental -r http://router.example.com/graphql

Create a contract graph named production-external from the source graph schema of production that includes all schema elements tagged with public or api:

npx wgc contract create production-external --source production --include public api -r http://router.example.com/graphql

Create a contract graph named public-api from the source graph schema of supergraph that includes all schema elements tagged with core or api and excludes all schema elements tagged with classified or internal:

npx wgc contract create public-api --source supergraph --include core api --exclude classified internal -r http://router.example.com/graphql