Reputation: 399
My goal is to define a paginated schema using connections (cursor, edges, etc.), but I have a problem with nested collections...
I'm using spring-boot v2.7.12 (without graphql starter - this version doesnt support directives *Connections) and graphql-java-kickstart (tools and also spring-boot-starter)
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>13.0.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>14.0.0</version>
</dependency>
schema.graphqls
type Container{
name:String
}
type Guide{
name: String
containers(first: Int, after: String): ContainerConnection @connection(for: "Container")
}
type Query {
guides:[Guide]
}
GuideController
@Controller
@RequiredArgsConstructor
public class GuideController implements GraphQLQueryResolver {
private final GuideRepository guideRepository;
List<Guide> guides() {
return ....
}
}
ContainerController
@Controller
@RequiredArgsConstructor
public class ContainerController implements GraphQLQueryResolver {
private final ContainerRepository containerRepository;
public Connection<Container> containers(Integer first, String after, DataFetchingEnvironment env) {
return ....
}
}
When the application is starting I got error
Caused by: graphql.kickstart.tools.resolver.FieldResolverError: No method found as defined in schema <unknown>:7 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment, class graphql.GraphQLContext] as the last argument), in priority order:
guide.entity.Guide.containers(~first, ~after)
guide.entity.Guide.getContainers(~first, ~after)
at graphql.kickstart.tools.resolver.FieldResolverScanner.missingFieldResolver(FieldResolverScanner.kt:82) ~[graphql-java-tools-13.0.0.jar:?]
at graphql.kickstart.tools.resolver.FieldResolverScanner.findFieldResolver(FieldResolverScanner.kt:42) ~[graphql-java-tools-13.0.0.jar:?]
at graphql.kickstart.tools.SchemaClassScanner.scanResolverInfoForPotentialMatches(SchemaClassScanner.kt:273) ~[graphql-java-tools-13.0.0.jar:?]
Why the resolver mapping containers method from Guide entity not from Controller? How to do that?
When I tried simple mapping for Guide or Container pagination, everything is fine
type Guide{
name: String
}
type Query {
guides[(first: Int, after: String) : GuideConnection @connection(for: "Guide")]
guide(id: Int) : Guide
}
public Connection<Guide> guides(Integer first, String after, DataFetchingEnvironment env) {
return new SimpleListConnection<>(List.of()).get(env);
}
For example: This is works but not solve my problem.2
Upvotes: 0
Views: 29