Skip to content

Commit d779f85

Browse files
authored
Upgrading to graphql-java 17 and test running again (#47)
* Upgrading to graphql-java 17 and test running again * Upgrading to graphql-java 17 and test running again - read me update
1 parent 9e5f06b commit d779f85

11 files changed

+95
-80
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ This library provides extended validation of fields and field arguments for [gra
1818
<dependency>
1919
<groupId>com.graphql-java</groupId>
2020
<artifactId>graphql-java-extended-validation</artifactId>
21-
<version>16.0.0</version>
21+
<version>17.0.0</version>
2222
<type>pom</type>
2323
</dependency>
2424
```
2525

2626
```groovy
27-
compile 'com.graphql-java:graphql-java-extended-validation:16.0.0'
27+
compile 'com.graphql-java:graphql-java-extended-validation:17.0.0'
2828
```
2929

3030
> Note:
@@ -36,8 +36,10 @@ compile 'com.graphql-java:graphql-java-extended-validation:16.0.0'
3636
> use 15.0.1 or above for graphql-java 15.x and above
3737
>
3838
> use 16.0.0 or above for graphql-java 16.x and above
39+
>
40+
> use 17.0.0 or above for graphql-java 17.x and above
3941
40-
Its currently available from JCenter repo and Maven central.
42+
It's currently available from Maven central.
4143

4244

4345
# SDL @Directive constraints

build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import java.text.SimpleDateFormat
33

44
plugins {
55
id 'java'
6+
id 'groovy'
67
id 'java-library'
78
id 'maven'
89
id 'maven-publish'
@@ -39,8 +40,9 @@ repositories {
3940

4041

4142
dependencies {
42-
compile "com.graphql-java:graphql-java:16.2"
43-
compile "org.hibernate.validator:hibernate-validator:6.2.0.Final"
43+
compile "com.graphql-java:graphql-java:17.0-beta1"
44+
compile "com.graphql-java:graphql-java-extended-scalars:17.0-beta1"
45+
compile "org.hibernate.validator:hibernate-validator:7.0.1.Final"
4446
compile "org.glassfish:jakarta.el:4.0.0"
4547

4648
testCompile 'org.slf4j:slf4j-simple:1.7.31'

src/main/java/graphql/validation/constraints/AbstractDirectiveConstraint.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ protected int getIntArg(GraphQLDirective directive, String argName) {
193193
if (argument == null) {
194194
return assertExpectedArgType(argName, "Int");
195195
}
196-
Number value = (Number) argument.getValue();
196+
197+
Number value = GraphQLArgument.getArgumentValue(argument);
197198
if (value == null) {
198-
value = (Number) argument.getDefaultValue();
199+
value = GraphQLArgument.getArgumentDefaultValue(argument);
199200
if (value == null) {
200201
return assertExpectedArgType(argName, "Int");
201202
}
@@ -216,9 +217,9 @@ protected String getStrArg(GraphQLDirective directive, String argName) {
216217
if (argument == null) {
217218
return assertExpectedArgType(argName, "String");
218219
}
219-
String value = (String) argument.getValue();
220+
String value = GraphQLArgument.getArgumentValue(argument);
220221
if (value == null) {
221-
value = (String) argument.getDefaultValue();
222+
value = GraphQLArgument.getArgumentDefaultValue(argument);
222223
if (value == null) {
223224
return assertExpectedArgType(argName, "String");
224225
}
@@ -239,9 +240,9 @@ protected boolean getBoolArg(GraphQLDirective directive, String argName) {
239240
if (argument == null) {
240241
return assertExpectedArgType(argName, "Boolean");
241242
}
242-
Object value = argument.getValue();
243+
Object value = GraphQLArgument.getArgumentValue(argument);
243244
if (value == null) {
244-
value = argument.getDefaultValue();
245+
value = GraphQLArgument.getArgumentDefaultValue(argument);
245246
if (value == null) {
246247
return assertExpectedArgType(argName, "Boolean");
247248
}
@@ -261,9 +262,9 @@ protected String getMessageTemplate(GraphQLDirective directive) {
261262
String msg = null;
262263
GraphQLArgument arg = directive.getArgument("message");
263264
if (arg != null) {
264-
msg = (String) arg.getValue();
265+
msg = GraphQLArgument.getArgumentValue(arg);
265266
if (msg == null) {
266-
msg = (String) arg.getDefaultValue();
267+
msg = GraphQLArgument.getArgumentDefaultValue(arg);
267268
}
268269
}
269270
if (msg == null) {
@@ -316,7 +317,7 @@ protected List<GraphQLError> mkError(ValidationEnvironment validationEnvironment
316317
*/
317318
protected boolean isStringOrIDOrList(GraphQLInputType inputType) {
318319
return isStringOrID(inputType) ||
319-
isList(inputType);
320+
isList(inputType);
320321
}
321322

322323
/**

src/main/java/graphql/validation/constraints/standard/AbstractDecimalMinMaxConstraint.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import graphql.GraphQLError;
44
import graphql.Scalars;
5+
import graphql.scalars.ExtendedScalars;
56
import graphql.schema.GraphQLDirective;
67
import graphql.schema.GraphQLInputType;
78
import graphql.schema.GraphQLScalarType;
@@ -24,24 +25,24 @@ public AbstractDecimalMinMaxConstraint(String name) {
2425
public boolean appliesToType(GraphQLInputType inputType) {
2526
return isOneOfTheseTypes(inputType,
2627
Scalars.GraphQLString, // note we allow strings
27-
Scalars.GraphQLByte,
28-
Scalars.GraphQLShort,
28+
ExtendedScalars.GraphQLByte,
29+
ExtendedScalars.GraphQLShort,
2930
Scalars.GraphQLInt,
30-
Scalars.GraphQLLong,
31-
Scalars.GraphQLBigDecimal,
32-
Scalars.GraphQLBigInteger,
31+
ExtendedScalars.GraphQLLong,
32+
ExtendedScalars.GraphQLBigDecimal,
33+
ExtendedScalars.GraphQLBigInteger,
3334
Scalars.GraphQLFloat
3435
);
3536
}
3637

3738
public List<String> getApplicableTypeNames() {
3839
return Stream.of(Scalars.GraphQLString, // note we allow strings
39-
Scalars.GraphQLByte,
40-
Scalars.GraphQLShort,
40+
ExtendedScalars.GraphQLByte,
41+
ExtendedScalars.GraphQLShort,
4142
Scalars.GraphQLInt,
42-
Scalars.GraphQLLong,
43-
Scalars.GraphQLBigDecimal,
44-
Scalars.GraphQLBigInteger,
43+
ExtendedScalars.GraphQLLong,
44+
ExtendedScalars.GraphQLBigDecimal,
45+
ExtendedScalars.GraphQLBigInteger,
4546
Scalars.GraphQLFloat)
4647
.map(GraphQLScalarType::getName)
4748
.collect(Collectors.toList());

src/main/java/graphql/validation/constraints/standard/AbstractMinMaxConstraint.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import graphql.GraphQLError;
44
import graphql.Scalars;
5+
import graphql.scalars.ExtendedScalars;
56
import graphql.schema.GraphQLDirective;
67
import graphql.schema.GraphQLInputType;
78
import graphql.schema.GraphQLScalarType;
@@ -24,23 +25,23 @@ public AbstractMinMaxConstraint(String name) {
2425
@Override
2526
public boolean appliesToType(GraphQLInputType inputType) {
2627
return isOneOfTheseTypes(inputType,
27-
Scalars.GraphQLByte,
28-
Scalars.GraphQLShort,
28+
ExtendedScalars.GraphQLByte,
29+
ExtendedScalars.GraphQLShort,
2930
Scalars.GraphQLInt,
30-
Scalars.GraphQLLong,
31-
Scalars.GraphQLBigDecimal,
32-
Scalars.GraphQLBigInteger,
31+
ExtendedScalars.GraphQLLong,
32+
ExtendedScalars.GraphQLBigDecimal,
33+
ExtendedScalars.GraphQLBigInteger,
3334
Scalars.GraphQLFloat
3435
);
3536
}
3637

3738
public List<String> getApplicableTypeNames() {
38-
return Stream.of(Scalars.GraphQLByte,
39-
Scalars.GraphQLShort,
39+
return Stream.of(ExtendedScalars.GraphQLByte,
40+
ExtendedScalars.GraphQLShort,
4041
Scalars.GraphQLInt,
41-
Scalars.GraphQLLong,
42-
Scalars.GraphQLBigDecimal,
43-
Scalars.GraphQLBigInteger,
42+
ExtendedScalars.GraphQLLong,
43+
ExtendedScalars.GraphQLBigDecimal,
44+
ExtendedScalars.GraphQLBigInteger,
4445
Scalars.GraphQLFloat)
4546
.map(GraphQLScalarType::getName)
4647
.collect(toList());

src/main/java/graphql/validation/constraints/standard/AbstractPositiveNegativeConstraint.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import graphql.GraphQLError;
44
import graphql.Scalars;
5+
import graphql.scalars.ExtendedScalars;
56
import graphql.schema.GraphQLDirective;
67
import graphql.schema.GraphQLInputType;
78
import graphql.schema.GraphQLScalarType;
@@ -24,23 +25,23 @@ public AbstractPositiveNegativeConstraint(String name) {
2425
@Override
2526
public boolean appliesToType(GraphQLInputType inputType) {
2627
return isOneOfTheseTypes(inputType,
27-
Scalars.GraphQLByte,
28-
Scalars.GraphQLShort,
28+
ExtendedScalars.GraphQLByte,
29+
ExtendedScalars.GraphQLShort,
2930
Scalars.GraphQLInt,
30-
Scalars.GraphQLLong,
31-
Scalars.GraphQLBigDecimal,
32-
Scalars.GraphQLBigInteger,
31+
ExtendedScalars.GraphQLLong,
32+
ExtendedScalars.GraphQLBigDecimal,
33+
ExtendedScalars.GraphQLBigInteger,
3334
Scalars.GraphQLFloat
3435
);
3536
}
3637

3738
public List<String> getApplicableTypeNames() {
38-
return Stream.of(Scalars.GraphQLByte,
39-
Scalars.GraphQLShort,
39+
return Stream.of(ExtendedScalars.GraphQLByte,
40+
ExtendedScalars.GraphQLShort,
4041
Scalars.GraphQLInt,
41-
Scalars.GraphQLLong,
42-
Scalars.GraphQLBigDecimal,
43-
Scalars.GraphQLBigInteger,
42+
ExtendedScalars.GraphQLLong,
43+
ExtendedScalars.GraphQLBigDecimal,
44+
ExtendedScalars.GraphQLBigInteger,
4445
Scalars.GraphQLFloat)
4546
.map(GraphQLScalarType::getName)
4647
.collect(toList());

src/main/java/graphql/validation/constraints/standard/DigitsConstraint.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

3435
.applicableTypeNames(Stream.of(Scalars.GraphQLString,
35-
Scalars.GraphQLByte,
36-
Scalars.GraphQLShort,
36+
ExtendedScalars.GraphQLByte,
37+
ExtendedScalars.GraphQLShort,
3738
Scalars.GraphQLInt,
38-
Scalars.GraphQLLong,
39-
Scalars.GraphQLBigDecimal,
40-
Scalars.GraphQLBigInteger,
39+
ExtendedScalars.GraphQLLong,
40+
ExtendedScalars.GraphQLBigDecimal,
41+
ExtendedScalars.GraphQLBigInteger,
4142
Scalars.GraphQLFloat)
4243
.map(GraphQLScalarType::getName)
4344
.collect(toList()))
@@ -52,12 +53,12 @@ public Documentation getDocumentation() {
5253
public boolean appliesToType(GraphQLInputType inputType) {
5354
return isOneOfTheseTypes(inputType,
5455
Scalars.GraphQLString,
55-
Scalars.GraphQLByte,
56-
Scalars.GraphQLShort,
56+
ExtendedScalars.GraphQLByte,
57+
ExtendedScalars.GraphQLShort,
5758
Scalars.GraphQLInt,
58-
Scalars.GraphQLLong,
59-
Scalars.GraphQLBigDecimal,
60-
Scalars.GraphQLBigInteger,
59+
ExtendedScalars.GraphQLLong,
60+
ExtendedScalars.GraphQLBigDecimal,
61+
ExtendedScalars.GraphQLBigInteger,
6162
Scalars.GraphQLFloat
6263
);
6364
}

src/main/java/graphql/validation/constraints/standard/RangeConstraint.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import graphql.GraphQLError;
44
import graphql.Scalars;
5+
import graphql.scalars.ExtendedScalars;
56
import graphql.schema.GraphQLDirective;
67
import graphql.schema.GraphQLInputType;
78
import graphql.schema.GraphQLScalarType;
@@ -35,12 +36,12 @@ public Documentation getDocumentation() {
3536
.example("driver( milesTravelled : Int @Range( min : 1000, max : 100000)) : DriverDetails")
3637

3738
.applicableTypeNames(Stream.of(GraphQLString,
38-
Scalars.GraphQLByte,
39-
Scalars.GraphQLShort,
39+
ExtendedScalars.GraphQLByte,
40+
ExtendedScalars.GraphQLShort,
4041
Scalars.GraphQLInt,
41-
Scalars.GraphQLLong,
42-
Scalars.GraphQLBigDecimal,
43-
Scalars.GraphQLBigInteger,
42+
ExtendedScalars.GraphQLLong,
43+
ExtendedScalars.GraphQLBigDecimal,
44+
ExtendedScalars.GraphQLBigInteger,
4445
Scalars.GraphQLFloat)
4546
.map(GraphQLScalarType::getName)
4647
.collect(toList()))
@@ -55,12 +56,12 @@ Integer.MAX_VALUE, getMessageTemplate())
5556
public boolean appliesToType(GraphQLInputType inputType) {
5657
return isOneOfTheseTypes(inputType,
5758
GraphQLString,
58-
Scalars.GraphQLByte,
59-
Scalars.GraphQLShort,
59+
ExtendedScalars.GraphQLByte,
60+
ExtendedScalars.GraphQLShort,
6061
Scalars.GraphQLInt,
61-
Scalars.GraphQLLong,
62-
Scalars.GraphQLBigDecimal,
63-
Scalars.GraphQLBigInteger,
62+
ExtendedScalars.GraphQLLong,
63+
ExtendedScalars.GraphQLBigDecimal,
64+
ExtendedScalars.GraphQLBigInteger,
6465
Scalars.GraphQLFloat
6566
);
6667
}

src/main/java/graphql/validation/interpolation/ResourceBundleMessageInterpolator.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import java.util.MissingResourceException;
1616
import java.util.Optional;
1717
import java.util.ResourceBundle;
18-
import javax.validation.Constraint;
19-
import javax.validation.Path;
20-
import javax.validation.Payload;
18+
import jakarta.validation.Constraint;
19+
import jakarta.validation.Path;
20+
import jakarta.validation.Payload;
2121
import org.hibernate.validator.internal.engine.MessageInterpolatorContext;
2222
import org.hibernate.validator.internal.metadata.core.ConstraintHelper;
2323
import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl;
@@ -160,7 +160,7 @@ private MessageInterpolatorContext buildHibernateContext(Map<String, Object> mes
160160

161161
return new MessageInterpolatorContext(
162162
constraintDescriptor, validatedValue, rootBeanType,
163-
propertyPath, messageParams, expressionVariables, ExpressionLanguageFeatureLevel.DEFAULT, true);
163+
propertyPath, messageParams, expressionVariables, ExpressionLanguageFeatureLevel.BEAN_PROPERTIES, true);
164164
}
165165

166166
private org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator hibernateInterpolator() {

src/main/java/graphql/validation/rules/TargetedValidationRules.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public List<GraphQLError> runValidationRules(DataFetchingEnvironment env, Messag
6969

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

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

164164
GraphQLInputType fieldType = inputField.getType();
165-
List<GraphQLDirective> directives = inputField.getDirectives();
166-
Object validatedValue = objectMap.getOrDefault(inputField.getName(), inputField.getDefaultValue());
165+
Object validatedValue = objectMap.getOrDefault(inputField.getName(), GraphQLInputObjectField.getInputFieldDefaultValue(inputField));
167166
if (validatedValue == null) {
168167
continue;
169168
}

0 commit comments

Comments
 (0)