Skip to content

Commit a5f0fac

Browse files
committed
Revert "Rename to @nullOnNonNullError"
This reverts commit e744cca.
1 parent e744cca commit a5f0fac

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/main/java/graphql/Directives.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Directives {
4040
private static final String SPECIFIED_BY = "specifiedBy";
4141
private static final String ONE_OF = "oneOf";
4242
private static final String DEFER = "defer";
43-
private static final String NULL_ON_NON_NULL_ERROR = "nullOnNonNullError";
43+
private static final String NULL_ON_ERROR = "nullOnError";
4444

4545
public static final DirectiveDefinition DEPRECATED_DIRECTIVE_DEFINITION;
4646
public static final DirectiveDefinition INCLUDE_DIRECTIVE_DEFINITION;
@@ -51,7 +51,7 @@ public class Directives {
5151
@ExperimentalApi
5252
public static final DirectiveDefinition DEFER_DIRECTIVE_DEFINITION;
5353
@ExperimentalApi
54-
public static final DirectiveDefinition NULL_ON_NON_NULL_ERROR_DIRECTIVE_DEFINITION;
54+
public static final DirectiveDefinition NULL_ON_ERROR_DIRECTIVE_DEFINITION;
5555

5656
public static final String BOOLEAN = "Boolean";
5757
public static final String STRING = "String";
@@ -139,8 +139,8 @@ public class Directives {
139139
.type(newTypeName().name(STRING).build())
140140
.build())
141141
.build();
142-
NULL_ON_NON_NULL_ERROR_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition()
143-
.name(NULL_ON_NON_NULL_ERROR)
142+
NULL_ON_ERROR_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition()
143+
.name(NULL_ON_ERROR)
144144
.directiveLocation(newDirectiveLocation().name(QUERY.name()).build())
145145
.directiveLocation(newDirectiveLocation().name(MUTATION.name()).build())
146146
.directiveLocation(newDirectiveLocation().name(SUBSCRIPTION.name()).build())
@@ -241,10 +241,10 @@ public class Directives {
241241

242242
@ExperimentalApi
243243
public static final GraphQLDirective NullOnErrorDirective = GraphQLDirective.newDirective()
244-
.name(NULL_ON_NON_NULL_ERROR)
244+
.name(NULL_ON_ERROR)
245245
.description("This directive allows returning null in non-null positions that have an associated error.")
246246
.validLocations(QUERY, MUTATION, SUBSCRIPTION)
247-
.definition(NULL_ON_NON_NULL_ERROR_DIRECTIVE_DEFINITION)
247+
.definition(NULL_ON_ERROR_DIRECTIVE_DEFINITION)
248248
.build();
249249

250250
private static Description createDescription(String s) {

src/main/java/graphql/ExperimentalApi.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
String ENABLE_INCREMENTAL_SUPPORT = "ENABLE_INCREMENTAL_SUPPORT";
2727
/**
28-
* The key that should be associated with a boolean value which indicates whether @nullOnNonNullError behaviour is enabled for this execution.
28+
* The key that should be associated with a boolean value which indicates whether @nullOnError behaviour is enabled for this execution.
2929
*/
30-
String ENABLE_NULL_ON_NON_NULL_ERROR = "ENABLE_NULL_ON_NON_NULL_ERROR";
30+
String ENABLE_NULL_ON_ERROR = "ENABLE_NULL_ON_ERROR";
3131
}

src/main/java/graphql/execution/Execution.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import java.util.Optional;
3838
import java.util.concurrent.CompletableFuture;
3939

40-
import static graphql.Directives.NULL_ON_NON_NULL_ERROR_DIRECTIVE_DEFINITION;
40+
import static graphql.Directives.NULL_ON_ERROR_DIRECTIVE_DEFINITION;
4141
import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder;
4242
import static graphql.execution.ExecutionStepInfo.newExecutionStepInfo;
4343
import static graphql.execution.ExecutionStrategyParameters.newParameters;
@@ -89,7 +89,7 @@ public CompletableFuture<ExecutionResult> execute(Document document, GraphQLSche
8989
}
9090

9191
boolean customErrorPropagationEnabled = Optional.ofNullable(executionInput.getGraphQLContext())
92-
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_NULL_ON_NON_NULL_ERROR))
92+
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_NULL_ON_ERROR))
9393
.orElse(false);
9494
boolean propagateErrors = !customErrorPropagationEnabled || propagateErrors(operationDefinition.getDirectives(), true);
9595

@@ -272,7 +272,7 @@ private ExecutionResult mergeExtensionsBuilderIfPresent(ExecutionResult executio
272272
}
273273

