Repository navigation
fix: pass object and list arguments of a nested field to the subgraph - #97
Open
mikaelkaron wants to merge 1 commit into
Open
mikaelkaron wants to merge 1 commit into
mikaelkaron wants to merge 1 commit into
Conversation
The arguments of a nested field are collected from the query AST, where
an object or a list literal has no value of its own, so an argument such
as tags(where: { id: { eq: "1" } }) was dropped from the subquery and the
subgraph returned every tag. Collect each literal with
valueFromASTUntyped, which also resolves the variables inside it.
Fixes platformatic#69
Signed-off-by: Mikael Karon <mikael@karon.se>
Assisted-by: Claude Code:claude-opus-5-5
This branch has not been deployed
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.
Fixes #69
The composer reads a nested field's arguments from the query's syntax tree, in collectNodeArgs (lib/utils.js), where it took node.value.value. Object and list values have no .value there, so an argument such as tags(where: { id: { eq: "1" } }) was dropped from the query sent to the subgraph, and every tag came back. Top-level fields were not affected, because graphql-js resolves their arguments before the composer sees them. A whole-object variable (tags(where: $where)) was not affected either.
Each value is now read with graphql's valueFromASTUntyped, which also fills in the variables inside it.
test/nested-args.test.js covers, on a nested field:
an inline object (the case from #69)
a list, an enum and an int (in: [...], orderBy: [{ direction: ASC }], limit: 1)
variables inside an inline object
a whole-object variable
Without the fix the first three fail. With it, npm test passes: lint plus 158 tests.
Assisted-by: Claude Code:claude-opus-5-5