You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7199aa2
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/skills/verify-return-value-unwrapping/SKILL.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: verify-return-value-unwrapping
3
-
description: Exhaustively check, up to a bound, that the value of a resolver method, a field with no matching getter or a typed Map reaches graphql-java fully unwrapped. Futures are awaited, generic wrappers are transformed, Optional and DataFetcherResult are handled, and list order, nulls and failures are kept, for every return type nested up to 3 containers deep. Use it before pushing any change to TypeShape (the type walk, ContainerKind, the generic wrapper rules or the Unwrapper), the data fetchers in MethodFieldResolver, PropertyFieldResolver or MapFieldResolver, or the GenericWrapper defaults, and whenever a bug report says graphql-java got a CompletableFuture, Optional or wrapper object as a field value.
3
+
description: Exhaustively check, up to a bound, that the value of a resolver method, a field with no matching getter or a typed Map reaches graphql-java fully unwrapped. Futures are awaited, generic wrappers are transformed, Optional and DataFetcherResult are handled, and list order, nulls and failures are kept, for every return type nested up to 3 containers deep. Use it before pushing any change to TypeShape (the type walk, ContainerKind, the generic wrapper rules or the Unwrapper), the data fetchers in ResolverPlan, or the GenericWrapper defaults, and whenever a bug report says graphql-java got a CompletableFuture, Optional or wrapper object as a field value.
4
4
---
5
5
6
6
# Verify return value unwrapping
@@ -38,11 +38,13 @@ and an all-non-null GraphQL type.
38
38
39
39
Each return type runs as three kinds of resolver, each compiled as a Java class at runtime:
40
40
41
-
| Kind | Generated resolver |Data fetcher |
41
+
| Kind | Generated resolver |Member and data fetcher in `ResolverPlan.kt`|
42
42
|---|---|---|
43
-
|`method`|`public <type> field()` on the query resolver |`MethodFieldResolver`|
44
-
|`property`|`public <type> field;` on the query resolver, which is also what a Kotlin `@JvmField` compiles to |`PropertyFieldResolver`|
45
-
|`map`|`extends HashMap<String, <type>>`, bound to `type Holder` and returned by `Query.holder`|`MapFieldResolver`|
43
+
|`method`|`public <type> field()` on the query resolver |`MethodMember`, `LightMethodFieldResolverDataFetcher`|
44
+
|`property`|`public <type> field;` on the query resolver, which is also what a Kotlin `@JvmField` compiles to |`PropertyMember`, `PropertyFieldResolverDataFetcher`|
45
+
|`map`|`extends HashMap<String, <type>>`, bound to `type Holder` and returned by `Query.holder`|`MapMember`, `MapFieldResolverDataFetcher`|
46
+
47
+
Each kind's `resolverKind` is the noun of a `ResolverKind`, and a `ResolverKind` without a kind here ends in `MODEL ERROR`.
46
48
47
49
The check builds each schema through the public `SchemaParser` API, which rejects about a fifth of the combinations, such as
48
50
`Optional` below the top level. For every accepted one it executes the query once for each value that makes at most
@@ -73,7 +75,7 @@ as `-Dunwrapping.args`, and prints the report. On a failure it also prints the p
73
75
|---|---|
74
76
| 0 |`PASS`, or `PASS apart from the known findings above`|
75
77
| 1 |`FAIL`: a return type that isn't a known finding breaks the property. `NEW`: a known finding matches more accepted return types than its line records |
76
-
| 2 |`MODEL ERROR`: the checkout or the check didn't compile, the build rejected a return type the check must exercise, or a `ContainerKind` in `TypeShape.kt` has no `Container` in `Check.java`, so a pass would prove nothing |
78
+
| 2 |`MODEL ERROR`: the checkout or the check didn't compile, the build rejected a return type the check must exercise, a `ContainerKind` in `TypeShape.kt` has no `Container` in `Check.java`, or a `ResolverKind` in `ResolverPlan.kt` has no `Kind`, so a pass would prove nothing |
77
79
| 3 |`STALE`: a known finding matches a return type that no longer fails, or fewer accepted return types than its line records. Or the run's coverage differs from `pinnedCoverage` in `Check.java`|
78
80
79
81
Options: `--depth N`, `--budget N`, `--property-budget N`, `--show N` (counterexamples and stale return types printed, default 15), and `--rejected`, which lists
@@ -154,7 +156,7 @@ or delete it when none fail, so that a regression shows up as `FAIL`.
154
156
## What this does not cover
155
157
156
158
- Suspend functions, subscriptions and `Publisher`, arrays, and Kotlin-declared resolver methods. The generated resolvers
157
-
are Java methods without parameters, so only `LightMethodFieldResolverDataFetcher` runs, not
159
+
are Java methods without parameters, so only `LightMethodFieldResolverDataFetcher`in `ResolverPlan.kt`runs, not
158
160
`MethodFieldResolverDataFetcher`.
159
161
- Wrappers picked by a subclass of the value (`Box` and `SpecialBox` in `NestedGenericWrapperTest`), wrappers with a type
160
162
argument index other than 0, custom `schemaWrapper`s other than the list one, transformers that return a `FutureTask`,
@@ -169,24 +171,22 @@ or delete it when none fail, so that a regression shows up as `FAIL`.
169
171
170
172
## Coverage and sync
171
173
172
-
Last confirmed to describe the code at commit `5ce3d1db` (2026-11-05). It covers:
174
+
Last confirmed to describe the code at commit `1b351934` (2026-11-05). It covers:
173
175
174
176
| File | What |
175
177
|---|---|
176
-
|`src/main/kotlin/graphql/kickstart/tools/resolver/TypeShape.kt`|all of it: the walk, `ContainerKind`, `GenericWrappers`, `resolveTypeVariables`, the `Unwrapper` and its steps |
177
-
|`src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt`|`createDataFetcher` (the `TypeShape.Unwrapper`), `returnShape`, `LightMethodFieldResolverDataFetcher`|
178
+
|`src/main/kotlin/graphql/kickstart/tools/resolver/TypeShape.kt`| the walk, `ContainerKind`, `GenericWrappers`, `resolveTypeVariables`, the `Unwrapper` and its steps |
179
+
|`src/main/kotlin/graphql/kickstart/tools/resolver/ResolverPlan.kt`|`dataFetcher` (the `TypeShape.Unwrapper` per member), `returnShape`, `ResolverKind`, the members' `declaredValueType`, and the `ResolverDataFetcher` subclasses|
178
180
|`src/main/kotlin/graphql/kickstart/tools/SchemaParserOptions.kt`|`GenericWrapper` and the default wrappers in `build()`|
179
-
|`src/main/kotlin/graphql/kickstart/tools/resolver/PropertyFieldResolver.kt`| all of it |
180
-
|`src/main/kotlin/graphql/kickstart/tools/resolver/MapFieldResolver.kt`| all of it, for Map subclasses with a typed value |
Move the sync commit forward only after you've read those changes and confirmed that the containers, variants and
189
189
expected values in `Check.java` still describe them. For example, a new default wrapper or a new kind of unwrapping
190
190
step needs a new `Container` with its variants and its plain value in `build`. A new `ContainerKind` ends in
191
-
`MODEL ERROR` until it has one. After an intended change, rerun the check,
191
+
`MODEL ERROR` until it has one, and so does a new `ResolverKind` until `Check.java` has a `Kind` with its noun. After an intended change, rerun the check,
192
192
and break the new code on purpose once in a scratch worktree to see the check fail before you trust its pass.
Copy file name to clipboardExpand all lines: AGENTS.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,8 @@ resolver classes. Published to Maven Central. Kotlin, with a few Java files, tar
7
7
8
8
-`src/main/kotlin/graphql/kickstart/tools`: `SchemaParser` and its builder and options, `MergedDefinitions.kt` (merges each
9
9
SDL type with its extensions into a `MergedType`. Other code, apart from the Relay factory, reads SDL types only through
10
-
it), `SchemaClassScanner` (matches schema types to classes), `resolver/` (field resolvers and data fetchers), `directive/`,
10
+
it), `SchemaClassScanner` (matches schema types to classes), `resolver/` (`ResolverPlan.kt` finds the Java member behind each field and builds its data fetcher, `TypeShape.kt` walks
11
+
declared types and unwraps values, `ArgumentConverter.kt` converts arguments), `directive/`,
11
12
`relay/`, `proxy/` (finds the class behind a Spring, Guice, Weld or Javassist proxied resolver), `util/`
12
13
-`src/test/kotlin`: JUnit tests, one class per feature. A test for an issue goes into the class for its feature.
13
14
`EndToEndTest` and `EndToEndSpecHelper` hold the shared schema and resolvers
@@ -93,13 +94,13 @@ happening. "docs only" means nothing does yet, so the rule depends on you readin
93
94
| Rule | Enforced by |
94
95
|---|---|
95
96
| The value of a resolver method, a field with no matching getter or a typed Map is unwrapped by one rule that the schema build and the data fetcher share |`TypeShape`, whose one walk yields both the class the schema build matches and the layers that `TypeShape.Unwrapper` unwraps in the method, field and Map data fetchers. An untyped Map's values reach graphql-java as they are. A container kind can't be added without its placement rule and its value step, since both are abstract on the enum, and `ReturnValueUnwrappingTest` fails until the bounded check builds values for it |
96
-
| A resolver method's parameter layout, type variables and source are decided once, at schema build | docs only |
97
+
| A resolver method's parameter layout, type variables and source are decided once, at schema build | `ResolverPlan`, which reads the field's member once and hands the scan its type shapes, the data fetcher its parameters and `UnmappedInputFieldChecker` its argument targets. Its member variants are private to `ResolverPlan.kt`, each decides its `ResolverKind`, and none builds a data fetcher. `ResolverPlan.dataFetcher` gives every member a `ResolverDataFetcher`, a sealed class whose constructor takes the `TypeShape.Unwrapper`, so a lambda or a fetcher without one doesn't compile. A new `ResolverKind` doesn't compile until the lookup's `when` handles it, a new `ExtraParameter` doesn't compile without its binder, the fixture tests in `ResolverCompatibilityTest` fail, naming the fixture to add, until they build a sample of each and see its value unwrapped, and `ReturnValueUnwrappingTest` ends in `MODEL ERROR` until the bounded check runs the new kind. `ResolverOwnershipTest` fails on member reflection outside `ResolverPlan.kt` (`java.lang.reflect` calls and signature reads, `MethodHandles`, `kotlin.reflect.full` and `kotlin.reflect.jvm` calls, `KClass` member lookups, a value typed as a `KFunction` or `KProperty`, and commons-lang3's field and method utilities, apart from the type reads in `ScanDictionary.findInputValueTypeInType(String, Class)`), on a member that depends on a data fetcher, on a library data fetcher that isn't a `ResolverDataFetcher` declared in `ResolverPlan.kt`, and on generic-wrapper or `DataFetcherResult` handling outside `TypeShape.kt`. Its exemptions name the exact classes each owning file declares. It doesn't see `Future`, `CompletionStage` or `Optional` checks outside `TypeShape.kt`, `Class.forName` lookups, `Method.getReturnType`, a `KFunction` held as `Any` and called through a cast, reflection a library does for you (graphql-java's `PropertyDataFetcher`, `java.beans.Expression`), a new helper in an owning file that reflects for another file, or a `DataFetcher { }` lambda outside `ResolverPlan.kt`. The fixture tests and the bounded check catch a value these leave wrapped only in the fetchers `ResolverPlan` builds |
97
98
| A change to how resolvers are found, bound or unwrapped keeps what a method, a property and a Map field return |`ResolverCompatibilityTest`, which compares field and Map values with a method's, and the bounded check in `ReturnValueUnwrappingTest`, which compares all three with the plain value. Neither has known findings, so a value that differs on a return type they run fails the build. The bounded check also pins how many return types it generates, and for each kind how many the build rejects and how many executions run, so a change that stops running some fails until the same diff updates `pinnedCoverage`. It doesn't judge whether a newly rejected return type should build |
98
99
| One output has one builder. Don't add a second path that builds the same thing | docs only |
99
100
| Read an SDL type's members merged with its extensions, never from the raw definition |`MergedType` in `MergedDefinitions.kt` and `DefinitionsBoundaryTest`, which fails on a raw member, directive or child-node read, an extension class, an SDL node walk or a `TypeDefinitionRegistry` call outside it. A read by reflection gets past it. `TypeExtensionTest` builds and queries a schema with an extension of every kind, so a build that leaves an extension's fields, interfaces, members, values, input fields or directives out of the built type fails it, however the code read them |
100
101
| Every kind of SDL type starts its graphql-java type from the same recipe |`MergedType.prepare`, `DefinitionsBoundaryTest` and `TypeKindRecipeTest`|
101
102
| Reuse an existing structure before you add a parallel one | docs only |
102
-
| Argument conversion goes through one entry point |docs only|
103
+
| Argument conversion goes through one entry point |`ArgumentConverter`, which `ResolverPlan` builds once per argument. `ResolverOwnershipTest` fails on a TokenBuffer or a Jackson `readValue`, `readValueAs`, `convertValue`, `updateValue`, `treeToValue` or `valueToTree` outside `ArgumentConverter.kt`, and on an `ArgumentConverter` built or called outside `ResolverPlan.kt`. Jackson's per-call retry for scalars it can't convert stays inside `ArgumentConverter`|
103
104
| An input field's Java type comes from the mapping Jackson uses, not from guessed getters | docs only |
104
105
| Every recursive walk over the type graph handles cycles, and a test covers a cycle | docs only |
105
106
| Public signatures stay binary compatible, data class `copy()` and `componentN` included | japicmp with `build/japicmp-kotlin-public.groovy` at `mvn verify`, which allows excludes and other narrowing options only at an X.0.0 version |
0 commit comments