Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findBreakingChanges: extract 'findByName' utility function #1901

Merged
merged 1 commit into from May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}