Skip to content

Commit 90e8b79

Browse files
author
Thomas Draier
committed
Relay connections : support recursive and interfaces connection, pass arguments to DataFetcher
1 parent 32df1c8 commit 90e8b79

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/graphql/annotations/GraphQLAnnotations.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,10 @@ private GraphQLOutputType getGraphQLConnection(boolean isConnection, AccessibleO
511511
private boolean isConnection(AccessibleObject obj, Class<?> klass, GraphQLOutputType type) {
512512
return obj.isAnnotationPresent(GraphQLConnection.class) &&
513513
type instanceof GraphQLList &&
514-
((GraphQLList) type).getWrappedType() instanceof GraphQLObjectType;
514+
(((GraphQLList) type).getWrappedType() instanceof GraphQLObjectType ||
515+
((GraphQLList) type).getWrappedType() instanceof GraphQLInterfaceType ||
516+
((GraphQLList) type).getWrappedType() instanceof GraphQLUnionType ||
517+
((GraphQLList) type).getWrappedType() instanceof GraphQLTypeReference);
515518
}
516519

517520
protected GraphQLFieldDefinition getField(Method method) throws GraphQLAnnotationsException {
@@ -708,7 +711,9 @@ public ConnectionDataFetcher(Class<? extends Connection> connection, DataFetcher
708711
@Override
709712
public Object get(DataFetchingEnvironment environment) {
710713
// Exclude arguments
711-
DataFetchingEnvironment env = new DataFetchingEnvironmentImpl(environment.getSource(), new HashMap<>(), environment.getContext(),
714+
HashMap<String, Object> arguments = new HashMap<>(environment.getArguments());
715+
arguments.keySet().removeAll(Arrays.asList("first", "last", "before", "after"));
716+
DataFetchingEnvironment env = new DataFetchingEnvironmentImpl(environment.getSource(), arguments, environment.getContext(),
712717
environment.getFields(), environment.getFieldType(), environment.getParentType(), environment.getGraphQLSchema(),
713718
environment.getFragmentsByName(), environment.getExecutionId(), environment.getSelectionSet());
714719
Connection conn = constructNewInstance(constructor, actualDataFetcher.get(env));

0 commit comments

Comments
 (0)