274274
private boolean propagateErrors(List<Directive> directives, boolean defaultValue) {
275-
Directive foundDirective = NodeUtil.findNodeByName(directives, NULL_ON_NON_NULL_ERROR_DIRECTIVE_DEFINITION.getName());
275+
Directive foundDirective = NodeUtil.findNodeByName(directives, NULL_ON_ERROR_DIRECTIVE_DEFINITION.getName());
276276
if (foundDirective != null) {
277277
return false;
278278
}

src/main/java/graphql/execution/ExecutionContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public ValueUnboxer getValueUnboxer() {
176176
/**
177177
* @return true if the current operation should propagate errors in non-null positions
178178
* Propagating errors is the default. Error aware clients may opt in returning null in non-null positions
179-
* by using the `@nullOnNonNullError` directive.
179+
* by using the `@nullOnError` directive.
180180
*/
181181
@ExperimentalApi
182182
public boolean propagateErrors() { return propagateErrors; }

src/test/groovy/graphql/execution/NoErrorPropagationTest.groovy

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ import spock.lang.Specification
77

88
class NoErrorPropagationTest extends Specification {
99

10-
def "with nullOnNonNullError, null is returned"() {
10+
def "with nullOnError, null is returned"() {
1111

1212
def sdl = '''
1313
type Query {
1414
foo : Int!
1515
}
16-
directive @nullOnNonNullError on QUERY | MUTATION | SUBSCRIPTION
16+
directive @nullOnError on QUERY | MUTATION | SUBSCRIPTION
1717
'''
1818

1919
def graphql = TestUtil.graphQL(sdl).build()
2020

2121
def query = '''
22-
query GetFoo @nullOnNonNullError { foo }
22+
query GetFoo @nullOnError { foo }
2323
'''
2424
when:
2525

2626
ExecutionInput ei = ExecutionInput.newExecutionInput(query).root(
2727
[foo: null]
28-
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_NON_NULL_ERROR): true])
28+
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_ERROR): true])
2929
.build()
3030

3131
def er = graphql.execute(ei)
@@ -36,13 +36,13 @@ class NoErrorPropagationTest extends Specification {
3636
er.errors[0].path.toList() == ["foo"]
3737
}
3838

39-
def "without nullOnNonNullError, error is propagated"() {
39+
def "without nullOnError, error is propagated"() {
4040

4141
def sdl = '''
4242
type Query {
4343
foo : Int!
4444
}
45-
directive @nullOnNonNullError on QUERY | MUTATION | SUBSCRIPTION
45+
directive @nullOnError on QUERY | MUTATION | SUBSCRIPTION
4646
'''
4747

4848
def graphql = TestUtil.graphQL(sdl).build()
@@ -54,7 +54,7 @@ class NoErrorPropagationTest extends Specification {
5454

5555
ExecutionInput ei = ExecutionInput.newExecutionInput(query).root(
5656
[foo: null]
57-
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_NON_NULL_ERROR): true])
57+
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_ERROR): true])
5858
.build()
5959

6060
def er = graphql.execute(ei)
@@ -66,19 +66,19 @@ class NoErrorPropagationTest extends Specification {
6666
}
6767

6868

69-
def "when ENABLE_NULL_ON_NON_NULL_ERROR is false, error is propagated"() {
69+
def "when ENABLE_NULL_ON_ERROR is false, error is propagated"() {
7070

7171
def sdl = '''
7272
type Query {
7373
foo : Int!
7474
}
75-
directive @nullOnNonNullError on QUERY | MUTATION | SUBSCRIPTION
75+
directive @nullOnError on QUERY | MUTATION | SUBSCRIPTION
7676
'''
7777

7878
def graphql = TestUtil.graphQL(sdl).build()
7979

8080
def query = '''
81-
query GetFoo @nullOnNonNullError { foo }
81+
query GetFoo @nullOnError { foo }
8282
'''
8383
when:
8484

@@ -93,7 +93,7 @@ class NoErrorPropagationTest extends Specification {
9393
er.errors[0].path.toList() == ["foo"]
9494
}
9595

96-
def "when @nullOnNonNullError is not added to the schema operation does not validate"() {
96+
def "when @nullOnError is not added to the schema operation does not validate"() {
9797

9898
def sdl = '''
9999
type Query {
@@ -104,20 +104,20 @@ class NoErrorPropagationTest extends Specification {
104104
def graphql = TestUtil.graphQL(sdl).build()
105105

106106
def query = '''
107-
query GetFoo @nullOnNonNullError { foo }
107+
query GetFoo @nullOnError { foo }
108108
'''
109109
when:
110110

111111
ExecutionInput ei = ExecutionInput.newExecutionInput(query).root(
112112
[foo: null]
113-
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_NON_NULL_ERROR): true])
113+
).graphQLContext([(ExperimentalApi.ENABLE_NULL_ON_ERROR): true])
114114
.build()
115115

116116
def er = graphql.execute(ei)
117117

118118
then:
119119
er.data == null
120-
er.errors[0].message.equals("Validation error (UnknownDirective) : Unknown directive 'nullOnNonNullError'")
120+
er.errors[0].message.equals("Validation error (UnknownDirective) : Unknown directive 'nullOnError'")
121121
}
122122

123123
}

0 commit comments

Comments
 (0)