Skip to content

Commit 3b8bb68

Browse files
committed
remove deferred related code
1 parent 06c0b2d commit 3b8bb68

10 files changed

Lines changed: 2 additions & 169 deletions

File tree

src/main/java/graphql/Directives.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ public class Directives {
4040
.validLocations(FRAGMENT_SPREAD, INLINE_FRAGMENT, FIELD)
4141
.build();
4242

43-
/**
44-
* The @defer directive can be used to defer sending data for a field till later in the query. This is an opt in
45-
* directive that is not available unless it is explicitly put into the schema.
46-
*/
47-
public static final GraphQLDirective DeferDirective = GraphQLDirective.newDirective()
48-
.name("defer")
49-
.description("This directive allows results to be deferred during execution")
50-
.argument(newArgument()
51-
.name("if")
52-
.type(nonNull(GraphQLBoolean))
53-
.description("Deferred behaviour is controlled by this argument")
54-
.defaultValue(true)
55-
)
56-
.validLocations(FIELD)
57-
.build();
5843

5944
/**
6045
* The "deprecated" directive is special and is always available in a graphql schema

src/main/java/graphql/execution/ExecutorServiceExecutionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
*
2222
* <p>Deprecation Notice : This execution strategy does not support all of the graphql-java capabilities
23-
* such as data loader or @defer fields. Since its so easy to create a data fetcher that uses
23+
* such as data loader. Since its so easy to create a data fetcher that uses
2424
* {@link java.util.concurrent.CompletableFuture#supplyAsync(java.util.function.Supplier, java.util.concurrent.Executor)}
2525
* to make field fetching happen off thread we recommend that you use that instead of this class. This class
2626
* will be removed in a future version.

src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import graphql.execution.Async;
77
import graphql.execution.ExecutionContext;
88
import graphql.execution.FieldValueInfo;
9-
import graphql.execution.MergedField;
109
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters;
1110
import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters;
1211
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
@@ -283,10 +282,6 @@ public void onFieldValuesInfo(List<FieldValueInfo> fieldValueInfoList) {
283282
contexts.forEach(context -> context.onFieldValuesInfo(fieldValueInfoList));
284283
}
285284

286-
@Override
287-
public void onDeferredField(MergedField field) {
288-
contexts.forEach(context -> context.onDeferredField(field));
289-
}
290285
}
291286

292287
}

src/main/java/graphql/execution/instrumentation/ExecutionStrategyInstrumentationContext.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import graphql.ExecutionResult;
44
import graphql.PublicSpi;
55
import graphql.execution.FieldValueInfo;
6-
import graphql.execution.MergedField;
76

87
import java.util.List;
98

@@ -14,7 +13,4 @@ default void onFieldValuesInfo(List<FieldValueInfo> fieldValueInfoList) {
1413

1514
}
1615

17-
default void onDeferredField(MergedField field) {
18-
19-
}
2016
}

src/main/java/graphql/execution/instrumentation/dataloader/FieldLevelTrackingApproach.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import graphql.ExecutionResult;
55
import graphql.Internal;
66
import graphql.execution.FieldValueInfo;
7-
import graphql.execution.MergedField;
87
import graphql.execution.ResultPath;
98
import graphql.execution.instrumentation.ExecutionStrategyInstrumentationContext;
109
import graphql.execution.instrumentation.InstrumentationContext;
@@ -157,19 +156,6 @@ public void onFieldValuesInfo(List<FieldValueInfo> fieldValueInfoList) {
157156
dispatch();
158157
}
159158
}
160-
161-
@Override
162-
public void onDeferredField(MergedField field) {
163-
boolean dispatchNeeded;
164-
// fake fetch count for this field
165-
synchronized (callStack) {
166-
callStack.increaseFetchCount(curLevel);
167-
dispatchNeeded = dispatchIfNeeded(callStack, curLevel);
168-
}
169-
if (dispatchNeeded) {
170-
dispatch();
171-
}
172-
}
173159
};
174160
}
175161

src/main/java/graphql/execution/nextgen/FetchedValueAnalysis.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public enum FetchedValueType {
2121
LIST,
2222
SCALAR,
2323
ENUM,
24-
DEFER
2524
}
2625

2726
private final FetchedValueType valueType;

src/main/java/graphql/validation/ValidationErrorType.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ public enum ValidationErrorType {
3232
DuplicateOperationName,
3333
DuplicateFragmentName,
3434
DuplicateDirectiveName,
35-
DeferDirectiveOnNonNullField,
36-
DeferDirectiveNotOnQueryOperation,
37-
DeferMustBeOnAllFields,
3835
DuplicateArgumentNames,
3936
DuplicateVariableName
4037
}

src/test/groovy/example/http/HttpMain.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.util.Map;
4141
import java.util.concurrent.CompletableFuture;
4242

43-
import static graphql.Directives.DeferDirective;
4443
import static graphql.ExecutionInput.newExecutionInput;
4544
import static graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationOptions.newOptions;
4645
import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring;
@@ -256,7 +255,6 @@ private GraphQLSchema buildStarWarsSchema() {
256255

257256
// finally combine the logical schema with the physical runtime
258257
starWarsSchema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
259-
starWarsSchema = starWarsSchema.transform(builder -> builder.additionalDirective(DeferDirective));
260258
}
261259
return starWarsSchema;
262260
}

src/test/groovy/example/http/package-info.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,5 @@
3030
*
3131
* }
3232
* </pre>
33-
*
34-
* This also has @defer support which sends back HTTP multipart requests. Since tools like graphiql dont understand http multipart
35-
* then you might use a tool like curl to see results
36-
*
37-
* <pre>
38-
* {@code
39-
* curl \
40-
* -X POST \
41-
* -H "Content-Type: application/json" \
42-
* --data '{ "query": "{ hero { name friends @defer { name } } } "}' \
43-
* http://localhost:8080/graphql
44-
* }
45-
* </pre>
46-
*
47-
* See https://www.apollographql.com/docs/react/features/defer-support.html for some more details on @defer
4833
*/
4934
package example.http;

src/test/groovy/graphql/execution/instrumentation/dataloader/DataLoaderPerformanceData.groovy

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package graphql.execution.instrumentation.dataloader
22

3-
import graphql.Directives
3+
44
import graphql.GraphQL
55
import graphql.execution.instrumentation.Instrumentation
66
import graphql.schema.GraphQLSchema
77
import org.dataloader.DataLoaderRegistry
88

9-
109
class DataLoaderPerformanceData {
1110

1211
private final BatchCompareDataFetchers batchCompareDataFetchers;
@@ -23,7 +22,6 @@ class DataLoaderPerformanceData {
2322

2423
GraphQL setupGraphQL(Instrumentation instrumentation) {
2524
GraphQLSchema schema = new BatchCompare().buildDataLoaderSchema(batchCompareDataFetchers)
26-
schema = schema.transform({ bldr -> bldr.additionalDirective(Directives.DeferDirective) })
2725

2826
GraphQL.newGraphQL(schema)
2927
.instrumentation(instrumentation)
@@ -156,110 +154,4 @@ class DataLoaderPerformanceData {
156154
}
157155
}
158156
"""
159-
160-
static def expectedInitialDeferredData = [
161-
shops: [
162-
[id: "shop-1", name: "Shop 1", departments: null],
163-
[id: "shop-2", name: "Shop 2", departments: null],
164-
[id: "shop-3", name: "Shop 3", departments: null],
165-
]
166-
]
167-
168-
static def expectedInitialExpensiveDeferredData = [
169-
shops : [
170-
[id: "shop-1", name: "Shop 1", departments: null, expensiveDepartments: null],
171-
[id: "shop-2", name: "Shop 2", departments: null, expensiveDepartments: null],
172-
[id: "shop-3", name: "Shop 3", departments: null, expensiveDepartments: null],
173-
],
174-
expensiveShops: null
175-
]
176-
177-
static def expectedListOfDeferredData = [
178-
[[id: "department-1", name: "Department 1", products: [[id: "product-1", name: "Product 1"]]],
179-
[id: "department-2", name: "Department 2", products: [[id: "product-2", name: "Product 2"]]],
180-
[id: "department-3", name: "Department 3", products: [[id: "product-3", name: "Product 3"]]]]
181-
,
182-
183-
[[id: "department-4", name: "Department 4", products: [[id: "product-4", name: "Product 4"]]],
184-
[id: "department-5", name: "Department 5", products: [[id: "product-5", name: "Product 5"]]],
185-
[id: "department-6", name: "Department 6", products: [[id: "product-6", name: "Product 6"]]]]
186-
,
187-
[[id: "department-7", name: "Department 7", products: [[id: "product-7", name: "Product 7"]]],
188-
[id: "department-8", name: "Department 8", products: [[id: "product-8", name: "Product 8"]]],
189-
[id: "department-9", name: "Department 9", products: [[id: "product-9", name: "Product 9"]]]]
190-
,
191-
192-
]
193-
194-
195-
static def deferredQuery = """
196-
query {
197-
shops {
198-
id name
199-
departments @defer {
200-
id name
201-
products {
202-
id name
203-
}
204-
}
205-
}
206-
}
207-
"""
208-
209-
static def expensiveDeferredQuery = """
210-
query {
211-
shops {
212-
id name
213-
departments @defer {
214-
name
215-
products @defer {
216-
name
217-
}
218-
expensiveProducts @defer {
219-
name
220-
}
221-
}
222-
expensiveDepartments @defer {
223-
name
224-
products {
225-
name
226-
}
227-
expensiveProducts {
228-
name
229-
}
230-
}
231-
}
232-
expensiveShops @defer {
233-
id name
234-
}
235-
}
236-
"""
237-
238-
static def expectedExpensiveDeferredData = [
239-
[[id: "exshop-1", name: "ExShop 1"], [id: "exshop-2", name: "ExShop 2"], [id: "exshop-3", name: "ExShop 3"]],
240-
[[name: "Department 1",products:null, expensiveProducts:null], [name: "Department 2",products:null, expensiveProducts:null], [name: "Department 3",products:null, expensiveProducts:null]],
241-
[[name: "Department 1", products: [[name: "Product 1"]], expensiveProducts: [[name: "Product 1"]]], [name: "Department 2", products: [[name: "Product 2"]], expensiveProducts: [[name: "Product 2"]]], [name: "Department 3", products: [[name: "Product 3"]], expensiveProducts: [[name: "Product 3"]]]],
242-
[[name: "Department 4",products:null, expensiveProducts:null], [name: "Department 5",products:null, expensiveProducts:null], [name: "Department 6",products:null, expensiveProducts:null]],
243-
[[name: "Department 4", products: [[name: "Product 4"]], expensiveProducts: [[name: "Product 4"]]], [name: "Department 5", products: [[name: "Product 5"]], expensiveProducts: [[name: "Product 5"]]], [name: "Department 6", products: [[name: "Product 6"]], expensiveProducts: [[name: "Product 6"]]]],
244-
[[name: "Department 7",products:null, expensiveProducts:null], [name: "Department 8",products:null, expensiveProducts:null], [name: "Department 9",products:null, expensiveProducts:null]],
245-
[[name: "Department 7", products: [[name: "Product 7"]], expensiveProducts: [[name: "Product 7"]]], [name: "Department 8", products: [[name: "Product 8"]], expensiveProducts: [[name: "Product 8"]]], [name: "Department 9", products: [[name: "Product 9"]], expensiveProducts: [[name: "Product 9"]]]],
246-
[[name: "Product 1"]],
247-
[[name: "Product 1"]],
248-
[[name: "Product 2"]],
249-
[[name: "Product 2"]],
250-
[[name: "Product 3"]],
251-
[[name: "Product 3"]],
252-
[[name: "Product 4"]],
253-
[[name: "Product 4"]],
254-
[[name: "Product 5"]],
255-
[[name: "Product 5"]],
256-
[[name: "Product 6"]],
257-
[[name: "Product 6"]],
258-
[[name: "Product 7"]],
259-
[[name: "Product 7"]],
260-
[[name: "Product 8"]],
261-
[[name: "Product 8"]],
262-
[[name: "Product 9"]],
263-
[[name: "Product 9"]],
264-
]
265157
}

0 commit comments

Comments
 (0)