Skip to content

Commit f4f0c72

Browse files
committed
Remove 'find' polyfill
1 parent 94f8be7 commit f4f0c72

File tree

6 files changed

+9
-39
lines changed

6 files changed

+9
-39
lines changed

src/execution/values.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import find from '../polyfills/find';
2-
31
import type { ObjMap } from '../jsutils/ObjMap';
42
import keyMap from '../jsutils/keyMap';
53
import inspect from '../jsutils/inspect';
@@ -249,12 +247,10 @@ export function getDirectiveValues(
249247
node: { +directives?: $ReadOnlyArray<DirectiveNode>, ... },
250248
variableValues?: ?ObjMap<mixed>,
251249
): void | { [argument: string]: mixed, ... } {
252-
const directiveNode =
253-
node.directives &&
254-
find(
255-
node.directives,
256-
(directive) => directive.name.value === directiveDef.name,
257-
);
250+
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
251+
const directiveNode = node.directives?.find(
252+
(directive) => directive.name.value === directiveDef.name,
253+
);
258254

259255
if (directiveNode) {
260256
return getArgumentValues(directiveDef, directiveNode, variableValues);

src/polyfills/find.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/type/schema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import find from '../polyfills/find';
21
import arrayFrom from '../polyfills/arrayFrom';
32
import objectValues from '../polyfills/objectValues';
43
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';
@@ -329,7 +328,7 @@ export class GraphQLSchema {
329328
}
330329

331330
getDirective(name: string): ?GraphQLDirective {
332-
return find(this.getDirectives(), (directive) => directive.name === name);
331+
return this.getDirectives().find((directive) => directive.name === name);
333332
}
334333

335334
toConfig(): GraphQLSchemaNormalizedConfig {

src/type/validate.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import find from '../polyfills/find';
21
import objectValues from '../polyfills/objectValues';
32

43
import inspect from '../jsutils/inspect';
@@ -393,7 +392,7 @@ function validateTypeImplementsInterface(
393392
// Assert each interface field arg is implemented.
394393
for (const ifaceArg of ifaceField.args) {
395394
const argName = ifaceArg.name;
396-
const typeArg = find(typeField.args, (arg) => arg.name === argName);
395+
const typeArg = typeField.args.find((arg) => arg.name === argName);
397396

398397
// Assert interface field arg exists on object field.
399398
if (!typeArg) {
@@ -428,7 +427,7 @@ function validateTypeImplementsInterface(
428427
// Assert additional arguments must not be required.
429428
for (const typeArg of typeField.args) {
430429
const argName = typeArg.name;
431-
const ifaceArg = find(ifaceField.args, (arg) => arg.name === argName);
430+
const ifaceArg = ifaceField.args.find((arg) => arg.name === argName);
432431
if (!ifaceArg && isRequiredArgument(typeArg)) {
433432
context.reportError(
434433
`Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`,

src/utilities/TypeInfo.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import find from '../polyfills/find';
2-
31
import type { Visitor } from '../language/visitor';
42
import type { ASTNode, ASTKindToNode, FieldNode } from '../language/ast';
53
import { Kind } from '../language/kinds';
@@ -204,8 +202,7 @@ export class TypeInfo {
204202
let argType: mixed;
205203
const fieldOrDirective = this.getDirective() ?? this.getFieldDef();
206204
if (fieldOrDirective) {
207-
argDef = find(
208-
fieldOrDirective.args,
205+
argDef = fieldOrDirective.args.find(
209206
(arg) => arg.name === node.name.value,
210207
);
211208
if (argDef) {

src/validation/rules/OverlappingFieldsCanBeMergedRule.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import find from '../../polyfills/find';
21
import objectEntries from '../../polyfills/objectEntries';
32

43
import type { ObjMap } from '../../jsutils/ObjMap';
@@ -631,8 +630,7 @@ function sameArguments(
631630
return false;
632631
}
633632
return arguments1.every((argument1) => {
634-
const argument2 = find(
635-
arguments2,
633+
const argument2 = arguments2.find(
636634
(argument) => argument.name.value === argument1.name.value,
637635
);
638636
if (!argument2) {

0 commit comments

Comments
 (0)