-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allowing document compiler to handles directives and values down in the field tree #3757
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
8f998e2
32802f2
08c6bb8
3e23fea
641bea4
f4939e3
6563ef9
fe13e10
4760249
883ba63
e09e6b6
4887066
bfe691a
95654b5
053aac4
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package graphql.execution; | ||
|
|
||
| import graphql.PublicApi; | ||
| import graphql.collect.ImmutableKit; | ||
| import graphql.collect.ImmutableMapWithNullValues; | ||
| import graphql.normalized.NormalizedInputValue; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Holds coerced variables, that is their values are now in a normalized {@link graphql.normalized.NormalizedInputValue} form. | ||
| */ | ||
| @PublicApi | ||
| public class NormalizedVariables { | ||
| private final ImmutableMapWithNullValues<String, NormalizedInputValue> normalisedVariables; | ||
|
|
||
| public NormalizedVariables(Map<String, NormalizedInputValue> normalisedVariables) { | ||
| this.normalisedVariables = ImmutableMapWithNullValues.copyOf(normalisedVariables); | ||
| } | ||
|
|
||
| public Map<String, NormalizedInputValue> toMap() { | ||
| return normalisedVariables; | ||
| } | ||
|
|
||
| public boolean containsKey(String key) { | ||
| return normalisedVariables.containsKey(key); | ||
| } | ||
|
|
||
| public Object get(String key) { | ||
| return normalisedVariables.get(key); | ||
| } | ||
|
|
||
| public static NormalizedVariables emptyVariables() { | ||
| return new NormalizedVariables(ImmutableKit.emptyMap()); | ||
| } | ||
|
|
||
| public static NormalizedVariables of(Map<String, NormalizedInputValue> normalisedVariables) { | ||
| return new NormalizedVariables(normalisedVariables); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return normalisedVariables.toString(); | ||
| } | ||
| } | ||
|
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. We have Raw, Coerced and NormalizedVariables now as distinct classes |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ public static CoercedVariables coerceVariableValues(GraphQLSchema schema, | |
| * | ||
| * @return a map of the normalised values | ||
| */ | ||
| public static Map<String, NormalizedInputValue> getNormalizedVariableValues( | ||
| public static NormalizedVariables getNormalizedVariableValues( | ||
| GraphQLSchema schema, | ||
| List<VariableDefinition> variableDefinitions, | ||
| RawVariables rawVariables, | ||
|
|
@@ -131,9 +131,7 @@ public static Map<String, NormalizedInputValue> getNormalizedVariableValues( | |
| } | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
|
|
||
| return NormalizedVariables.of(result); | ||
|
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. distinct class now used |
||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,16 @@ | |
| import graphql.PublicApi; | ||
| import graphql.execution.CoercedVariables; | ||
| import graphql.execution.MergedField; | ||
| import graphql.execution.NormalizedVariables; | ||
| import graphql.language.Field; | ||
| import graphql.normalized.NormalizedInputValue; | ||
| import graphql.schema.GraphQLDirective; | ||
| import graphql.schema.GraphQLSchema; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.function.Supplier; | ||
|
|
||
| /** | ||
| * This gives you access to the immediate directives on a {@link graphql.execution.MergedField}. This does not include directives on parent | ||
|
|
@@ -66,6 +69,16 @@ public interface QueryDirectives { | |
| */ | ||
| Map<Field, List<QueryAppliedDirective>> getImmediateAppliedDirectivesByField(); | ||
|
|
||
| /** | ||
| * This will return a map of {@link QueryAppliedDirective} to a map of their argument values in {@link NormalizedInputValue} form | ||
| * <p> | ||
| * NOTE : This will only be available when {@link graphql.normalized.ExecutableNormalizedOperationFactory} is used | ||
| * to create the {@link QueryAppliedDirective} information | ||
| * | ||
| * @return a map of applied directive to named argument values | ||
| */ | ||
| Map<QueryAppliedDirective, Map<String, NormalizedInputValue>> getNormalizedInputValueByImmediateAppliedDirectives(); | ||
|
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. for a given QueryAppliedDirective - we can get a normalised view of its argument values |
||
|
|
||
| /** | ||
| * This will return a list of the named directives that are immediately on this merged field. | ||
| * | ||
|
|
@@ -108,6 +121,8 @@ interface Builder { | |
|
|
||
| Builder coercedVariables(CoercedVariables coercedVariables); | ||
|
|
||
| Builder normalizedVariables(Supplier<NormalizedVariables> normalizedVariables); | ||
|
|
||
| Builder graphQLContext(GraphQLContext graphQLContext); | ||
|
|
||
| Builder locale(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.
just passing on NormalizedVariables