-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle repeated query directives #3270
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
Handle repeated query directives #3270
Conversation
directives.forEach(directive -> { | ||
GraphQLDirective protoType = schema.getDirective(directive.getName()); | ||
if (protoType != null) { | ||
GraphQLDirective newDirective = protoType.transform(builder -> buildArguments(builder, codeRegistry, protoType, directive, variables, graphQLContext, locale)); | ||
directiveMap.put(newDirective.getName(), newDirective); |
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.
Previously this would just replace the last directive instance. Now it accumulates the values for repeated directives.
@@ -25,14 +26,14 @@ public class DirectivesResolver { | |||
public DirectivesResolver() { | |||
} | |||
|
|||
public Map<String, GraphQLDirective> resolveDirectives(List<Directive> directives, GraphQLSchema schema, Map<String, Object> variables, GraphQLContext graphQLContext, 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.
I wonder if we should just return a List<GraphQLDirecitve>
since we don't even use the map result. It's immediately discarded as we call Map.values()
@@ -265,7 +265,7 @@ public static <T> CompletableFuture<List<T>> flatList(CompletableFuture<List<Lis | |||
return cf.thenApply(FpKit::flatList); | |||
} | |||
|
|||
public static <T> List<T> flatList(List<List<T>> listLists) { | |||
public static <T> List<T> flatList(Collection<List<T>> listLists) { |
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.
Needed as Map.values()
returns a Collection
(Maps aren't ordered).
then: | ||
appliedDirectivesByName.keySet() == ["rep"] as Set | ||
appliedDirectivesByName["rep"].size() == 2 | ||
// Groovy is a pathway to many abilities some consider to be unnatural |
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.
Groovy is a pathway to many abilities some consider to be unnatural
Lol
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.
My favourite is groovy will ignore all 'private' modifier. I am not selfish. I can even share other's private with you.
then: | ||
appliedDirectivesByName.keySet() == ["rep"] as Set | ||
appliedDirectivesByName["rep"].size() == 2 | ||
// Groovy is a pathway to many abilities some consider to be unnatural |
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.
Lol you put this in to verify that I read all the way to the end, right?
No description provided.