Repository navigation
Expand file tree
/
Copy pathTypeResolutionParameters.java
More file actions
156 lines (129 loc) · 4.51 KB
/
Copy pathTypeResolutionParameters.java
File metadata and controls
156 lines (129 loc) · 4.51 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package graphql.execution;
import graphql.DeprecatedAt;
import graphql.GraphQLContext;
import graphql.Internal;
import graphql.TypeResolutionEnvironment;
import graphql.collect.ImmutableMapWithNullValues;
import graphql.schema.DataFetchingFieldSelectionSet;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
import java.util.Map;
import java.util.function.Supplier;
/**
* This class is a classic builder style one that SHOULD have been on have been on {@link TypeResolutionEnvironment}
* but for legacy reasons was not. So it acts as the builder of {@link TypeResolutionEnvironment} objects
*/
@Internal
public class TypeResolutionParameters {
private final MergedField field;
private final GraphQLType fieldType;
private final Object value;
private final Supplier<ImmutableMapWithNullValues<String, Object>> argumentValues;
private final GraphQLSchema schema;
private final Object context;
private final Object localContext;
private final GraphQLContext graphQLContext;
private final DataFetchingFieldSelectionSet selectionSet;
private TypeResolutionParameters(Builder builder) {
this.field = builder.field;
this.fieldType = builder.fieldType;
this.value = builder.value;
this.argumentValues = builder.argumentValues;
this.schema = builder.schema;
this.context = builder.context;
this.graphQLContext = builder.graphQLContext;
this.localContext = builder.localContext;
this.selectionSet = builder.selectionSet;
}
public MergedField getField() {
return field;
}
public GraphQLType getFieldType() {
return fieldType;
}
public Object getValue() {
return value;
}
public Map<String, Object> getArgumentValues() {
return argumentValues.get();
}
public GraphQLSchema getSchema() {
return schema;
}
public DataFetchingFieldSelectionSet getSelectionSet() {
return selectionSet;
}
public static Builder newParameters() {
return new Builder();
}
/**
* @return the legacy context object
*
* @deprecated use {@link #getGraphQLContext()} instead
*/
@Deprecated
@DeprecatedAt("2021-07-05")
public Object getContext() {
return context;
}
public GraphQLContext getGraphQLContext() {
return graphQLContext;
}
public Object getLocalContext() {
return localContext;
}
public static class Builder {
private MergedField field;
private GraphQLType fieldType;
private Object value;
private Supplier<ImmutableMapWithNullValues<String, Object>> argumentValues;
private GraphQLSchema schema;
private Object context;
private GraphQLContext graphQLContext;
private Object localContext;
private DataFetchingFieldSelectionSet selectionSet;
public Builder field(MergedField field) {
this.field = field;
return this;
}
public Builder fieldType(GraphQLType fieldType) {
this.fieldType = fieldType;
return this;
}
public Builder value(Object value) {
this.value = value;
return this;
}
public Builder argumentValues(Supplier<Map<String, Object>> argumentValues) {
this.argumentValues = () -> ImmutableMapWithNullValues.copyOf(argumentValues.get());
return this;
}
public Builder schema(GraphQLSchema schema) {
this.schema = schema;
return this;
}
@Deprecated
@DeprecatedAt("2021-07-05")
public Builder context(Object context) {
this.context = context;
return this;
}
public Builder graphQLContext(GraphQLContext context) {
this.graphQLContext = context;
return this;
}
public Builder localContext(Object localContext) {
this.localContext = localContext;
return this;
}
public Builder selectionSet(DataFetchingFieldSelectionSet selectionSet) {
this.selectionSet = selectionSet;
return this;
}
public TypeResolutionEnvironment build() {
// this build should have always been in TypeResolutionEnvironment but this little workaround improves it a smidge,
// and we can fix it up later so this class is redundant
return new TypeResolutionEnvironment(new TypeResolutionParameters(this));
}
}
}