Commit Graph
11531 Commits
Author SHA1 Message Date
Tim Smart c3a3b45930 docs(graphql): sync generated AI documentation 2026-10-12 16:00:47 +13:00
Tim Smart 56aad54d1c fix(graphql-generator): name generated groups GraphQLGroup 2026-10-12 16:00:47 +13:00
Tim Smart b431beeabe test(graphql-generator): expect GraphQLGroup exports 2026-10-12 16:00:47 +13:00
Tim 2cd87ac5bb Apply suggestion from @tim-smart 2026-10-12 16:00:47 +13:00
Tim Smart 38f0dc3aea refactor(graphql): restore explicit operation constructor signatures and isRetryable on error reasons 2026-10-12 16:00:47 +13:00
Tim Smart 2806d46dec refactor(graphql): simplification pass over runtime and generator
- GraphQL: one Constructor<K> signature shared by query/mutation/subscription
- GraphQLClientError: isRetryable lives on GraphQLClientError and TransportError only
- GraphQLProtocol: drop the test-only makeWebSocket overload, makeHttp is makeHttpWith
- GraphQLClient: inline the strict/partial decode choice
- Generator: drop unused directive definitions and specifiedBy from the schema model,
  one directory walk in Generate, one fragment-spread walker, one imports map in
  Emitter, merged object/interface SDL branches, smaller lexer/printer/parser/diagnostic
  helpers, shared toGenerateError
2026-10-12 16:00:47 +13:00
Tim Smart d61ad42a57 docs(graphql): tighten changesets and code comments 2026-10-12 16:00:47 +13:00
Tim Smart fb03671c04 feat(graphql): operation .middleware method, refined String schemas, explicit export types 2026-10-12 16:00:47 +13:00
Tim Smart c3621555c1 test(graphql): operation .middleware method and refined String schemas for otherTypename/enumLiterals 2026-10-12 16:00:47 +13:00
Tim Smart d8b8cbbb66 refactor(graphql): simplification pass over the client, transports and generator 2026-10-12 16:00:47 +13:00
Tim Smart a67edcb048 refactor(graphql): use Effect.fnUntraced for generator-bodied functions 2026-10-12 16:00:47 +13:00
Tim Smart bfe5d0eb5f test(graphql-generator): generate the GitHub set during tests from a schema subset 2026-10-12 16:00:47 +13:00
Tim Smart 33ced02825 docs(graphql): narrow the getting-started example pointer 2026-10-12 16:00:47 +13:00
Tim Smart 68af97d52d docs(graphql): trim the ai-docs to one getting-started example 2026-10-12 16:00:47 +13:00
Tim Smart 22c38fc595 fix(graphql-generator): exit 2 for invalid CLI usage 2026-10-12 16:00:47 +13:00
Tim Smart f6f0e5319c refactor(graphql): inline options types, drop middleware stack capture, simplify HTTP transport 2026-10-12 16:00:47 +13:00
Tim Smart 25be4486b2 test(graphql-generator): require exit 2 for CLI usage errors 2026-10-12 16:00:47 +13:00
Tim Smart 846eeb3d50 docs(graphql): generator README and ai-docs for effect/graphql 2026-10-12 16:00:47 +13:00
Tim Smart 318ac1266b chore(graphql): describe the transports and the generator in the changesets 2026-10-12 16:00:47 +13:00
Tim Smart 1fca7fa3cc chore(graphql-generator): drop internal tracker references from source comments 2026-10-12 16:00:47 +13:00
Tim Smart c6bbd026d4 test(graphql): reduce the suites to focused contracts and regressions 2026-10-12 16:00:47 +13:00
Tim Smart e978d9c642 fix(graphql): validate graphql-ws message shapes as graphql-ws does
Reject non-object ack/ping/pong payloads, empty ids, non-object next payloads
and error payloads that are not a non-empty list of entries with a message,
before any ack, keep-alive or routing state changes.
2026-10-12 16:00:47 +13:00
Tim Smart ecd10c7a65 test(graphql): cover the remaining invalid graphql-ws message shapes
Extend the 4400 table with the shapes graphql-ws's validateMessage rejects:
empty ids, array or missing next payloads, error payloads that are not a
non-empty list of formatted errors, and non-object ack/ping/pong payloads.
2026-10-12 16:00:47 +13:00
Tim Smart 1105ed2d8d fix(graphql): observe graphql-ws closes during connectionParams, reject invalid messages, treat 1002 as fatal
The socket is read while connectionParams runs, so a close fails waiting
operations; the ack timeout still starts after connection_init. An invalid
server message closes the connection with 4400. 1002 joins fatalCloseCodes.
2026-10-12 16:00:47 +13:00
Tim Smart f24da04075 test(graphql): cover graphql-ws closes during connectionParams, invalid messages and 1002
Failing regressions for review findings: a close while connectionParams is
pending must fail the waiting operation, an invalid server message must close
the connection with 4400, and 1002 must be fatal. A server pong stays valid.
2026-10-12 16:00:47 +13:00
Tim Smart a252bafcfc test(graphql): correct SSE failure timing and isolate idle timeout 2026-10-12 16:00:47 +13:00
Tim Smart beeefc1082 feat(graphql): graphql-ws and graphql-sse subscription transports
layerHttp sends subscriptions as graphql-sse distinct mode on the same URL,
or over graphql-ws with subscriptions.webSocket. layerWebSocket sends every
operation over one lazily connected, multiplexed graphql-ws socket with
connectionParams, an ack timeout, keep-alive pings, idle close and close-code
classification. makeHttp and makeWebSocket are exported as effects.
2026-10-12 16:00:47 +13:00
Tim Smart 85dcdb4e6f test(graphql): specify the graphql-ws and graphql-sse subscription transports
Failing tests ahead of the implementation: graphql-ws against an in-memory
WebSocketConstructor under TestClock, graphql-sse against a streaming
HttpClient, client-level resubscribe over WS, and one Node end-to-end test
with a hand-rolled server for POST, SSE and graphql-ws.
2026-10-12 16:00:47 +13:00
Tim Smart 6df83e8e64 fix(graphql-generator): keep watch kinds explicit and reconcile cycle targets 2026-10-12 16:00:47 +13:00
Tim Smart 1b6c6f07f9 test(graphql-generator): reproduce root creation during watch installation 2026-10-12 16:00:47 +13:00
Tim Smart 75e8889c29 fix(graphql-generator): recover watched roots that are missing, deleted or failing; keep the parse cache internal 2026-10-12 16:00:47 +13:00
Tim Smart 438501c6e4 test(graphql-generator): cover missing roots and rename-over saves 2026-10-12 16:00:47 +13:00
Tim Smart bb7782fd21 test(graphql-generator): trim watch coverage to focused regressions 2026-10-12 16:00:47 +13:00
Tim Smart 7e0b47aace feat(graphql-generator): graphqlgen --watch with debounced cycles, parsed-input caching and config reloads 2026-10-12 16:00:47 +13:00
Tim Smart 76983316ce test(graphql-generator): tests-first graphqlgen --watch loop contract 2026-10-12 16:00:47 +13:00
Tim Smart 1b83c606d2 fix(graphql-generator): skip protected glob roots in both walks 2026-10-12 16:00:47 +13:00
Tim Smart e1e7a0fe45 test(graphql-generator): documents roots inside node_modules or dot-directories match nothing 2026-10-12 16:00:47 +13:00
Tim Smart 33bb58d04b test(graphql-generator): cover config failures and deletion safety 2026-10-12 16:00:47 +13:00
Tim Smart 696ebe0b90 feat(graphql-generator): graphqlgen CLI with config loading, all-or-nothing writes, stale cleanup and --check 2026-10-12 16:00:47 +13:00
Tim Smart b050786e1b test(graphql-generator): tests-first graphqlgen CLI and documents glob matcher 2026-10-12 16:00:47 +13:00
Tim Smart 05f1917436 fix(graphql-generator): merged-field conditions and abstract member selection
Fixes the stage-5 review findings on 55f4e7ecfd:

