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
I18n for validation error messages #2878
Conversation
@@ -66,95 +66,6 @@ mutation dogOperation { | |||
id | |||
} | |||
} | |||
""" |
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.
Moved to the Lone Anonymous test file - it's hard to find tests via spec number
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.
I don't like the naming. It should always be a descriptive name.
@@ -1,133 +0,0 @@ | |||
package graphql.validation |
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.
Moved into rule test, it's hard to find tests via spec number
@@ -1,26 +0,0 @@ | |||
package graphql.validation |
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.
Moved into rule test, it's hard to find tests via spec number
@@ -21,52 +21,4 @@ query madDog(\$dogCommand: DogCommand){ | |||
validationErrors.size() == 1 | |||
validationErrors.get(0).getValidationErrorType() == ValidationErrorType.VariableTypeMismatch | |||
} | |||
|
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.
Moved into rule test, it's hard to find tests via spec number
@@ -1,47 +0,0 @@ | |||
package graphql.validation.rules |
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.
Renamed to ScalarLeavesTest
, diff makes it look like a deletion
@@ -196,7 +196,7 @@ class CoercingTest extends Specification { | |||
def er = customScalarSchema.execute(ei) | |||
then: | |||
er.errors.size() == 1 | |||
er.errors[0].message.contains("parseLiteral message") |
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.
Coercing error messages remain the same as before, not i18n-ised.
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.
This looks great - it was less invasive than I thought - albeit still wide reaching
* | ||
* @return a result object that indicates how this operation went | ||
*/ | ||
public static List<ValidationError> validate(GraphQLSchema graphQLSchema, Document parsedDocument) { |
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.
This is a breaking change. Leave the old and use Locale.getDefault() in it and delegate to the old method
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.
That's right, I'll change this
* | ||
* @return a result object that indicates how this operation went | ||
*/ | ||
public static List<ValidationError> validate(GraphQLSchema graphQLSchema, Document parsedDocument, Predicate<Class<?>> rulePredicate) { | ||
public static List<ValidationError> validate(GraphQLSchema graphQLSchema, Document parsedDocument, Predicate<Class<?>> rulePredicate, Locale locale) { |
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.
Same breaking change- leave the old, use Locale.getDefault() and win
return msgArguments.toArray(); | ||
} | ||
|
||
public I18nMsg argumentAt(int index, Object argument) { |
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.
I probably named this method but on reflectionaddArgumentAt
is a better name
then: | ||
executionInput.query == "{ q }" | ||
executionInput.cacheControl != null | ||
executionInput.locale == null | ||
executionInput.locale == Locale.ENGLISH | ||
executionInput.dataLoaderRegistry != null | ||
executionInput.variables == [:] | ||
} |
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.
Add a test to show it now defaults when build but not set
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.
Nice
Defaulting the locale is a small regression for anyone that did not assume this behavior. Maybe this should be noted in the release notes? See https://github.com/vert-x3/vertx-web/pull/2244/files#r931731703 |
Hi @yeikel thanks for letting me know. I'll amend the release notes |
Adding i18n messages for validation errors. We are starting with validation errors, as they occur most frequently.
This PR follows on from @bbakerman's i18n PR #1473, I have copied the core i18n ideas into this PR, brought it up to date and expanded tests.
Coming up in the next PR - German and Portuguese translations