You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
Based on @mjmahone comment #2084 (comment)
Currently
parse
always return empty arrays (and neverundefined
) but AST definitions explicitly supportundefined
.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
onInterfaceTypeDefinitionNode
node) is still compatible with newer versions ofgraphql-js
.It also means it's very easy to manually create nodes, for example creating
FieldNode
you can safely omitarguments
,directives
andselectionSet
properties so minimal field will look like: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 getundefined
instead of an empty array.The text was updated successfully, but these errors were encountered: