concatAST.js.flow 555 B

1234567891011121314151617
  1. // @flow strict
  2. import type { DocumentNode } from '../language/ast';
  3. /**
  4. * Provided a collection of ASTs, presumably each from different files,
  5. * concatenate the ASTs together into batched AST, useful for validating many
  6. * GraphQL source files which together represent one conceptual application.
  7. */
  8. export function concatAST(
  9. documents: $ReadOnlyArray<DocumentNode>,
  10. ): DocumentNode {
  11. let definitions = [];
  12. for (const doc of documents) {
  13. definitions = definitions.concat(doc.definitions);
  14. }
  15. return { kind: 'Document', definitions };
  16. }