|
3 | 3 | import com.google.common.collect.BiMap; |
4 | 4 | import com.google.common.collect.HashBiMap; |
5 | 5 | import com.google.common.collect.ImmutableBiMap; |
6 | | -import com.google.common.collect.ImmutableList; |
7 | 6 | import graphql.GraphQLContext; |
8 | 7 | import graphql.Internal; |
| 8 | +import graphql.collect.ImmutableKit; |
9 | 9 | import graphql.execution.CoercedVariables; |
10 | 10 | import graphql.execution.ValuesResolver; |
11 | 11 | import graphql.language.Directive; |
|
14 | 14 | import graphql.schema.GraphQLDirective; |
15 | 15 | import graphql.schema.GraphQLSchema; |
16 | 16 |
|
17 | | -import java.util.Collection; |
18 | 17 | import java.util.List; |
19 | 18 | import java.util.Locale; |
20 | 19 | import java.util.Map; |
@@ -66,13 +65,16 @@ private void buildArguments(GraphQLDirective.Builder directiveBuilder, |
66 | 65 |
|
67 | 66 | public List<QueryAppliedDirective> toAppliedDirectives(List<Directive> directives, GraphQLSchema schema, CoercedVariables variables, GraphQLContext graphQLContext, Locale locale) { |
68 | 67 | BiMap<GraphQLDirective, Directive> directivesMap = resolveDirectives(directives, schema, variables, graphQLContext, locale); |
69 | | - return toAppliedDirectives(directivesMap.keySet()); |
70 | | - } |
71 | | - |
72 | | - public List<QueryAppliedDirective> toAppliedDirectives(Collection<GraphQLDirective> directives) { |
73 | | - return directives.stream().map(this::toAppliedDirective).collect(ImmutableList.toImmutableList()); |
| 68 | + return ImmutableKit.map(directivesMap.keySet(), this::toAppliedDirective); |
74 | 69 | } |
75 | 70 |
|
| 71 | + /** |
| 72 | + * This helps us remodel the applied GraphQLDirective back to the better modelled and named {@link QueryAppliedDirective} |
| 73 | + * |
| 74 | + * @param directive the directive to remodel |
| 75 | + * |
| 76 | + * @return a QueryAppliedDirective |
| 77 | + */ |
76 | 78 | public QueryAppliedDirective toAppliedDirective(GraphQLDirective directive) { |
77 | 79 | QueryAppliedDirective.Builder builder = QueryAppliedDirective.newDirective(); |
78 | 80 | builder.name(directive.getName()); |
|
0 commit comments