concatAST.js.flow 525 B

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