Skip to content

Comments

Add @alloy-js/graphql language bindings backed by graphql-js#358

Open
steverice wants to merge 1 commit intoalloy-framework:mainfrom
pinterest:feature/graphql-js
Open

Add @alloy-js/graphql language bindings backed by graphql-js#358
steverice wants to merge 1 commit intoalloy-framework:mainfrom
pinterest:feature/graphql-js

Conversation

@steverice
Copy link
Contributor

@steverice steverice commented Feb 10, 2026

Introduce a new @alloy-js/graphql package that lets Alloy build GraphQL schemas via JSX components or STC helpers and emits a GraphQLSchema from graphql-js. The package defines a dedicated schema state + build/validation pipeline instead of the binder model, keeping the API aligned with GraphQL’s single global namespace and explicit naming semantics. Identity is based on name/namekey only—no refkeys or rename tracking—so changes to names are explicit and breaking by design.

Key capabilities included in this package:

  • Component API for schema constructs (Schema, ObjectType, InterfaceType, UnionType, InputObjectType, EnumType, ScalarType) plus Field, Argument, InputValue, and directives, with list/tagged child slot helpers to enforce valid component usage and nested list composition.
  • Relay-friendly helpers (Field.Connection, Connection.Edge, Connection.PageInfo, Connection.Fields) that generate connection and edge types, add pagination arguments, and enforce Relay schema rules when the Relay policy is selected.
  • GraphQL-specific name policy system (defaultNamePolicy, relayNamePolicy, createGraphQLNamePolicy) with optional formatters and regex rules for conventions, while always enforcing GraphQL hard requirements (spec name regex, reserved __ prefix, reserved enum values). namekey can bypass convention rules but still must satisfy GraphQL validity, and string type references are normalized through the active policy.
  • Built-in names and helpers for GraphQL scalars and Relay types (Node, PageInfo), plus root type helpers (Query, Mutation, Subscription) and directive application by name or namekey.

Supporting work rounds out the package with a README and API Extractor config, tsconfig/vitest setup, and extensive test coverage. Snapshot fixtures exercise real-world schemas (Star Wars, SpaceX, etc.) while targeted tests cover build behavior, schema definitions, directives, naming policies, connection behavior, and Relay validation rules.

Docs tooling is updated to include the new graphql package in API docs and to normalize declaration references during generation, and changelog entries plus lockfile updates capture the new workspace package.

If this is your first exposure to the GraphQL bindings, please see the README for important notes and design decisions.

Introduce a new `@alloy-js/graphql` package that lets Alloy build GraphQL schemas
via JSX components or STC helpers and emits a `GraphQLSchema` from `graphql-js`.
The package defines a dedicated schema state + build/validation pipeline instead
of the binder model, keeping the API aligned with GraphQL’s single global
namespace and explicit naming semantics. Identity is based on `name`/`namekey`
only—no refkeys or rename tracking—so changes to names are explicit and
breaking by design.

Key capabilities included in this package:
- Component API for schema constructs (`Schema`, `ObjectType`, `InterfaceType`,
  `UnionType`, `InputObjectType`, `EnumType`, `ScalarType`) plus `Field`,
  `Argument`, `InputValue`, and directives, with list/tagged child slot helpers
  to enforce valid component usage and nested list composition.
- Relay-friendly helpers (`Field.Connection`, `Connection.Edge`,
  `Connection.PageInfo`, `Connection.Fields`) that generate connection and edge
  types, add pagination arguments, and enforce Relay schema rules when the Relay
  policy is selected.
- GraphQL-specific name policy system (`defaultNamePolicy`, `relayNamePolicy`,
  `createGraphQLNamePolicy`) with optional formatters and regex rules for
  conventions, while always enforcing GraphQL hard requirements (spec name
  regex, reserved `__` prefix, reserved enum values). `namekey` can bypass
  convention rules but still must satisfy GraphQL validity, and string type
  references are normalized through the active policy.
- Built-in names and helpers for GraphQL scalars and Relay types (`Node`,
  `PageInfo`), plus root type helpers (`Query`, `Mutation`, `Subscription`) and
  directive application by `name` or `namekey`.

Supporting work rounds out the package with a README and API Extractor config,
`tsconfig`/`vitest` setup, and extensive test coverage. Snapshot fixtures exercise
real-world schemas (Star Wars, SpaceX, etc.) while targeted tests cover build
behavior, schema definitions, directives, naming policies, connection behavior,
and Relay validation rules.

Docs tooling is updated to include the new `graphql` package in API docs and to
normalize declaration references during generation, and changelog entries plus
lockfile updates capture the new workspace package.
@github-actions
Copy link
Contributor

All changed packages have been documented.

  • @alloy-js/graphql
Show changes

@alloy-js/graphql - feature ✏️

Added GraphQL language bindings using the graphql-js library

docs - internal ✏️

Make document builder work with generics and type aliases

@steverice steverice marked this pull request as ready for review February 10, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant