Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .claude/skills/verify-tools/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
name: verify-tools
description: Prove a graphql-java-tools behavior the way a consuming app sees it. Installs this checkout into a private Maven repo, builds a schema from SDL files and resolver classes in a separate probe project through the public API, runs GraphQL operations, and saves the printed schema, JSON results and library warnings as evidence. Use to confirm a fix or feature works from the outside (not just in the library's own unit tests), or to reproduce an issue report. Run it before pushing any schema-building change to an open PR, including refactors and new or changed library warnings, whose only proof is the probe's log.
---

# Verify graphql-java-tools from a consumer

`probe/` is a separate Maven project that depends on the jar installed from a checkout, so it sees only the public API,
unlike `src/test`. `mvn verify` still runs for every change. This skill proves one behavior end to end in minutes, and is
where bugfixes and small features stop.

## Run

`probe.sh` sits next to this file and verifies the checkout of the current directory. Every clone and worktree has its
own copy, so run it from the checkout root. To verify a commit that predates this skill, check it out in its own worktree
and run another checkout's `probe.sh` from inside it.

```bash
.claude/skills/verify-tools/probe.sh doctor # checkout, branch, install state, lock
.claude/skills/verify-tools/probe.sh list # scenario names
.claude/skills/verify-tools/probe.sh install # clean-build the checkout into the private repo
.claude/skills/verify-tools/probe.sh run <scenario> [--graphql-java <ver>] # build the schema, run every operation
.claude/skills/verify-tools/probe.sh clean # remove this checkout's work dir, keep evidence
```

- `run` first installs the checkout into a private Maven repo under `$TMPDIR/verify-tools/work/<checkout>-<path hash>/` when
the install is missing or stale, meaning HEAD or uncommitted `pom.xml`/`src/` changes differ from the last install. It
reads `~/.m2` but never writes it. The install runs `mvn clean install`, so it empties the checkout's `target/`. Don't
run it while another build uses the same checkout. The work dir is keyed on the checkout's path, so clones and worktrees
run in parallel, even when two share a folder name. If `doctor` shows the lock held by a live pid, wait for that run.
- It builds the schema from the scenario's `parser()`, prints it, then executes every `*.graphql` in
`probe/src/main/resources/scenarios/<name>/` in name order, with `<op>.variables.json` as variables. It collects
subscription events until the stream completes, for at most 10 seconds.
- Exit `0`: the schema built and every operation ran, though operations can still return GraphQL errors. `2`: the build
threw. `1`: harness failure (install log or `maven.log`) or a held lock. `64`: bad usage, such as a missing or unknown
scenario.
- `--graphql-java` swaps only the runtime graphql-java, like a user who pins another version. It doesn't recompile the
library against it. `--skip-install` runs a stale install on purpose and doesn't count as proof.

## Evidence

`run` prints its evidence directory, `$TMPDIR/verify-tools/evidence/<timestamp>-<scenario>[-gj<version>][-<n>]/`, on its last
line.

| File | Holds |
|---|---|
| `summary.txt` | Jars actually loaded, Java version, unused definitions, build result, errors per operation |
| `run.txt` | Checkout, commit, source fingerprint and install stamp, command, exit code |
| `schema.graphqls` | The executable schema as graphql-java prints it, generated types included |
| `<op>.json` | The spec-shaped result, `events` for a subscription, or `threw` when `execute` threw |
| `probe.log` | WARN and above, plus INFO from `graphql.kickstart.tools`, where the library's build warnings land |
| `inspect.txt` | What the scenario's `inspect(schema)` returned |
| `build-error.txt` | Stack trace when the build threw |

Proof standards:

- `summary.txt`'s `graphql-java-tools jar` is inside the work dir, and `run.txt`'s fingerprint equals its install stamp.
Otherwise you tested another build.
- Quote the operation and the relevant part of `<op>.json`. Cite `schema.graphqls` for schema shape, `probe.log` for
warnings, and `build-error.txt` with exit `2` for build failures.
- For a regression, a new warning or a clearer error, run the same scenario on the fix and on `master` (or the commit
before the fix), in two worktrees, and show both. They differ in exactly the way the issue describes.
- Report a sub-feature you didn't run as skipped, with the reason. Another scenario doesn't cover it.
- An expected value in `features/` that stops matching is a finding to report, not something to edit away.

## Adding a scenario

1. Write the SDL as `probe/src/main/resources/scenarios/<name>/schema.graphqls` and load it with `.file(...)`, unless the
behavior is about `schemaString`.
2. Add `object <Name> : Scenario` with `name` and `parser()` in `probe/src/main/kotlin/scenarios/<Name>.kt`. Being an
object in that package registers it. Classes share the package, so prefix resolver and data classes with the scenario.
Use only public API. If the probe needs `internal` or test classes, a user can't reach the behavior either, so report
that.
3. Add operations as `NN-<what>.graphql`, plus `NN-<what>.variables.json` when they take variables. graphql-java rejects
a second `__type` in one operation and still exits `0`, so read several types through `__schema { types { ... } }`.
4. Override what the scenario needs. `operations` reuses another scenario's operation directory. `schema(parser)` takes
another build path such as `toReadOnlySchema()`. `inspect(schema)` returns evidence the printer doesn't show, and
`probe.dumpDirectives(schema)` lists every element's applied and legacy directives. `graphQL(builder)` and
`input(builder)` add instrumentation, context or data loaders.
5. A scenario that doesn't compile breaks every checkout's run, so finish it before running. Keep a scenario that proves
a lasting feature and add its exact expected results to the matching file in `features/`. Delete a one-off
reproduction after reporting.

`features/README.md` maps each feature to its scenarios and expected results. Delete evidence directories by hand once
reported.
45 changes: 45 additions & 0 deletions .claude/skills/verify-tools/features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# graphql-java-tools verification map

Each file below is one user-visible feature, with the scenarios that prove it and their exact expected results. The
commands and proof standards are in `../SKILL.md`. Scenario data is fixed, so expected values are literal.

A feature file has an H1 title and one paragraph on the behavior a user sees, then three H2 sections: `Sub-features` (short
IDs, one line each), `Expected results` (each scenario's `run` command and what its evidence shows), and `Gotchas` (traps
that waste or invalidate a run, and how the result looked before the fix).

## Features

- [Schema building](./schema-building.md): SDL files, root and nested resolvers, property and getter discovery, custom
scalars, the unused-type warning, the missing-resolver error and the read-only schema (`bookstore`,
`bookstore-missing-resolver`, `read-only-schema`).
- [Arguments and input types](./arguments-and-inputs.md): SDL defaults, enums, lists, input objects mapped to classes,
omitted versus null, parameters typed by a type variable, custom scalar arguments, recursive input objects and the WARN
for unmapped input fields (`inputs`, `unmapped-inputs`, `generic-input-resolver`, `scalar-args`, `recursive-inputs`).
- [Async resolvers and subscriptions](./async-and-subscriptions.md): `CompletableFuture`, suspend functions, and
`Publisher` subscriptions (`async`).
- [Generic wrappers](./generic-wrappers.md): wrappers and futures nested in lists and other wrappers, with and without a
`ValueUnboxer`, and in suspend resolvers (`nested-wrappers`, `nested-wrappers-unboxer`, `nested-wrappers-suspend`).
- [DataFetcherResult inside an Optional](./optional-data-fetcher-results.md): data, errors, empty, a list, the same type
returned another way, and the nested-result rejection (`optional-results`, `optional-results-mixed`,
`optional-results-list`, `optional-results-nested`).
- [Interfaces and unions](./interfaces-and-unions.md): runtime type resolution through the dictionary, including a class
whose name differs from the type, and a union that is only a member of another union (`polymorphism`,
`nested-unions`).
- [Directives and relay connections](./directives-and-relay.md): `SchemaDirectiveWiring`, `@deprecated`, `@connection`
type generation, directives and `@specifiedBy` on scalars, wirings on recursive and cross-referencing types, applied
versus legacy directive lists, undeclared directives and invalid applications (`directives`, `scalar-directives`,
`wiring-shapes`, `directive-drift`, `directive-drift-undeclared`, `directives-invalid`).
- [Schema parser options](./schema-options.md): `missingResolverDataFetcherProvider`
(`options`).
- [Type extensions](./type-extensions.md): fields, interfaces, members, values and directives of every kind of extension,
the repeat and kind-mismatch warnings, repeated object and input fields, and sealed subclasses found through
extensions (`type-extensions`, `type-extensions-repeated-fields`, `type-extensions-sealed`).
- [Proxied resolvers](./proxies.md): Spring JDK dynamic and CGLIB proxies, and the warning for fields a JDK proxy can't
call (`jdk-proxy`, `jdk-proxy-cglib`, `jdk-proxy-plain`).
- [Context and environment parameters](./context-and-environment.md): `contextClass`, `GraphQLContext` and
`DataFetchingEnvironment` after the schema arguments, in any order, the misbound-argument warning, and resolver methods
without the source parameter (`context-and-environment`, `context-and-environment-invalid`, `context-misbound`,
`sourceless`, `sourceless-shadowed`, `sourceless-unimplemented`, `sourceless-misbound`).

Not mapped yet: field visibility, per-field object mappers, the Guice, Javassist and Weld proxy handlers,
`includeUnusedTypes`, and comment descriptions. Add a scenario and a feature entry when a change touches one of them.
95 changes: 95 additions & 0 deletions .claude/skills/verify-tools/features/arguments-and-inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Arguments and input types

Resolver methods take GraphQL arguments as ordinary parameters, in SDL order. graphql-java-tools converts scalars, enums,
lists and input objects into the parameter's declared class, applies SDL default values, and passes
`DataFetchingEnvironment` when it is the last parameter. An input object can refer to itself, or to another input object
that refers back. With `inputArgumentOptionalDetectOmission`, an `Optional` parameter tells an omitted argument (`null`)
from an explicit `null` (`Optional.empty()`).

## Sub-features

- `args-defaults` applies an argument's SDL default when the operation omits it.
- `args-enum-list` converts `[Genre!]` literals into a `List<Genre>` of a Kotlin enum.
- `args-env` passes `DataFetchingEnvironment` as the trailing parameter.
- `args-input-object` maps a nested input object into data classes, including input field defaults.
- `args-optional-omission` passes `null` for an omitted argument, `Optional.empty()` for an explicit null, and
`Optional.of` for a value.
- `args-invalid-enum` rejects an unknown enum literal during validation, before any resolver runs.
- `args-unmapped-warn` logs a WARN at build for an input field the argument's class has no property for, here a
misspelled property under an `Optional`.
- `args-unmapped-ignored` doesn't report a field the property's `@JsonIgnoreProperties` ignores, here on an `Optional`
property.
- `args-type-variable` converts an argument whose parameter is typed by the resolver superclass's type variable into the
class the subclass binds it to.
- `args-scalars` passes a custom scalar's coerced object through unconverted, also when it's a Kotlin class without visible
properties inside an input object, converts `ID` into a `Long` parameter, and converts `[[String]]` into a
`List<Set<String>>` parameter.
- `args-recursive` converts an input object that refers to itself, and two that refer to each other, through lists, nested
lists and non-null types into data classes at every depth. It also builds a directive whose arguments are an input
object, an enum with a default and a list.

## Expected results

- **Run.** `run inputs`. Exit `0`. `summary.txt` shows `errors=0` for `01` to
`03` and `errors=1` for `04-invalid-enum`.
- **Defaults, enums, env.** `01-search.json` has
`data.defaults = "term=dune limit=10 genres=null field=search"` and
`data.explicit = "term=dune limit=2 genres=[SCIENCE, HISTORY] field=search"`.
- **Omitted vs null.** `02-nickname.json` has `omitted = "omitted"`, `explicitNull = "explicit null"` and
`given = "value Bilbo"`.
- **Input objects.** `03-add-book.json` (variables in `03-add-book.variables.json`) has `data.addBook` equal to
`{"title": "Cosmos", "genre": "SCIENCE", "tags": ["space", "classic"], "pages": 396, "language": "en"}`. `language`
comes from the input field default. `data.defaults` is `{"genre": "FICTION", "tags": [], "pages": null}`.
- **Invalid enum.** `04-invalid-enum.json` has no `data`, and one error whose message starts with
`Validation error (WrongType@[search])` and names `POETRY`.
- **Unmapped input fields.** `run unmapped-inputs`. Exit `0`. `probe.log` has
exactly one `UnmappedInputFieldChecker` WARN, starting `Input field 'ItemInput.name' has no matching property in
scenarios.ItemInput` and listing `Known properties: nmae`. There is no WARN for `InnerInput.legacy`.
`01-ignored.json` has `data.ignored = "a"`. `02-typo.json` has one error containing
`Unrecognized property "name" (class scenarios.ItemInput)` (`Unrecognized field` before Jackson 3, in 14.x), which shows
the reported field really fails.
- **Type variable parameters.** `run generic-input-resolver`. Exit `0`.
`summary.txt` shows `errors=0` for both operations. `02-generic.json` has
`data.generic = "generic got GreetingInput(name=a)"`, and `01-plain.json` has
`data.plain = "plain got GreetingInput(name=a)"`.
- **Scalar arguments.** `run scalar-args`. Exit `0`. `summary.txt` shows
`errors=0` for the first five operations. `01-custom-scalar.json` has `data.tag = "tag kotlin"` and
`data.tags = "tags [a, b]"` (`Tag` has no constructor Jackson can use, so this only works when the value is passed
through). `02-id.json` has `data.id = "id 43 (long)"`. `03-nested-sets.json` has
`data.nestedSets = "sets [[a, b], [c]] sizes [2, 1]"`. `04-nested-lists.json` has
`data.nestedLists = "lists [[a, a, b], [c]]"`. `05-empty-kotlin-scalar.json` has `data.tokenInput = "token input"`.
`06-marked-empty-kotlin-scalars.json` has one error and `07-optional-marked-empty-kotlin-scalars.json` two, all containing
`missing type id property '@class'` or `Cannot deserialize value of type`. Those scalars fail rather than reach the resolver
as a default instance.
- **Recursive inputs.** `run recursive-inputs`. Exit `0`, `errors=0` for both operations and an empty `probe.log`.
`01-describe.json` (variables in `01-describe.variables.json`) has `data.names = ["a", "b"]`. `data.describe` starts
`TreeFilter(name=root, and=[TreeFilter(name=a,` and ends `siblings=[[ChildFilter(parent=null, siblings=null, depth=4)],
[]], depth=3))`. `data.literal` is `TreeFilter(name=x, and=null, not=null, child=ChildFilter(parent=null,
siblings=[[ChildFilter(parent=null, siblings=null, depth=2)]], depth=1))`. `schema.graphqls` has `siblings:
[[ChildFilter!]!]` and `directive @limit(labels: [String!], range: RangeInput!, unit: LimitUnit = ITEMS) on
FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION`. In `02-introspect.json`, `limit` has `range` of
`RangeInput!`, `unit` of `LimitUnit` with default `ITEMS`, and `labels` of `[String!]`.

## Gotchas

- Arguments bind by position, not name. A resolver whose parameters are in a different order than the SDL still builds
when the types line up, and returns swapped values.
- Without `inputArgumentOptionalDetectOmission`, an omitted argument and an explicit null both arrive as
`Optional.empty()`. This scenario turns the option on. Prove the default behavior in a separate scenario.
- `04-invalid-enum` fails in graphql-java validation. It proves the generated enum type, not the resolver's conversion.
- The unmapped input field check comes from PR #857. On a checkout without it, `unmapped-inputs` still exits `0` with the
same JSON, but `probe.log` has no `UnmappedInputFieldChecker` lines.
- `02-typo` errors because the scenario uses the default `ObjectMapper`, which fails on unknown properties. It doesn't
cover a mapper that ignores them.
- The type variable fix comes from PR #882. On a checkout without it, `generic-input-resolver` still builds and exits
`0`, but `02-generic.json` has `data: null` and an error containing `TypeVariableImpl cannot be cast to class
java.lang.Class`.
- The nested list fix comes from PR #891. On a checkout without it, `scalar-args` still exits `0`, but
`03-nested-sets.json` has an error containing `ArrayList cannot be cast to class java.util.Set`.
- The fix for a Kotlin scalar class without visible properties comes from issue #926. On a checkout without it,
`05-empty-kotlin-scalar.json` has `data.tokenInput = "token default"`, since Jackson wrote the value as `{}` and read it
back as a new instance. The same scalar written with a type id or an object id comes from issue #932. On a checkout
without it, `07-optional-marked-empty-kotlin-scalars.json` has no errors and `"typed default"` and `"id default"`. The probe doesn't cover an `ObjectNode` parameter, which needs Jackson 3 on the probe's compile
path. `CustomScalarInputTest` does.
- `recursive-inputs` registers no directive wiring. `wiring-shapes` in `directives-and-relay.md` covers wirings on a
recursive input.
35 changes: 35 additions & 0 deletions .claude/skills/verify-tools/features/async-and-subscriptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Async resolvers and subscriptions

Resolvers can return a `CompletableFuture`, be Kotlin `suspend` functions (root resolvers and `GraphQLResolver<T>` field
resolvers alike), or, for subscription fields, return a reactive-streams `Publisher`. The schema declares the plain
result type (`String!`, `Int!`), and graphql-java-tools unwraps the async wrapper.

## Sub-features

- `async-future` resolves a field from a `CompletableFuture<String>`.
- `async-suspend-root` resolves a root field from a `suspend fun` that suspends (`delay`).
- `async-suspend-nested` resolves a list of objects from a `suspend fun`, and a field on each through a suspend
`GraphQLResolver<Shipment>` method.
- `async-subscription` streams a `Publisher<Int>` from a `GraphQLSubscriptionResolver`, one event per element, then
completes.

## Expected results

- **Run.** `run async`. Exit `0`. `summary.txt` has
`operation 01-query: errors=0` and `operation 02-subscription: errors=0 events=3`.
- **Futures and suspend.** `01-query.json` has `data.future = "from a future"`,
`data.suspended = "from a suspend function"`, and
`data.shipments = [{"id": "s1", "status": "s1: delivered"}, {"id": "s2", "status": "s2: delivered"}]`.
- **Subscription.** `02-subscription.json` is
`{"events": [{"data": {"ticks": 1}}, {"data": {"ticks": 2}}, {"data": {"ticks": 3}}]}`, with no `errors` key and no
`publisherError` entry.

## Gotchas

- Collection stops at stream completion or after 10 seconds. A publisher that never completes prints `subscription did
not complete within 10 seconds` and records only the events seen so far, which is a finding, not a pass.
- An error from the publisher shows up as a `{"publisherError": ...}` event, not under `errors`.
- `--graphql-java` changes only the runtime graphql-java. The library jar is still the one compiled against the version
in `pom.xml`.
- The suspend timing isn't asserted. To prove a dispatcher or `coroutineContextProvider` change, add a field that
reports `Thread.currentThread().name` or the coroutine context to a new scenario.
Loading
Loading