Handle repeated query directives#3270
Conversation
| 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.
Previously this would just replace the last directive instance. Now it accumulates the values for repeated directives.
| 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.
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()
| } | ||
|
|
||
| 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.
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.
Groovy is a pathway to many abilities some consider to be unnatural
Lol
There was a problem hiding this comment.
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.
Lol you put this in to verify that I read all the way to the end, right?
No description provided.