forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirectiveInfo.java
59 lines (50 loc) · 2.1 KB
/
DirectiveInfo.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package graphql.schema.idl;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import graphql.Directives;
import graphql.PublicApi;
import graphql.schema.GraphQLDirective;
import java.util.Map;
import java.util.Set;
/**
* Info on all the directives provided by graphql specification
*/
@PublicApi
public class DirectiveInfo {
/**
* A set of directives which provided by graphql specification
*/
public static final Set<GraphQLDirective> GRAPHQL_SPECIFICATION_DIRECTIVES = ImmutableSet.of(
Directives.IncludeDirective,
Directives.SkipDirective,
Directives.DeprecatedDirective,
Directives.SpecifiedByDirective);
/**
* A map from directive name to directive which provided by specification
*/
public static final Map<String, GraphQLDirective> GRAPHQL_SPECIFICATION_DIRECTIVE_MAP = ImmutableMap.of(
Directives.IncludeDirective.getName(), Directives.IncludeDirective,
Directives.SkipDirective.getName(), Directives.SkipDirective,
Directives.DeprecatedDirective.getName(), Directives.DeprecatedDirective,
Directives.SpecifiedByDirective.getName(), Directives.SpecifiedByDirective);
/**
* Returns true if a directive with provided directiveName has been defined in graphql specification
*
* @param directiveName the name of directive in question
*
* @return true if the directive provided by graphql specification, and false otherwise
*/
public static boolean isGraphqlSpecifiedDirective(String directiveName) {
return GRAPHQL_SPECIFICATION_DIRECTIVE_MAP.containsKey(directiveName);
}
/**
* Returns true if the provided directive has been defined in graphql specification
*
* @param graphQLDirective the directive in question
*
* @return true if the directive provided by graphql specification, and false otherwise
*/
public static boolean isGraphqlSpecifiedDirective(GraphQLDirective graphQLDirective) {
return isGraphqlSpecifiedDirective(graphQLDirective.getName());
}
}