Closed
Description
Reporting issues with GraphQL.js
Hi there. The function findArgChanges
may generate wrong result if default value of the field is an Array:
const oldSchema = buildSchema(`
type Type1 {
field1(name: [String!] = []): String
}
type Query {
field1: String
}
`);
const newSchema = buildSchema(`
type Type1 {
field1(name: [String!] = []): String
}
type Query {
field1: String
}
`);
findDangerousChanges(oldSchema, newSchema);
Result:
[ { type: 'ARG_DEFAULT_VALUE_CHANGE',
description: 'Type1.field1 arg name has changed defaultValue' } ]
Possible Solution
In graphql-js/src/utilities/findBreakingChanges.js
:
} else if (
oldArgDef.defaultValue !== undefined &&
oldArgDef.defaultValue !== newArgDef.defaultValue
) {
dangerousChanges.push({
type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
description:
`${oldType.name}.${fieldName} arg ` +
`${oldArgDef.name} has changed defaultValue`,
});
}
If the default value is an array, oldArgDef.defaultValue !== newArgDef.defaultValue
is always true.
I also create a PR which can reproduce this bug: #1566.