- A merged field with several occurrences carries each occurrence's
  @skip/@include condition to the children it adds, since the parent can
  be present because of another occurrence. A field's only occurrence
  still keeps its children required.
- On an interface or union, the fallback member only takes fragments on
  the type itself or on an interface it declares. Every other fragment
  names its object types as their own members: a fragment on the only
  possible type keeps its member, and an interface fragment covering every
  member of a union, or of an interface that doesn't declare its fields,
  no longer resolves those fields against the parent and crashes.
2026-10-12 16:00:47 +13:00
Tim Smart 92bd55b756 test(graphql-generator): stage-5 review regressions for merged conditions and abstract members
Failing regressions for the stage-5 review of 55f4e7ecfd:

- A merged field whose second occurrence is conditional, written directly
  or through a conditional spread, keeps that condition on the children it
  adds. A field whose only occurrence is conditional keeps its children
  required (passes today; guards the fix).
- A fragment on the only possible type of an interface or a union keeps
  its own member, so the selected field decodes and a malformed member
  fails.
- An interface fragment covering every possible type of a union, or of an
  interface that doesn't declare the field, generates and decodes.
2026-10-12 16:00:47 +13:00
Tim Smart 5cfd13bbd1 feat(graphql-generator): unions, interfaces, @skip/@include, @oneOf and subscriptions
Stage 5 (EFF-1917) of the generator:

- Selections on interfaces and unions emit a Schema.Union discriminated by
  __typename: one Literal struct per object type the selection names
  through a fragment that doesn't cover every possible type, and a last
  struct built with GraphQL.otherTypename<Shared.Typename.X>(). Inline
  fragments and spreads on interfaces apply to every implementer they
  cover. __typename is added to the decoded Schema and to every abstract
  selection set in the printed document (not inside inline fragments,
  which share their parent's object).
- The shared module emits each reached abstract type's possible types
  once, as a type in its Typename namespace.
- Fragments on interfaces and unions are a Schema.Union const and a type
  alias.
- @skip/@include with a variable condition make the fields they cover
  optionalKey, through spreads and inline fragments; a conditional spread
  is always written out inline. Literal conditions are folded, and the
  document keeps every directive.
- @oneOf input objects are a Schema.Union of structs, each requiring one
  non-null key with the others optionalKey(Never), so two keys or none
  fail to encode. A class can't extend Opaque over a union (TS2509), so
  they are `export const X = Schema.Opaque<X>()(Schema.Union([...]))` with
  the type written out as `export type X`.
- Subscriptions emit GraphQL.subscription and join the file's group.
- Recursive input objects remain a located error.
- Snapshots regenerated, adding timeline.graphql.ts and the subscriptions
  set.
2026-10-12 16:00:47 +13:00
Tim Smart 875a38be6b test(graphql-generator): tests-first abstract types, @skip/@include, @oneOf and subscriptions
Contract tests for stage 5 (EFF-1917), ahead of the implementation:

- Unions and interfaces (EFF-1831 point 4): __typename added first in the
  document and Schema, one Literal struct per inline fragment plus an
  otherTypename member, the shared Typename namespace, fragments on abstract
  types as Schema.Union aliases, and decode checks through the generated
  modules.
- @skip/@include (EFF-1832 point 11): variable conditions on a field, a
  spread and an inline fragment, folded literal conditions, and a partly
  optional fragment written inline, asserting the Schema text and printed
  document.
- @oneOf inputs (point 12): Opaque over a Union; one key encodes, two keys,
  no key or a null key fail.
- Subscriptions: GraphQL.subscription joins the file's group.
- GitHub set: the prototype's timeline.graphql, ActorFields on the Actor
  interface, GitObjectID mapped in the fixture scalars.
- Hand-written SDL fixture sdl/subscriptions.graphql with a Subscription
  root, a @oneOf input, nested interfaces and an enum, plus its documents.
- Snapshot entries for timeline.graphql.ts and the subscriptions set, and
  runtime tests that import them through a mock GraphQLProtocol.
- Stage-5 "not supported yet" cases now expect no diagnostics; recursive
  input objects stay a located error.

The new snapshot files are not committed. They come from the
implementation run with `-u`, and until then the runtime test can't
import them.
2026-10-12 16:00:47 +13:00
Tim Smart 27a7bd1aab fix(graphql-generator): check group-name collisions against emitted imports
Each merged selection now records the spread in the file being emitted
through which another file's fragment was written out inline, and every
import records the first such spread. A module that exports a group and
imports a fragment of the same name is a located error at that spread,
replacing the syntactic check that missed imports exposed by inlining.
A spread that doesn't lead to the import, such as a non-overlapping
...Outer, is no longer considered.
2026-10-12 16:00:47 +13:00
Tim Smart c54186f108 test(graphql-generator): group-name collision introduced by an inlined spread
A fragment named like the file's group, imported only because an
overlapping spread was written out inline, must be a located error at
that spread in the operation file, with no files emitted.
2026-10-12 16:00:47 +13:00
Tim Smart 8db559c342 fix(graphql-generator): module cycles, group bindings, shared schema names and __proto__ keys
- Report a cycle in the imports between generated files as one located
  error at its first cross-file spread (file order, then position), naming
  the files on the cycle, instead of emitting modules that throw.
- Reject a local or imported fragment that would bind the name of the
  group its file exports.
- Give shared-module types that can't be bound (reserved words, eval,
  arguments) a local alias exported under the GraphQL name, and allocate
  the effect/Schema and scalar module imports around every type name.
