Skip to content

Commit 44ab83c

Browse files
authored
Merge pull request #291 from anatol-sialitski/master
Bump version graphql-java from 17.2 to 20.3
2 parents 9090887 + 69e340e commit 44ab83c

13 files changed

+123
-68
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ gradle.projectsEvaluated {
5454

5555
dependencies {
5656
compile 'javax.validation:validation-api:1.1.0.Final'
57-
compile 'com.graphql-java:graphql-java:17.4'
58-
compile 'com.graphql-java:graphql-java-extended-scalars:17.0'
59-
57+
compile 'com.graphql-java:graphql-java:20.4'
58+
compile 'com.graphql-java:graphql-java-extended-scalars:20.2'
59+
compile 'javax.xml.bind:jaxb-api:2.3.1'
6060

6161
// OSGi
6262
compileOnly 'org.osgi:org.osgi.core:6.0.0'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ org.gradle.daemon=true
55
org.gradle.parallel=true
66
org.gradle.jvmargs=-Dfile.encoding=UTF-8
77

8-
version = 9.1
8+
version = 20.3

src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
*/
1515
package graphql.annotations.processor.retrievers.fieldBuilders;
1616

17+
import java.lang.annotation.Annotation;
18+
import java.lang.reflect.AnnotatedElement;
19+
import java.lang.reflect.Method;
20+
import java.util.ArrayList;
21+
import java.util.Arrays;
22+
import java.util.List;
23+
import java.util.stream.Collectors;
24+
1725
import graphql.annotations.annotationTypes.directives.activation.GraphQLDirectives;
1826
import graphql.annotations.processor.ProcessingElementsContainer;
1927
import graphql.annotations.processor.exceptions.GraphQLAnnotationsException;
@@ -23,14 +31,6 @@
2331
import graphql.schema.GraphQLScalarType;
2432
import graphql.schema.GraphQLType;
2533

26-
import java.lang.annotation.Annotation;
27-
import java.lang.reflect.AnnotatedElement;
28-
import java.lang.reflect.Method;
29-
import java.util.ArrayList;
30-
import java.util.Arrays;
31-
import java.util.List;
32-
import java.util.stream.Collectors;
33-
3434
import static graphql.schema.GraphQLDirective.newDirective;
3535

3636

@@ -133,13 +133,15 @@ private void transformArgument(Annotation annotation, GraphQLDirective.Builder d
133133
methods[finalI].setAccessible(true);
134134
Object argumentValue = methods[finalI].invoke(annotation);
135135
Object value;
136-
if (graphQLArgument.getType() instanceof GraphQLScalarType) {
136+
if ( graphQLArgument.getType() instanceof GraphQLScalarType )
137+
{
137138
value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue);
138139
}
139-
else{
140+
else
141+
{
140142
value = argumentValue;
141143
}
142-
builder.value(value);
144+
builder.value( value );
143145
} catch (Exception e) {
144146
throw new GraphQLAnnotationsException(COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE, e);
145147
}
@@ -160,7 +162,7 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
160162

161163
try {
162164
Object value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue);
163-
builder.value(value);
165+
builder.value( value );
164166
} catch (Exception e) {
165167
throw new GraphQLAnnotationsException(COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE, e);
166168
}

src/test/java/graphql/annotations/GraphQLDataFetcherTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import graphql.annotations.processor.GraphQLAnnotations;
2323
import graphql.schema.DataFetcher;
2424
import graphql.schema.DataFetchingEnvironment;
25+
import graphql.schema.GraphQLFieldDefinition;
2526
import graphql.schema.GraphQLSchema;
2627
import graphql.schema.PropertyDataFetcher;
2728
import org.testng.annotations.BeforeMethod;
2829
import org.testng.annotations.Test;
2930

3031
import java.util.HashMap;
32+
import java.util.function.Supplier;
3133

3234
import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema;
3335
import static org.testng.Assert.*;
@@ -161,8 +163,10 @@ public SampleMultiArgDataFetcher(String target, String flip) {
161163
}
162164

163165
@Override
164-
public Object get(DataFetchingEnvironment environment) {
165-
final Object result = super.get(environment);
166+
public Object get( final GraphQLFieldDefinition fieldDefinition, final Object source, final Supplier supplier )
167+
throws Exception
168+
{
169+
final Object result = super.get( fieldDefinition, source, supplier );
166170
if (flip) {
167171
return !(Boolean) result;
168172
} else {

src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public void queryNameWithFalse_directivesProvidedToRegistry_wiringIsActivated()
225225
this.graphQLAnnotations.getContainer().getDirectiveRegistry().put(upperCase.getName(), new DirectiveAndWiring(upperCase, UpperWiring.class));
226226
GraphQLObjectType object = this.graphQLAnnotations.object(Query.class);
227227
GraphQLCodeRegistry codeRegistry = graphQLAnnotations.getContainer().getCodeRegistryBuilder().build();
228-
GraphQLSchema schema = newSchema().query(object).codeRegistry(codeRegistry).build();
228+
GraphQLSchema schema = newSchema().query(object).codeRegistry(codeRegistry).additionalDirective( upperCase ).build();
229229

230230
ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("query { nameWithFalse }");
231231
assertTrue(result.getErrors().isEmpty());

src/test/java/graphql/annotations/GraphQLExtensionsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public void fields() {
117117
public void values() {
118118
GraphQLSchema schema = newAnnotationsSchema().query(TestObject.class).typeExtension(TestObjectExtension.class).build();
119119

120-
ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field field2 field3 field4 field5}", new GraphQLExtensionsTest.TestObject());
120+
ExecutionResult result = GraphQL.newGraphQL( schema ).build().execute(
121+
GraphQLHelper.createExecutionInput( "{field field2 field3 field4 field5}", new GraphQLExtensionsTest.TestObject() ) );
121122
Map<String, Object> data = result.getData();
122123
assertEquals(data.get("field"), "test");
123124
assertEquals(data.get("field2"), "test test2");

src/test/java/graphql/annotations/GraphQLFragmentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testInterfaceInlineFragment() throws Exception {
6565
GraphQL graphQL2 = GraphQL.newGraphQL(schema).build();
6666

6767
// When
68-
ExecutionResult graphQLResult = graphQL2.execute("{getItems { ... on MyObject {getA, getMy {getB}} ... on MyObject2 {getA, getB} }}", new RootObject());
68+
ExecutionResult graphQLResult = graphQL2.execute(GraphQLHelper.createExecutionInput("{getItems { ... on MyObject {getA, getMy {getB}} ... on MyObject2 {getA, getB} }}", new RootObject()));
6969
Set resultMap = ((Map) graphQLResult.getData()).entrySet();
7070

7171
// Then
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations;
16+
17+
import java.util.Map;
18+
19+
import graphql.ExecutionInput;
20+
21+
public class GraphQLHelper
22+
{
23+
public static ExecutionInput createExecutionInput( String query, Object context, Map<String, Object> variables )
24+
{
25+
ExecutionInput.Builder builder = ExecutionInput.newExecutionInput().query( query ).root( context );
26+
if ( variables != null )
27+
{
28+
builder.variables( variables );
29+
}
30+
return builder.build();
31+
}
32+
33+
public static ExecutionInput createExecutionInput( String query, Object context )
34+
{
35+
return createExecutionInput( query, context, null );
36+
}
37+
}

src/test/java/graphql/annotations/GraphQLInputTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void query() {
186186
.additionalType(TestObject.class).build();
187187

188188
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
189-
ExecutionResult result = graphQL.execute("{ object { value(input:{key:\"test\"}) } }", new Query());
189+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{key:\"test\"}) } }", new Query()));
190190
assertTrue(result.getErrors().isEmpty());
191191
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "testa");
192192
}
@@ -196,7 +196,7 @@ public void queryMultipleDefinitions() {
196196
GraphQLSchema schema = newAnnotationsSchema().query(QueryMultipleDefinitions.class).build();
197197

198198
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
199-
ExecutionResult result = graphQL.execute("{ something(code: {firstField:\"a\",secondField:\"b\"}) somethingElse(code: {firstField:\"c\",secondField:\"d\"}) }", new QueryMultipleDefinitions());
199+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ something(code: {firstField:\"a\",secondField:\"b\"}) somethingElse(code: {firstField:\"c\",secondField:\"d\"}) }", new QueryMultipleDefinitions()));
200200
assertTrue(result.getErrors().isEmpty());
201201
assertEquals(((Map<String, String>) result.getData()).get("something"), "ab");
202202
assertEquals(((Map<String, String>) result.getData()).get("somethingElse"), "cd");
@@ -207,11 +207,11 @@ public void queryWithRecursion() {
207207
GraphQLSchema schema = newAnnotationsSchema().query(QueryRecursion.class).build();
208208

209209
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
210-
ExecutionResult result = graphQL.execute("{ object { value(input:{key:\"test\"}) } }", new QueryRecursion());
210+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{key:\"test\"}) } }", new QueryRecursion()));
211211
assertTrue(result.getErrors().isEmpty());
212212
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "testa");
213213

214-
result = graphQL.execute("{ object { value(input:{rec:{key:\"test\"}}) } }", new QueryRecursion());
214+
result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{rec:{key:\"test\"}}) } }", new QueryRecursion()));
215215
assertTrue(result.getErrors().isEmpty());
216216
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "rectesta");
217217
}
@@ -221,7 +221,7 @@ public void queryWithList() {
221221
GraphQLSchema schema = newAnnotationsSchema().query(QueryList.class).build();
222222

223223
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
224-
ExecutionResult result = graphQL.execute("{ object { value(input:[[[{key:\"test\", complex:[{subKey:\"subtest\"},{subKey:\"subtest2\"}]}]]]) } }", new QueryList());
224+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:[[[{key:\"test\", complex:[{subKey:\"subtest\"},{subKey:\"subtest2\"}]}]]]) } }", new QueryList()));
225225
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "test-subtest");
226226
}
227227

@@ -230,7 +230,7 @@ public void queryWithInterface() {
230230
GraphQLSchema schema = newAnnotationsSchema().query(QueryIface.class).additionalType(TestObject.class).build();
231231

232232
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
233-
ExecutionResult result = graphQL.execute("{ iface { value(input:{key:\"test\"}) } }", new QueryIface());
233+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ iface { value(input:{key:\"test\"}) } }", new QueryIface()));
234234
assertTrue(result.getErrors().isEmpty());
235235
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("iface").get("value"), "testa");
236236
}

src/test/java/graphql/annotations/GraphQLInterfaceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void queryUnion() {
170170
GraphQLSchema schema = newAnnotationsSchema().query(UnionQuery.class).build();
171171

172172
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
173-
ExecutionResult result = graphQL.execute("{ union { ... on TestObject1 { value } } }", new UnionQuery(new TestObject1()));
173+
ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ union { ... on TestObject1 { value } } }", new UnionQuery(new TestObject1())));
174174
assertTrue(result.getErrors().isEmpty());
175175
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("union").get("value"), "a");
176176
}

0 commit comments

Comments
 (0)