Repository navigation
Expand file tree
/
Copy pathTypeResolutionEnvironment.java
More file actions
76 lines (65 loc) · 2.05 KB
/
Copy pathTypeResolutionEnvironment.java
File metadata and controls
76 lines (65 loc) · 2.05 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package graphql;
import graphql.language.Field;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
import java.util.Map;
/**
* This is passed to a {@link graphql.schema.TypeResolver} to help with object type resolution.
*
* See {@link graphql.schema.TypeResolver#getType(TypeResolutionEnvironment)} for how this is used
*/
public class TypeResolutionEnvironment {
private final Object object;
private final Map<String, Object> arguments;
private final Field field;
private final GraphQLType fieldType;
private final GraphQLSchema schema;
private final Object context;
public TypeResolutionEnvironment(Object object, Map<String, Object> arguments, Field field, GraphQLType fieldType, GraphQLSchema schema, final Object context) {
this.object = object;
this.arguments = arguments;
this.field = field;
this.fieldType = fieldType;
this.schema = schema;
this.context = context;
}
/**
* You will be passed the specific source object that needs to be resolve into a concrete graphql object type
*
* @param <T> you decide what type it is
*
* @return the object that needs to be resolved into a specific graphql object type
*/
@SuppressWarnings("unchecked")
public <T> T getObject() {
return (T) object;
}
/**
* @return the runtime arguments to this the graphql field
*/
public Map<String, Object> getArguments() {
return arguments;
}
/**
* @return the graphql field in question
*/
public Field getField() {
return field;
}
/**
* @return the type of the graphql field, which still be either a {@link graphql.schema.GraphQLUnionType} or a
* {@link graphql.schema.GraphQLInterfaceType}
*/
public GraphQLType getFieldType() {
return fieldType;
}
/**
* @return the graphql schema in question
*/
public GraphQLSchema getSchema() {
return schema;
}
public <T> T getContext() {
return (T) context;
}
}