Skip to content

Upgrading to graphql-java 17 and test running again #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ This library provides extended validation of fields and field arguments for [gra
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-validation</artifactId>
<version>16.0.0</version>
<version>17.0.0</version>
<type>pom</type>
</dependency>
```

```groovy
compile 'com.graphql-java:graphql-java-extended-validation:16.0.0'
compile 'com.graphql-java:graphql-java-extended-validation:17.0.0'
```

> Note:
Expand All @@ -36,8 +36,10 @@ compile 'com.graphql-java:graphql-java-extended-validation:16.0.0'
> use 15.0.1 or above for graphql-java 15.x and above
>
> use 16.0.0 or above for graphql-java 16.x and above
>
> use 17.0.0 or above for graphql-java 17.x and above

Its currently available from JCenter repo and Maven central.
It's currently available from Maven central.


# SDL @Directive constraints
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import java.text.SimpleDateFormat

plugins {
id 'java'
id 'groovy'
id 'java-library'
id 'maven'
id 'maven-publish'
Expand Down Expand Up @@ -39,8 +40,9 @@ repositories {


dependencies {
compile "com.graphql-java:graphql-java:16.2"
compile "org.hibernate.validator:hibernate-validator:6.2.0.Final"
compile "com.graphql-java:graphql-java:17.0-beta1"
compile "com.graphql-java:graphql-java-extended-scalars:17.0-beta1"
compile "org.hibernate.validator:hibernate-validator:7.0.1.Final"
compile "org.glassfish:jakarta.el:4.0.0"

testCompile 'org.slf4j:slf4j-simple:1.7.31'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ protected int getIntArg(GraphQLDirective directive, String argName) {
if (argument == null) {
return assertExpectedArgType(argName, "Int");
}
Number value = (Number) argument.getValue();

Number value = GraphQLArgument.getArgumentValue(argument);
if (value == null) {
value = (Number) argument.getDefaultValue();
value = GraphQLArgument.getArgumentDefaultValue(argument);
if (value == null) {
return assertExpectedArgType(argName, "Int");
}
Expand All @@ -216,9 +217,9 @@ protected String getStrArg(GraphQLDirective directive, String argName) {
if (argument == null) {
return assertExpectedArgType(argName, "String");
}
String value = (String) argument.getValue();
String value = GraphQLArgument.getArgumentValue(argument);
if (value == null) {
value = (String) argument.getDefaultValue();
value = GraphQLArgument.getArgumentDefaultValue(argument);
if (value == null) {
return assertExpectedArgType(argName, "String");
}
Expand All @@ -239,9 +240,9 @@ protected boolean getBoolArg(GraphQLDirective directive, String argName) {
if (argument == null) {
return assertExpectedArgType(argName, "Boolean");
}
Object value = argument.getValue();
Object value = GraphQLArgument.getArgumentValue(argument);
if (value == null) {
value = argument.getDefaultValue();
value = GraphQLArgument.getArgumentDefaultValue(argument);
if (value == null) {
return assertExpectedArgType(argName, "Boolean");
}
Expand All @@ -261,9 +262,9 @@ protected String getMessageTemplate(GraphQLDirective directive) {
String msg = null;
GraphQLArgument arg = directive.getArgument("message");
if (arg != null) {
msg = (String) arg.getValue();
msg = GraphQLArgument.getArgumentValue(arg);
if (msg == null) {
msg = (String) arg.getDefaultValue();
msg = GraphQLArgument.getArgumentDefaultValue(arg);
}
}
if (msg == null) {
Expand Down Expand Up @@ -316,7 +317,7 @@ protected List<GraphQLError> mkError(ValidationEnvironment validationEnvironment
*/
protected boolean isStringOrIDOrList(GraphQLInputType inputType) {
return isStringOrID(inputType) ||
isList(inputType);
isList(inputType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.GraphQLError;
import graphql.Scalars;
import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLScalarType;
Expand All @@ -24,24 +25,24 @@ public AbstractDecimalMinMaxConstraint(String name) {
public boolean appliesToType(GraphQLInputType inputType) {
return isOneOfTheseTypes(inputType,
Scalars.GraphQLString, // note we allow strings
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat
);
}

public List<String> getApplicableTypeNames() {
return Stream.of(Scalars.GraphQLString, // note we allow strings
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat)
.map(GraphQLScalarType::getName)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.GraphQLError;
import graphql.Scalars;
import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLScalarType;
Expand All @@ -24,23 +25,23 @@ public AbstractMinMaxConstraint(String name) {
@Override
public boolean appliesToType(GraphQLInputType inputType) {
return isOneOfTheseTypes(inputType,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat
);
}

public List<String> getApplicableTypeNames() {
return Stream.of(Scalars.GraphQLByte,
Scalars.GraphQLShort,
return Stream.of(ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat)
.map(GraphQLScalarType::getName)
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.GraphQLError;
import graphql.Scalars;
import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLScalarType;
Expand All @@ -24,23 +25,23 @@ public AbstractPositiveNegativeConstraint(String name) {
@Override
public boolean appliesToType(GraphQLInputType inputType) {
return isOneOfTheseTypes(inputType,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat
);
}

public List<String> getApplicableTypeNames() {
return Stream.of(Scalars.GraphQLByte,
Scalars.GraphQLShort,
return Stream.of(ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat)
.map(GraphQLScalarType::getName)
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.GraphQLError;
import graphql.Scalars;
import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLScalarType;
Expand Down Expand Up @@ -32,12 +33,12 @@ public Documentation getDocumentation() {
.example("buyCar( carCost : Float @Digits(integer : 5, fraction : 2) : DriverDetails")

.applicableTypeNames(Stream.of(Scalars.GraphQLString,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat)
.map(GraphQLScalarType::getName)
.collect(toList()))
Expand All @@ -52,12 +53,12 @@ public Documentation getDocumentation() {
public boolean appliesToType(GraphQLInputType inputType) {
return isOneOfTheseTypes(inputType,
Scalars.GraphQLString,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.GraphQLError;
import graphql.Scalars;
import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLScalarType;
Expand Down Expand Up @@ -35,12 +36,12 @@ public Documentation getDocumentation() {
.example("driver( milesTravelled : Int @Range( min : 1000, max : 100000)) : DriverDetails")

.applicableTypeNames(Stream.of(GraphQLString,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat)
.map(GraphQLScalarType::getName)
.collect(toList()))
Expand All @@ -55,12 +56,12 @@ Integer.MAX_VALUE, getMessageTemplate())
public boolean appliesToType(GraphQLInputType inputType) {
return isOneOfTheseTypes(inputType,
GraphQLString,
Scalars.GraphQLByte,
Scalars.GraphQLShort,
ExtendedScalars.GraphQLByte,
ExtendedScalars.GraphQLShort,
Scalars.GraphQLInt,
Scalars.GraphQLLong,
Scalars.GraphQLBigDecimal,
Scalars.GraphQLBigInteger,
ExtendedScalars.GraphQLLong,
ExtendedScalars.GraphQLBigDecimal,
ExtendedScalars.GraphQLBigInteger,
Scalars.GraphQLFloat
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import java.util.MissingResourceException;
import java.util.Optional;
import java.util.ResourceBundle;
import javax.validation.Constraint;
import javax.validation.Path;
import javax.validation.Payload;
import jakarta.validation.Constraint;
import jakarta.validation.Path;
import jakarta.validation.Payload;
import org.hibernate.validator.internal.engine.MessageInterpolatorContext;
import org.hibernate.validator.internal.metadata.core.ConstraintHelper;
import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl;
Expand Down Expand Up @@ -160,7 +160,7 @@ private MessageInterpolatorContext buildHibernateContext(Map<String, Object> mes

return new MessageInterpolatorContext(
constraintDescriptor, validatedValue, rootBeanType,
propertyPath, messageParams, expressionVariables, ExpressionLanguageFeatureLevel.DEFAULT, true);
propertyPath, messageParams, expressionVariables, ExpressionLanguageFeatureLevel.BEAN_PROPERTIES, true);
}

private org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator hibernateInterpolator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<GraphQLError> runValidationRules(DataFetchingEnvironment env, Messag

List<GraphQLError> errors = new ArrayList<>();

GraphQLObjectType fieldContainer = env.getExecutionStepInfo().getFieldContainer();
GraphQLObjectType fieldContainer = env.getExecutionStepInfo().getObjectType();
GraphQLFieldDefinition fieldDefinition = env.getFieldDefinition();
ResultPath fieldPath = env.getExecutionStepInfo().getPath();
//
Expand Down Expand Up @@ -162,8 +162,7 @@ private List<GraphQLError> walkObjectArg(ValidationRule rule, ValidationEnvironm
for (GraphQLInputObjectField inputField : fieldDefinitions) {

GraphQLInputType fieldType = inputField.getType();
List<GraphQLDirective> directives = inputField.getDirectives();
Object validatedValue = objectMap.getOrDefault(inputField.getName(), inputField.getDefaultValue());
Object validatedValue = objectMap.getOrDefault(inputField.getName(), GraphQLInputObjectField.getInputFieldDefaultValue(inputField));
if (validatedValue == null) {
continue;
}
Expand Down
Loading