Skip to content

Commit

Permalink
Remove polyfill for 'flatMap' (graphql#2777)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Aug 31, 2020
1 parent e5a2b77 commit fbe8402
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
26 changes: 0 additions & 26 deletions src/polyfills/flatMap.js

This file was deleted.

9 changes: 6 additions & 3 deletions src/type/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import find from '../polyfills/find';
import flatMap from '../polyfills/flatMap';
import objectValues from '../polyfills/objectValues';

import inspect from '../jsutils/inspect';
Expand Down Expand Up @@ -599,8 +598,12 @@ function getAllSubNodes<T: ASTNode, K: ASTNode, L: ASTNode>(
object: SDLDefinedObject<T, K>,
getter: (T | K) => ?(L | $ReadOnlyArray<L>),
): $ReadOnlyArray<L> {
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
return flatMap(getAllNodes(object), (item) => getter(item) ?? []);
let subNodes = [];
for (const node of getAllNodes(object)) {
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
subNodes = subNodes.concat(getter(node) ?? []);
}
return subNodes;
}

function getAllImplementsInterfaceNodes(
Expand Down
15 changes: 8 additions & 7 deletions src/utilities/concatAST.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import flatMap from '../polyfills/flatMap';

import type { DocumentNode } from '../language/ast';

/**
* Provided a collection of ASTs, presumably each from different files,
* concatenate the ASTs together into batched AST, useful for validating many
* GraphQL source files which together represent one conceptual application.
*/
export function concatAST(asts: $ReadOnlyArray<DocumentNode>): DocumentNode {
return {
kind: 'Document',
definitions: flatMap(asts, (ast) => ast.definitions),
};
export function concatAST(
documents: $ReadOnlyArray<DocumentNode>,
): DocumentNode {
let definitions = [];
for (const doc of documents) {
definitions = definitions.concat(doc.definitions);
}
return { kind: 'Document', definitions };
}

0 comments on commit fbe8402

Please sign in to comment.