Skip to content

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

@IvanGoncharov

Description

@IvanGoncharov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions