Skip to content
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

Test all functions (with AST input) that they handle undefined instead of array properites #2203

Open
IvanGoncharov opened this issue Sep 26, 2019 · 0 comments

Comments

@IvanGoncharov
Copy link
Member

Based on @mjmahone comment #2084 (comment)

I know we ran into problems in the past when hand-modeling the AST where, unless you explicitly set directives: [], you'd end up getting an undefined reference, even though the flow type allowed it.

Currently parse always return empty arrays (and never undefined) but AST definitions explicitly support undefined.

This is done to make AST forward-compatible meaning old code that generate/transformate AST and doesn't know about new properties (e.g. interfaces on InterfaceTypeDefinitionNode node) is still compatible with newer versions of graphql-js.

It also means it's very easy to manually create nodes, for example creating FieldNode you can safely omit arguments, directives and selectionSet properties so minimal field will look like:

{
  kind: 'Field', 
  name: { kind: 'Name', value: 'foo' },
}

At the same time we need to be sure that functions like buildSchema, extendSchema, print, execute, etc. are actually ready to handle such functions and don't crash when they get undefined instead of an empty array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant