Skip to content

Commit e348632

Browse files
cvolzkebbakerman
authored andcommitted
Extend the TypeFunction API to be more flexible (Issue #81) (#82)
* Extend the TypeFunction API to be more flexible (Issue #81) * Extend the TypeFunction API to be more flexible (Issue #81) - address review feedback
1 parent 84f426a commit e348632

File tree

10 files changed

+257
-167
lines changed

10 files changed

+257
-167
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ syntax for GraphQL schema definition.
1212

1313
```groovy
1414
dependencies {
15-
compile "com.graphql-java:graphql-java-annotations:0.14.0"
15+
compile "com.graphql-java:graphql-java-annotations:0.15.0"
1616
}
1717
```
1818

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 0.14.1
1+
version = 0.15.0
22
group = com.graphql-java

src/main/java/graphql/annotations/BatchedTypeFunction.java

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

17-
import graphql.schema.GraphQLList;
18-
1917
import java.lang.reflect.AnnotatedParameterizedType;
2018
import java.lang.reflect.AnnotatedType;
2119
import java.lang.reflect.ParameterizedType;
22-
import java.util.Collection;
2320
import java.util.List;
2421

2522
public class BatchedTypeFunction implements TypeFunction {
@@ -30,7 +27,17 @@ public BatchedTypeFunction(TypeFunction defaultTypeFunction) {
3027
}
3128

3229
@Override
33-
public graphql.schema.GraphQLType apply(Class<?> aClass, AnnotatedType annotatedType) {
30+
public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) {
31+
return defaultTypeFunction.getTypeName(aClass, annotatedType);
32+
}
33+
34+
@Override
35+
public boolean canBuildType(final Class<?> aClass, final AnnotatedType type) {
36+
return defaultTypeFunction.canBuildType(aClass, type);
37+
}
38+
39+
@Override
40+
public graphql.schema.GraphQLType buildType(final String typeName, final Class<?> aClass, final AnnotatedType annotatedType) {
3441
if (!aClass.isAssignableFrom(List.class)) {
3542
throw new IllegalArgumentException("Batched method should return a List");
3643
}
@@ -45,10 +52,6 @@ public graphql.schema.GraphQLType apply(Class<?> aClass, AnnotatedType annotated
4552
} else {
4653
klass = (Class<?>) arg.getType();
4754
}
48-
return defaultTypeFunction.apply(klass, arg);
49-
}
50-
51-
@Override public Collection<Class<?>> getAcceptedTypes() {
52-
return defaultTypeFunction.getAcceptedTypes();
55+
return defaultTypeFunction.buildType(typeName, klass, arg);
5356
}
5457
}

0 commit comments

Comments
 (0)