-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve validation of URLPathTemplate
and JSONSelection
strings passed to @source{Type,Field}
directives
#2926
base: benjamn/fix-@sourceField-validation-on-extend-type
Are you sure you want to change the base?
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
expect(getSelectionOutputShape(ast)).toEqual({ | ||
foo: 'JSON', | ||
barAlias: { | ||
x: 'JSON', | ||
y: 'JSON', | ||
z: 'JSON', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output shape of a JSONSelection
string is a tree of nested JSON dictionaries mirroring the structure of a GraphQL query, including scalar properties as leaf nodes. The ultimate goal is to validate this structure against object fields to ensure all fields in the schema are handled by some JSONSelection
mapping.
These 'JSON'
leaf values could have been any placeholder value, but I wanted to emphasize we can't assume much about the types of leaf fields within JSONSelection
output shapes, except that they must be some JSON value (including possibly null
for nullable fields).
Follow-up to #2910.
This work is not finished because we ultimately want to validate that the variables used by
URLPathTemplate
strings and the output shapes ofJSONSelection
strings match the available field and argument names.This PR adds parsers for the two syntaxes and tests of those parsers, which allows us to validate the strings have the expected syntax, even if we're not validating semantics yet.
As another
TODO
, when we useJSONSelection
forbody
parameters, it's the input shape of the selection that needs to be validated, rather than the output shape, sogetSelectionOutputShape
may not be sufficient.