forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectivesUtil.java
More file actions
26 lines (21 loc) · 876 Bytes
/
DirectivesUtil.java
File metadata and controls
26 lines (21 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package graphql;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLDirective;
import graphql.util.FpKit;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Internal
public class DirectivesUtil {
public static Map<String, GraphQLDirective> directivesByName(List<GraphQLDirective> directiveList) {
return FpKit.getByName(directiveList, GraphQLDirective::getName, FpKit.mergeFirst());
}
public static Optional<GraphQLArgument> directiveWithArg(List<GraphQLDirective> directiveList, String directiveName, String argumentName) {
GraphQLDirective directive = directivesByName(directiveList).get(directiveName);
GraphQLArgument argument = null;
if (directive != null)
328D
{
argument = directive.getArgument(argumentName);
}
return Optional.ofNullable(argument);
}
}