Skip to content

Commit ef9d07d

Browse files
committed
Removed @defer as a default directive
1 parent 36b1c03 commit ef9d07d

5 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎src/main/java/graphql/Directives.java‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
import graphql.schema.GraphQLDirective;
55

66
import static graphql.Scalars.GraphQLBoolean;
7-
import static graphql.Scalars.GraphQLString;
87
import static graphql.introspection.Introspection.DirectiveLocation.FIELD;
9-
import static graphql.introspection.Introspection.DirectiveLocation.FIELD_DEFINITION;
108
import static graphql.introspection.Introspection.DirectiveLocation.FRAGMENT_SPREAD;
119
import static graphql.introspection.Introspection.DirectiveLocation.INLINE_FRAGMENT;
1210
import static graphql.schema.GraphQLArgument.newArgument;
1311
import static graphql.schema.GraphQLNonNull.nonNull;
1412

1513
/**
16-
* The query directives that are under stood by graphql-java
14+
* The directives that are understood by graphql-java
1715
*/
1816
public class Directives {
1917

@@ -38,19 +36,9 @@ public class Directives {
3836
.build();
3937

4038
/**
41-
* @deprecated - this is no longer needed and will be removed in a future version
39+
* The @defer directive can be used to defer sending data for a field till later in the query. This is an opt in
40+
* directive that is not available unless it is explicitly put into the schema.
4241
*/
43-
@Deprecated
44-
public static final GraphQLDirective FetchDirective = GraphQLDirective.newDirective()
45-
.name("fetch")
46-
.description("Directs the SDL type generation to create a data fetcher that uses this `from` argument as the property name")
47-
.argument(newArgument()
48-
.name("from")
49-
.type(nonNull(GraphQLString))
50-
.description("The `name` used to fetch values from the underlying object"))
51-
.validLocations(FIELD_DEFINITION)
52-
.build();
53-
5442
public static final GraphQLDirective DeferDirective = GraphQLDirective.newDirective()
5543
.name("defer")
5644
.description("This directive allows results to be deferred during execution")

‎src/main/java/graphql/schema/GraphQLSchema.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public static class Builder {
290290
private Set<GraphQLType> additionalTypes = new LinkedHashSet<>();
291291
// we default these in
292292
private Set<GraphQLDirective> additionalDirectives = new LinkedHashSet<>(
293-
asList(Directives.IncludeDirective, Directives.SkipDirective, Directives.DeferDirective)
293+
asList(Directives.IncludeDirective, Directives.SkipDirective)
294294
);
295295

296296
private SchemaUtil schemaUtil = new SchemaUtil();

‎src/test/groovy/graphql/StarWarsIntrospectionTests.groovy‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,6 @@ class StarWarsIntrospectionTests extends Specification {
430430
schemaParts.get('mutationType').size() == 1
431431
schemaParts.get('subscriptionType') == null
432432
schemaParts.get('types').size() == 17
433-
schemaParts.get('directives').size() == 3
433+
schemaParts.get('directives').size() == 2
434434
}
435435
}

‎src/test/groovy/graphql/execution/defer/DeferSupportIntegrationTest.groovy‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.execution.defer
22

3+
import graphql.Directives
34
import graphql.ExecutionInput
45
import graphql.ExecutionResult
56
import graphql.GraphQL
@@ -131,7 +132,9 @@ class DeferSupportIntegrationTest extends Specification {
131132
.type(newTypeWiring("Review").dataFetcher("comments", commentsFetcher))
132133
.build()
133134

134-
graphQL = TestUtil.graphQL(schemaSpec, runtimeWiring).build()
135+
def schema = TestUtil.schema(schemaSpec, runtimeWiring)
136+
.transform({ builder -> builder.additionalDirective(Directives.DeferDirective) })
137+
this.graphQL = GraphQL.newGraphQL(schema).build()
135138
}
136139

137140
def "test defer support end to end"() {

‎src/test/groovy/graphql/schema/GraphQLSchemaTest.groovy‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class GraphQLSchemaTest extends Specification {
130130
when: "no additional directives have been specified"
131131
def schema = schemaBuilder.build()
132132
then:
133-
schema.directives.size() == 3
133+
schema.directives.size() == 2
134134

135135
when: "clear directives is called"
136136
schema = schemaBuilder.clearDirectives().build()

0 commit comments

Comments
 (0)