concatAST.mjs 488 B

12345678910111213141516171819
  1. import { Kind } from '../language/kinds.mjs';
  2. /**
  3. * Provided a collection of ASTs, presumably each from different files,
  4. * concatenate the ASTs together into batched AST, useful for validating many
  5. * GraphQL source files which together represent one conceptual application.
  6. */
  7. export function concatAST(documents) {
  8. const definitions = [];
  9. for (const doc of documents) {
  10. definitions.push(...doc.definitions);
  11. }
  12. return {
  13. kind: Kind.DOCUMENT,
  14. definitions,
  15. };
  16. }