-
Notifications
You must be signed in to change notification settings - Fork 2k
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
findDangerousChanges: sort fields inside 'defaultValue' #2151
Conversation
@@ -395,6 +396,9 @@ function findArgChanges( | |||
description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, | |||
}); | |||
} else { | |||
// Since we looking only for client's observable changes we should | |||
// compare default values in the same representation as they are | |||
// represented inside introspection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For input type default values we apparently just compare it's stringified value instead of doing a deep comparison.
@Neitsch It's intentional since we want to detect only changes observable by the client.
So we should compare defaultValues
in the same representation as used by introspection:
graphql-js/src/type/introspection.js
Lines 337 to 345 in 0d2220f
defaultValue: { | |
type: GraphQLString, | |
description: | |
'A GraphQL-formatted string representing the default value for this input value.', | |
resolve(inputVal) { | |
const valueAST = astFromValue(inputVal.defaultValue, inputVal.type); | |
return valueAST ? print(valueAST) : null; | |
}, | |
}, |
It's important because defaultValue
is always specified in "internal" format (same format as returned by parseLiteral
/parseValue
and passed into serialize
) that mean it can be for example instances of Date
class and ===
wouldn't work for them but if you pass both values into serialize
you can compare resulting strings without any problems.
Thanks for the fix. It was really fast! :) |
@mrtnzlml Released in |
Fixes #2150