- Emit __proto__ struct keys as computed keys so they stay own fields.
2026-10-12 16:00:47 +13:00
Tim Smart a5b36b2f8e test(graphql-generator): regressions for module cycles, group bindings, schema names and __proto__
Failing tests for the four stage-4 review findings, plus two passing
controls:
- a two-file fragment arrangement whose generated imports form a cycle
  must be one located error at the first cross-file spread on the cycle;
- a local or imported fragment named like the file's group is a located
  error, while a fragment-only file may use its own group name;
- an enum named Schema and an input object named default must emit
  modules that load and round-trip;
- a __proto__ alias or variable must be an own struct field.

importGenerated writes generated output under test/.tmp and imports it so
tests can check that modules load.
2026-10-12 16:00:47 +13:00
Tim Smart 5a041880e2 test(graphql-generator): GitHub snapshots, runtime acceptance and stage-5 diagnostics
- Snapshot the GitHub set to test/generated/github/*.graphql.ts with
  toMatchFileSnapshot; pnpm check typechecks the snapshots, and oxlint and
  dprint skip them.
- Build a GraphQLClient from the generated IssuesGroup and run RepoIssues
  and AddComment against a mock HttpClient with GitHub-shaped responses.
- Cover the deferred stage-5 diagnostics, reserved names and introspection
  JSON schemas.
- Correct the RepoIssues document expectation to the token-minimal printer
  output (no commas).
- Narrow the test tsconfig fixture exclude to JSON so documents/scalars.ts
  is in the program.
2026-10-12 16:00:47 +13:00
Tim Smart 3141289c27 feat(graphql-generator): generate core, mapping rules, emitter and shared module
Public Config (defineConfig and the config Schema) and Generator
(generate(config, { cwd })) modules for EFF-1916. generate reads the
schema and the documents globs, validates them, and returns every
.graphql.ts file plus the shared module in memory, with located
diagnostics and one warning listing unmapped custom scalars.

Selections on interfaces and unions, @skip / @include, @oneOf and
recursive input objects, and subscriptions are reported as errors until
stage 5.
2026-10-12 16:00:47 +13:00