|
1 | 1 | package graphql.schema; |
2 | 2 |
|
3 | 3 |
|
4 | | -import graphql.execution.ExecutionContext; |
| 4 | +import graphql.Internal; |
5 | 5 | import graphql.execution.ExecutionId; |
6 | 6 | import graphql.language.Field; |
7 | 7 | import graphql.language.FragmentDefinition; |
8 | 8 |
|
9 | | -import java.util.Collections; |
10 | 9 | import java.util.List; |
11 | 10 | import java.util.Map; |
12 | 11 |
|
13 | 12 | @SuppressWarnings("unchecked") |
| 13 | +@Internal |
14 | 14 | public class DataFetchingEnvironmentImpl implements DataFetchingEnvironment { |
15 | 15 | private final Object source; |
16 | 16 | private final Map<String, Object> arguments; |
@@ -102,110 +102,4 @@ public ExecutionId getExecutionId() { |
102 | 102 | public DataFetchingFieldSelectionSet getSelectionSet() { |
103 | 103 | return selectionSet; |
104 | 104 | } |
105 | | - |
106 | | - public static Builder newDataFetchingEnvironment() { |
107 | | - return new Builder(); |
108 | | - } |
109 | | - |
110 | | - public static Builder newDataFetchingEnvironment(ExecutionContext executionContext) { |
111 | | - return new Builder() |
112 | | - .context(executionContext.getContext()) |
113 | | - .root(executionContext.getRoot()) |
114 | | - .graphQLSchema(executionContext.getGraphQLSchema()) |
115 | | - .fragmentsByName(executionContext.getFragmentsByName()) |
116 | | - .executionId(executionContext.getExecutionId()); |
117 | | - } |
118 | | - |
119 | | - |
120 | | - public static Builder newDataFetchingEnvironment(DataFetchingEnvironment environment) { |
121 | | - return new Builder() |
122 | | - .source(environment.getSource()) |
123 | | - .arguments(environment.getArguments()) |
124 | | - .context(environment.getContext()) |
125 | | - .root(environment.getRoot()) |
126 | | - .fields(environment.getFields()) |
127 | | - .fieldType(environment.getFieldType()) |
128 | | - .parentType(environment.getParentType()) |
129 | | - .graphQLSchema(environment.getGraphQLSchema()) |
130 | | - .fragmentsByName(environment.getFragmentsByName()) |
131 | | - .executionId(environment.getExecutionId()) |
132 | | - .selectionSet(environment.getSelectionSet()); |
133 | | - } |
134 | | - |
135 | | - public static class Builder { |
136 | | - |
137 | | - private Object source; |
138 | | - private Map<String, Object> arguments = Collections.emptyMap(); |
139 | | - private Object context; |
140 | | - private Object root; |
141 | | - private List<Field> fields = Collections.emptyList(); |
142 | | - private GraphQLOutputType fieldType; |
143 | | - private GraphQLType parentType; |
144 | | - private GraphQLSchema graphQLSchema; |
145 | | - private Map<String, FragmentDefinition> fragmentsByName = Collections.emptyMap(); |
146 | | - private ExecutionId executionId; |
147 | | - private DataFetchingFieldSelectionSet selectionSet; |
148 | | - |
149 | | - |
150 | | - public Builder source(Object source) { |
151 | | - this.source = source; |
152 | | - return this; |
153 | | - } |
154 | | - |
155 | | - public Builder arguments(Map<String, Object> arguments) { |
156 | | - this.arguments = arguments; |
157 | | - return this; |
158 | | - } |
159 | | - |
160 | | - public Builder context(Object context) { |
161 | | - this.context = context; |
162 | | - return this; |
163 | | - } |
164 | | - |
165 | | - public Builder root(Object root) { |
166 | | - this.root = root; |
167 | | - return this; |
168 | | - } |
169 | | - |
170 | | - public Builder fields(List<Field> fields) { |
171 | | - this.fields = fields; |
172 | | - return this; |
173 | | - } |
174 | | - |
175 | | - public Builder fieldType(GraphQLOutputType fieldType) { |
176 | | - this.fieldType = fieldType; |
177 | | - return this; |
178 | | - } |
179 | | - |
180 | | - public Builder parentType(GraphQLType parentType) { |
181 | | - this.parentType = parentType; |
182 | | - return this; |
183 | | - } |
184 | | - |
185 | | - public Builder graphQLSchema(GraphQLSchema graphQLSchema) { |
186 | | - this.graphQLSchema = graphQLSchema; |
187 | | - return this; |
188 | | - } |
189 | | - |
190 | | - public Builder fragmentsByName(Map<String, FragmentDefinition> fragmentsByName) { |
191 | | - this.fragmentsByName = fragmentsByName; |
192 | | - return this; |
193 | | - } |
194 | | - |
195 | | - public Builder executionId(ExecutionId executionId) { |
196 | | - this.executionId = executionId; |
197 | | - return this; |
198 | | - } |
199 | | - |
200 | | - public Builder selectionSet(DataFetchingFieldSelectionSet selectionSet) { |
201 | | - this.selectionSet = selectionSet; |
202 | | - return this; |
203 | | - } |
204 | | - |
205 | | - public DataFetchingEnvironment build() { |
206 | | - return new DataFetchingEnvironmentImpl(source, arguments, context, root, |
207 | | - fields, fieldType, parentType, graphQLSchema, fragmentsByName, executionId, selectionSet |
208 | | - ); |
209 | | - } |
210 | | - } |
211 | 105 | } |
0 commit comments