graphqlgraphql-schema

Split union declaration in GraphQL schema over multiple lines


I have a GraphQL-schema that has a union declaration that already has a lot of types, e.g.:

union SectionUnion = SectionForm | Section2 | Section3 | Section4 | Section5

I know that lots more sections are coming (not added yet) and at some point the union declaration will become unreadable, as it would be a very long line.

Is there a way to put the types in multiple lines, one type per line?


Solution

  • White space (spaces and tabs), line terminators and commas are all ignored characters in GraphQL. So this definition is equally valid and equivalent:

    union 
     SectionUnion    = 
    SectionForm |
        Section2
    | Section3
    
    ,
      | Section4   | ,,,  Section5