diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 51d9e491..55e9f135 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,12 +3,11 @@
name: Build
-on: [push]
+on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
- environment: prod
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
@@ -20,8 +19,6 @@ jobs:
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- - name: Test with Gradle
- run: ./gradlew test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
if: always() # always run even if the previous step fails
diff --git a/README.md b/README.md
index 4cc4c17c..a37b826c 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ If you would like to use a tool that creates a graphql spring boot server using
```groovy
dependencies {
- compile "io.github.graphql-java:graphql-java-annotations:8.5"
+ compile "io.github.graphql-java:graphql-java-annotations:9.0"
}
```
@@ -47,7 +47,7 @@ dependencies {
io.github.graphql-java
graphql-java-annotations
- 8.5
+ 9.0
```
diff --git a/build.gradle b/build.gradle
index 6d05adea..caaef010 100644
--- a/build.gradle
+++ b/build.gradle
@@ -54,7 +54,9 @@ gradle.projectsEvaluated {
dependencies {
compile 'javax.validation:validation-api:1.1.0.Final'
- compile 'com.graphql-java:graphql-java:16.2'
+ compile 'com.graphql-java:graphql-java:17.1'
+ compile 'com.graphql-java:graphql-java-extended-scalars:17.0'
+
// OSGi
compileOnly 'org.osgi:org.osgi.core:6.0.0'
diff --git a/gradle.properties b/gradle.properties
index 103bfc28..a7c04cdc 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,4 +5,4 @@ org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8
-version = 8.5
+version = 9.0
diff --git a/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java b/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java
deleted file mode 100644
index e3c20fdf..00000000
--- a/src/main/java/graphql/annotations/annotationTypes/GraphQLBatched.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright 2016 Yurii Rashkovskii
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- */
-package graphql.annotations.annotationTypes;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface GraphQLBatched {
-}
diff --git a/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java b/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java
deleted file mode 100644
index 5f4c3a89..00000000
--- a/src/main/java/graphql/annotations/dataFetchers/BatchedMethodDataFetcher.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2016 Yurii Rashkovskii
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- */
-package graphql.annotations.dataFetchers;
-
-import graphql.annotations.processor.ProcessingElementsContainer;
-import graphql.annotations.processor.typeFunctions.TypeFunction;
-import graphql.execution.batched.Batched;
-import graphql.schema.DataFetchingEnvironment;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-public class BatchedMethodDataFetcher extends MethodDataFetcher {
-
-
- public BatchedMethodDataFetcher(Method method, TypeFunction typeFunction, ProcessingElementsContainer container) {
- super(method,typeFunction, container);
- if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Batched method should be static");
- }
- }
-
- @Batched
- @Override
- public Object get(DataFetchingEnvironment environment) {
- return super.get(environment);
- }
-}
diff --git a/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java b/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java
index 7ba39f7d..5a756662 100644
--- a/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java
+++ b/src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java
@@ -12,7 +12,6 @@
*/
package graphql.annotations.dataFetchers;
-import graphql.annotations.annotationTypes.GraphQLBatched;
import graphql.annotations.annotationTypes.GraphQLConstructor;
import graphql.annotations.annotationTypes.GraphQLInvokeDetached;
import graphql.annotations.annotationTypes.GraphQLName;
@@ -69,7 +68,7 @@ public T get(DataFetchingEnvironment environment) {
T obj;
if (Modifier.isStatic(method.getModifiers())) {
return (T) method.invoke(null, invocationArgs(environment, container));
- } else if (method.isAnnotationPresent(GraphQLBatched.class) || method.isAnnotationPresent(GraphQLInvokeDetached.class)) {
+ } else if (method.isAnnotationPresent(GraphQLInvokeDetached.class)) {
obj = newInstance((Class) method.getDeclaringClass());
} else if (!method.getDeclaringClass().isInstance(environment.getSource())) {
obj = newInstance((Class) method.getDeclaringClass(), environment.getSource());
diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java
index 1f94f6a3..0082f5f5 100644
--- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java
+++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java
@@ -97,7 +97,7 @@ private GraphQLDirective transformArgs(GraphQLDirective graphQLDirective, Annota
for (int i = annotation.annotationType().getDeclaredMethods().length; i < arguments.size(); i++) {
int finalI = i;
- directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getDefaultValue())));
+ directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getArgumentDefaultValue().getValue())));
}
return directiveBuilder.build();
}
@@ -118,7 +118,7 @@ private GraphQLDirective transformArgs(GraphQLDirective graphQLDirective, String
for (int i = argumentValues.length; i < arguments.size(); i++) {
int finalI = i;
- directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getDefaultValue())));
+ directiveBuilder.argument(arguments.get(i).transform(builder -> builder.value(arguments.get(finalI).getArgumentDefaultValue().getValue())));
}
return directiveBuilder.build();
}
diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java
index 348266f1..ee40d9fb 100644
--- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java
+++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodDataFetcherBuilder.java
@@ -14,11 +14,9 @@
*/
package graphql.annotations.processor.retrievers.fieldBuilders.method;
-import graphql.annotations.annotationTypes.GraphQLBatched;
import graphql.annotations.annotationTypes.GraphQLDataFetcher;
import graphql.annotations.annotationTypes.GraphQLRelayMutation;
import graphql.annotations.connection.GraphQLConnection;
-import graphql.annotations.dataFetchers.BatchedMethodDataFetcher;
import graphql.annotations.dataFetchers.MethodDataFetcher;
import graphql.annotations.dataFetchers.RelayMutationMethodDataFetcher;
import graphql.annotations.processor.ProcessingElementsContainer;
@@ -62,9 +60,7 @@ public MethodDataFetcherBuilder(Method method, GraphQLOutputType outputType, Typ
public DataFetcher build() {
GraphQLDataFetcher dataFetcher = method.getAnnotation(GraphQLDataFetcher.class);
DataFetcher actualDataFetcher;
- if (dataFetcher == null && method.getAnnotation(GraphQLBatched.class) != null) {
- actualDataFetcher = new BatchedMethodDataFetcher(method, typeFunction, container);
- } else if (dataFetcher == null) {
+ if (dataFetcher == null) {
actualDataFetcher = new MethodDataFetcher(method, typeFunction, container);
} else {
actualDataFetcher = dataFetcherConstructor.constructDataFetcher(method.getName(), dataFetcher);
diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java
index ebdae92f..b81cf599 100644
--- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java
+++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/method/MethodTypeBuilder.java
@@ -14,10 +14,8 @@
*/
package graphql.annotations.processor.retrievers.fieldBuilders.method;
-import graphql.annotations.annotationTypes.GraphQLBatched;
import graphql.annotations.processor.ProcessingElementsContainer;
import graphql.annotations.processor.retrievers.fieldBuilders.Builder;
-import graphql.annotations.processor.typeFunctions.BatchedTypeFunction;
import graphql.annotations.processor.typeFunctions.TypeFunction;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
@@ -42,14 +40,7 @@ public MethodTypeBuilder(Method method, TypeFunction typeFunction, ProcessingEle
public GraphQLType build() {
AnnotatedType annotatedReturnType = method.getAnnotatedReturnType();
- TypeFunction typeFunction;
- if (method.getAnnotation(GraphQLBatched.class) != null) {
- typeFunction = new BatchedTypeFunction(this.typeFunction);
- } else {
- typeFunction = this.typeFunction;
- }
-
- return typeFunction.buildType(isInput,method.getReturnType(), annotatedReturnType, container);
+ return this.typeFunction.buildType(isInput,method.getReturnType(), annotatedReturnType, container);
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java
deleted file mode 100644
index 2733de72..00000000
--- a/src/main/java/graphql/annotations/processor/typeFunctions/BatchedTypeFunction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright 2016 Yurii Rashkovskii
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- */
-package graphql.annotations.processor.typeFunctions;
-
-import graphql.annotations.processor.ProcessingElementsContainer;
-import graphql.schema.GraphQLType;
-
-import java.lang.reflect.AnnotatedParameterizedType;
-import java.lang.reflect.AnnotatedType;
-import java.lang.reflect.ParameterizedType;
-import java.util.List;
-
-public class BatchedTypeFunction implements TypeFunction {
- private TypeFunction defaultTypeFunction;
-
- public BatchedTypeFunction(TypeFunction defaultTypeFunction) {
- this.defaultTypeFunction = defaultTypeFunction;
- }
-
- @Override
- public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return defaultTypeFunction.getTypeName(aClass, annotatedType);
- }
-
- @Override
- public boolean canBuildType(final Class> aClass, final AnnotatedType type) {
- return defaultTypeFunction.canBuildType(aClass, type);
- }
-
- @Override
- public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) {
- if (!aClass.isAssignableFrom(List.class)) {
- throw new IllegalArgumentException("Batched method should return a List");
- }
- if (!(annotatedType instanceof AnnotatedParameterizedType)) {
- throw new IllegalArgumentException("Batched should return parameterized type");
- }
- AnnotatedParameterizedType parameterizedType = (AnnotatedParameterizedType) annotatedType;
- AnnotatedType arg = parameterizedType.getAnnotatedActualTypeArguments()[0];
- Class> klass;
- if (arg.getType() instanceof ParameterizedType) {
- klass = (Class>) ((ParameterizedType) (arg.getType())).getRawType();
- } else {
- klass = (Class>) arg.getType();
- }
- return defaultTypeFunction.buildType(input, klass, arg,container);
- }
-}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java
index e5e3f730..87ff183e 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/BigDecimalFunction.java
@@ -14,17 +14,16 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
import java.math.BigDecimal;
public class BigDecimalFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLBigDecimal.getName();
+ return ExtendedScalars.GraphQLBigDecimal.getName();
}
@Override
@@ -38,6 +37,6 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLBigDecimal;
+ return ExtendedScalars.GraphQLBigDecimal;
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java
index 34cc2d11..73ffb37a 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/BigIntegerFunction.java
@@ -14,17 +14,16 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
import java.math.BigInteger;
public class BigIntegerFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLBigInteger.getName();
+ return ExtendedScalars.GraphQLBigInteger.getName();
}
@Override
@@ -38,6 +37,6 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLBigInteger;
+ return ExtendedScalars.GraphQLBigInteger;
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java
index 2a58473f..1eecd33a 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/ByteFunction.java
@@ -14,16 +14,15 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
public class ByteFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLByte.getName();
+ return ExtendedScalars.GraphQLByte.getName();
}
@Override
@@ -37,6 +36,6 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLByte;
+ return ExtendedScalars.GraphQLByte;
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java
index ba2ebb1c..664521e2 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/CharFunction.java
@@ -14,17 +14,16 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
public class CharFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLChar.getName();
+ return ExtendedScalars.GraphQLChar.getName();
}
@Override
@@ -38,6 +37,6 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLChar;
+ return ExtendedScalars.GraphQLChar;
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java
index 06618c46..ed92f6f4 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/LongFunction.java
@@ -14,10 +14,9 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
@@ -25,7 +24,7 @@ class LongFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLLong.getName();
+ return ExtendedScalars.GraphQLLong.getName();
}
@Override
@@ -39,7 +38,7 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLLong;
+ return ExtendedScalars.GraphQLLong;
}
}
diff --git a/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java b/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java
index 9f608c64..4582c631 100644
--- a/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java
+++ b/src/main/java/graphql/annotations/processor/typeFunctions/ShortFunction.java
@@ -14,16 +14,15 @@
*/
package graphql.annotations.processor.typeFunctions;
-import graphql.Scalars;
import graphql.annotations.processor.ProcessingElementsContainer;
+import graphql.scalars.ExtendedScalars;
import graphql.schema.GraphQLType;
-
import java.lang.reflect.AnnotatedType;
public class ShortFunction implements TypeFunction {
@Override
public String getTypeName(Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLShort.getName();
+ return ExtendedScalars.GraphQLShort.getName();
}
@Override
@@ -37,7 +36,7 @@ public GraphQLType buildType(boolean input, Class> aClass, AnnotatedType annot
}
private GraphQLType buildType(boolean inputType, Class> aClass, AnnotatedType annotatedType) {
- return Scalars.GraphQLShort;
+ return ExtendedScalars.GraphQLShort;
}
}
diff --git a/src/test/java/graphql/annotations/GraphQLBatchedTest.java b/src/test/java/graphql/annotations/GraphQLBatchedTest.java
deleted file mode 100644
index 213b6f18..00000000
--- a/src/test/java/graphql/annotations/GraphQLBatchedTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Copyright 2016 Yurii Rashkovskii
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- */
-package graphql.annotations;
-
-import graphql.ExceptionWhileDataFetching;
-import graphql.ExecutionResult;
-import graphql.GraphQL;
-import graphql.annotations.annotationTypes.GraphQLBatched;
-import graphql.annotations.annotationTypes.GraphQLField;
-import graphql.annotations.processor.GraphQLAnnotations;
-import graphql.execution.batched.BatchedExecutionStrategy;
-import graphql.schema.GraphQLObjectType;
-import graphql.schema.GraphQLSchema;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import static graphql.Scalars.GraphQLString;
-import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-@SuppressWarnings("unchecked")
-public class GraphQLBatchedTest {
-
- private GraphQLAnnotations graphQLAnnotations;
-
- @BeforeMethod
- public void init() {
- this.graphQLAnnotations = new GraphQLAnnotations();
- }
-
- public static class SimpleBatchedField {
- @GraphQLField
- @GraphQLBatched
- public static List a() {
- return Arrays.asList("one", "two");
- }
- }
-
- public static class TestBatchedObject {
- @GraphQLField
- public List fields() {
- return Arrays.asList(new SimpleBatchedField(), new SimpleBatchedField());
- }
- }
-
- @Test
- public void batchedDataFetcher() throws Throwable {
- GraphQLObjectType nestedObject = this.graphQLAnnotations.object(SimpleBatchedField.class);
- assertEquals(nestedObject.getFieldDefinition("a").getType(), GraphQLString);
-
- GraphQLSchema schema = newAnnotationsSchema().query(TestBatchedObject.class).build();
- GraphQL graphql = GraphQL.newGraphQL(schema).queryExecutionStrategy(new BatchedExecutionStrategy()).build();
- ExecutionResult result = graphql.execute("{ fields { a } }", new TestBatchedObject());
- List errors = result.getErrors();
- for (Object e : errors) {
- throw ((ExceptionWhileDataFetching) e).getException();
- }
- assertTrue(result.getErrors().isEmpty());
- Map data = (Map) result.getData();
- List