-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding Locale to Coercing and hence ValueResolver #2912
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
Changes from all commits
f56f937
5919da0
dffefc4
c97b558
5386876
62ccc28
68b6c2e
39fcdab
6ccfa79
655faad
d6bfb9c
89c8574
da0bd0e
2d74845
68d1070
9d42a8d
c615df1
f59454d
f003665
6e23f9b
4408cc8
f207309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package graphql.analysis; | ||
|
|
||
| import graphql.GraphQLContext; | ||
| import graphql.PublicApi; | ||
| import graphql.execution.CoercedVariables; | ||
| import graphql.execution.RawVariables; | ||
|
|
@@ -20,6 +21,7 @@ | |
| import java.util.Collections; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
|
|
||
| import static graphql.Assert.assertNotNull; | ||
|
|
@@ -70,7 +72,7 @@ private QueryTraverser(GraphQLSchema schema, | |
| this.fragmentsByName = getOperationResult.fragmentsByName; | ||
| this.roots = singletonList(getOperationResult.operationDefinition); | ||
| this.rootParentType = getRootTypeFromOperation(getOperationResult.operationDefinition); | ||
| this.coercedVariables = ValuesResolver.coerceVariableValues(schema, variableDefinitions, rawVariables); | ||
| this.coercedVariables = ValuesResolver.coerceVariableValues(schema, variableDefinitions, rawVariables, GraphQLContext.getDefault(), Locale.getDefault()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entry point come not from a graphql request and hence uses a default graphql context and default locale. Perhaps in some future change these are passed in. |
||
| } | ||
|
|
||
| private QueryTraverser(GraphQLSchema schema, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| package graphql.execution; | ||
|
|
||
| import graphql.Assert; | ||
| import graphql.GraphQLContext; | ||
| import graphql.Internal; | ||
| import graphql.language.Directive; | ||
| import graphql.language.NodeUtil; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
|
|
||
| import static graphql.Directives.IncludeDirective; | ||
|
|
@@ -30,7 +32,7 @@ public boolean shouldInclude(Map<String, Object> variables, List<Directive> dire | |
| private boolean getDirectiveResult(Map<String, Object> variables, List<Directive> directives, String directiveName, boolean defaultValue) { | ||
| Directive foundDirective = NodeUtil.findNodeByName(directives, directiveName); | ||
| if (foundDirective != null) { | ||
| Map<String, Object> argumentValues = ValuesResolver.getArgumentValues(SkipDirective.getArguments(), foundDirective.getArguments(), CoercedVariables.of(variables)); | ||
| Map<String, Object> argumentValues = ValuesResolver.getArgumentValues(SkipDirective.getArguments(), foundDirective.getArguments(), CoercedVariables.of(variables), GraphQLContext.getDefault(), Locale.getDefault()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entry point come not from a graphql request and hence uses a default graphql context and default locale. Perhaps in some future change these are passed in. |
||
| Object flag = argumentValues.get("if"); | ||
| Assert.assertTrue(flag instanceof Boolean, () -> String.format("The '%s' directive MUST have a value for the 'if' argument", directiveName)); | ||
| return (Boolean) flag; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ public CompletableFuture<ExecutionResult> execute(Document document, GraphQLSche | |
|
|
||
| CoercedVariables coercedVariables; | ||
| try { | ||
| coercedVariables = ValuesResolver.coerceVariableValues(graphQLSchema, variableDefinitions, inputVariables); | ||
| coercedVariables = ValuesResolver.coerceVariableValues(graphQLSchema, variableDefinitions, inputVariables, executionInput.getGraphQLContext(), executionInput.getLocale()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. context and locale take from ExecutionInput |
||
| } catch (RuntimeException rte) { | ||
| if (rte instanceof GraphQLError) { | ||
| return completedFuture(new ExecutionResultImpl((GraphQLError) rte)); | ||
|
|
||
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 entry point come not from a graphql request and hence uses a default graphql context and default locale. Perhaps in some future change these are passed in.