Add path to input validation error#40
Merged
Merged
Conversation
44743cf to
d80bd91
Compare
lopert
approved these changes
Nov 10, 2025
Comment on lines
+60
to
+68
| const valueStack: NestedValue[][] = [[{ value, path: [] }]]; | ||
| const typeStack: (GraphQLNamedType | undefined)[] = []; | ||
| const possibleTypesStack: Set<string>[] = [ | ||
| new Set([schema.getQueryType()!.name]), | ||
| ]; | ||
| const typenameResponseKeyStack: (string | undefined)[] = []; | ||
| const expectedFieldsStack: Map<string, Set<string>>[] = [new Map()]; | ||
|
|
||
| const errors: string[] = []; | ||
| const errors: FixtureInputValidationError[] = []; |
Collaborator
There was a problem hiding this comment.
Thanks for improving these types <3
| errors.push( | ||
| `Cannot validate ${responseKey}: missing field definition`, | ||
| ); | ||
| const currentPath = pathFromAncestors(ancestors); |
Collaborator
There was a problem hiding this comment.
I was really surprised that we couldn't just use the path from the args here.
I added a bit of logging to understand things more, and saw it doesn't contain any of the field names.
For this query visiting field name:
query {
data {
items {
name
}
}
}
Built-in path:
['definitions', 0, 'selectionSet', 'selections', 0, 'selectionSet', 'selections', 0, 'selectionSet', 'selections', 0]
→ AST structure path (technical)
pathFromAncestors(ancestors):
['data', 'items', 'name']
→ GraphQL field path (semantic, useful for error messages)
Contributor
Author
There was a problem hiding this comment.
Yeah, I went through the same thing
Collaborator
|
Could you add a |
saga-dasgupta
approved these changes
Nov 10, 2025
Contributor
saga-dasgupta
left a comment
There was a problem hiding this comment.
Thanks for adding the path, LGTM.
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.
Add path to the fixture input validation error so it is easier to identify where the error is occurring.