Skip to content

Commit

Permalink
findBreakingChanges: extract 'findByName' utility function (#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 24, 2019
1 parent d414076 commit c906b7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utilities/findBreakingChanges.js
Expand Up @@ -206,7 +206,7 @@ function findArgChanges(

for (const oldArgDef of oldTypeFields[fieldName].args) {
const newArgs = newTypeFields[fieldName].args;
const newArgDef = find(newArgs, arg => arg.name === oldArgDef.name);
const newArgDef = findByName(newArgs, oldArgDef.name);

// Arg not present
if (!newArgDef) {
Expand Down Expand Up @@ -245,7 +245,7 @@ function findArgChanges(
// Check if arg was added to the field
for (const newArgDef of newTypeFields[fieldName].args) {
const oldArgs = oldTypeFields[fieldName].args;
const oldArgDef = find(oldArgs, arg => arg.name === newArgDef.name);
const oldArgDef = findByName(oldArgs, newArgDef.name);
if (!oldArgDef) {
const argName = newArgDef.name;
if (isRequiredArgument(newArgDef)) {
Expand Down Expand Up @@ -854,3 +854,7 @@ function getArgumentMapForDirective(
): ObjMap<GraphQLArgument> {
return keyMap(directive.args, arg => arg.name);
}

function findByName(array, name) {
return find(array, item => item.name === name);
}

0 comments on commit c906b7c

Please sign in to comment.