Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert small change
  • Loading branch information
pelletier197 committed Jul 25, 2021
commit a3be90a61f67bf80a8375564222e2f483df2dd79
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public boolean appliesTo(GraphQLArgument argument, GraphQLFieldDefinition fieldD
public List<GraphQLError> runValidation(ValidationEnvironment validationEnvironment) {
Object validatedValue = validationEnvironment.getValidatedValue();

// output fields are special
if (validationEnvironment.getValidatedElement() == FIELD) {
return runValidationImpl(validationEnvironment);
}

//
// all the directives validation code does NOT care for NULL ness since the graphql engine covers that.
// eg a @NonNull validation directive makes no sense in graphql like it might in Java
Expand All @@ -120,11 +125,6 @@ public List<GraphQLError> runValidation(ValidationEnvironment validationEnvironm
return Collections.emptyList();
}

// output fields are special
if (validationEnvironment.getValidatedElement() == FIELD) {
return runValidationImpl(validationEnvironment);
}

GraphQLInputType inputType = Util.unwrapNonNull(validationEnvironment.getValidatedType());
validationEnvironment = validationEnvironment.transform(b -> b.validatedType(inputType));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class ExpressionConstraintTest extends BaseConstraintTestSupport {

@Unroll
def "expression constraints on a field"() {
// TODO - is this useful? Those tests don't pass anymore because `validatedValue` is null.
// Those also validate the arguments, even it the directive is on the field. An alternative for the user could be to wrap the arguments in another abject and put the directive on that wrapped type.

DirectiveConstraint ruleUnderTest = new ExpressionConstraint()

expect:
Expand All @@ -31,7 +28,7 @@ class ExpressionConstraintTest extends BaseConstraintTestSupport {

fieldDeclaration | args | expectedMessage
'field( first : Int, last : Int) : ID ' + relayCheck | [first: 10] | ""
// 'field( first : Int, last : Int) : ID ' + relayCheck | [first: 10, last: 20] | "Expression;path=/field;val:null;\t"
'field( first : Int, last : Int) : ID ' + relayCheck | [first: 10, last: 20] | "Expression;path=/field;val:null;\t"
}


Expand Down