Skip to content

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

Open
steverice wants to merge 18 commits intoalloy-framework:mainfrom
pinterest:feature/graphql-js
Open

Add @alloy-js/graphql language bindings backed by graphql-js#358
steverice wants to merge 18 commits 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.

steverice and others added 14 commits September 25, 2025 21:38
GitHub does not run workflows by default in forked repositories; indeed, we do not want to run the workflows in the parent repo (which include things like publishing artifacts).

Instead, we create our own version of the `CI` workflow and will manually disable all the others (so those files can still be updated without merge conflict).
Fix sets with mapJoin (alloy-framework#199). Sets were just never supported in mapJoin
even though `For` said they were.

Also fixes an issue where immediately recursive effects wouldn't run.
Add support for floating points ending in .0 in Python implementation.

The current behavior just converts them into an integer.

---------

Co-authored-by: Steve Rice <steve@steverice.org>
Add an extra line after the ClassDoc, as described by [PEP
257](https://peps.python.org/pep-0257/#multi-line-docstrings):

> Insert a blank line after all docstrings (one-line or multi-line) that
document a class – generally speaking, the class’s methods are separated
from each other by a single blank line, and the docstring needs to be
offset from the first method by a blank line.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

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
mauriciogardini and others added 4 commits February 16, 2026 16:48
* Add Type Imports

* Lint

* Remove LocalImportSymbol, ensureTypeRefContext, special casing for typing imports, type param from Reference

* Further simplify the implementation

* Minor refactors
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.
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.

4 participants