Я использую Spring- boot v2.7.12 (без Graphql Starter — эта версия не поддерживает директивы *Connections) и Graphql-java-kickstart (инструменты, а также Spring-Boot-Starter)
Код: Выделить всё
com.graphql-java-kickstart
graphql-java-tools
13.0.0
com.graphql-java-kickstart
graphql-spring-boot-starter
14.0.0
Код: Выделить всё
type Container{
name:String
}
type Guide{
name: String
containers(first: Int, after: String): ContainerConnection @connection(for: "Container")
}
type Query {
guides:[Guide]
}
Код: Выделить всё
@Controller
@RequiredArgsConstructor
public class GuideController implements GraphQLQueryResolver {
private final GuideRepository guideRepository;
List guides() {
return ....
}
}
Код: Выделить всё
@Controller
@RequiredArgsConstructor
public class ContainerController implements GraphQLQueryResolver {
private final ContainerRepository containerRepository;
public Connection containers(Integer first, String after, DataFetchingEnvironment env) {
return ....
}
}
Код: Выделить всё
Caused by: graphql.kickstart.tools.resolver.FieldResolverError: No method found as defined in schema :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:?]
Когда я попробовал простое сопоставление для разбивки на страницы Guide или Container, все было в порядке
Код: Выделить всё
type Guide{
name: String
}
type Query {
guides[(first: Int, after: String) : GuideConnection @connection(for: "Guide")]
guide(id: Int) : Guide
}
Код: Выделить всё
public Connection guides(Integer first, String after, DataFetchingEnvironment env) {
return new SimpleListConnection(List.of()).get(env);
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -in-schema