Repository navigation
fix(handler-graphql): honour multiple: true on resolver dependencies - #5698
Merged
Merged
Conversation
`addResolver` accepts the `[abstraction, { multiple: true }]` dependency tuple
that the container uses everywhere else. It destructured the tuple, threw the
options away, and single-resolved anyway. So a resolver asking for every
implementation of an abstraction got one object instead of an array and died on
`.map`.
The failure gives no hint where it came from: the message is whatever the
resolver did with the object, `e.map is not a function`, attributed to the
GraphQL field rather than to the builder.
Reverting the one-line fix fails the new regression test with exactly that
error.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #5693 so it can be reviewed on its own — it is a fix to shared infrastructure, not part of that feature.
The bug
addResolveraccepts the[abstraction, { multiple: true }]dependency tuple that the container uses everywhere else:It destructured the tuple, threw the options away, and single-resolved anyway. So the resolver above receives one object rather than an array, and dies on
.map.Why it is worth its own PR
The failure gives no hint where it came from. The GraphQL error is whatever the resolver did with the object — in our case
e.map is not a function— attributed to the field, not to the builder. Anyone who tries the documented tuple form loses an afternoon to it.Testing
Three tests in
packages/handler-graphql/__tests__/GraphQLSchemaBuilder.test.ts: single resolution still works, multiple resolves every implementation, and an unregistered multiple dependency yields[]rather thanundefined.Reverting the one-line fix fails two of them with
greeters.map is not a function, which is the production symptom exactly.53 tests in
handler-graphql,adioand lint clean.Note for whoever merges
Independent of #5693. That PR originally needed this fix, but its
listCapabilitiesresolver now goes through a use case and takes the multiple dependency viacreateImplementation, where it has always worked. The two can merge in either order.Worth fixing regardless: the tuple form is what the
Dependencytype advertises, and the next person to use it in a resolver hits the same silent breakage.