Relay based paging for Java graphql server in Java
•
Java
I have implemented a Java - based graphql server using graphql - Java - tools Now I need to use my java - graphql server to implement relay - based paging
I can't find anything useful Who can help me point out the right place to find how in Java_ Implement relay based paging in graphql server?
Thank you for your expectation
Solution
Graphql java tools in version 5.4 Support for relay has been added to 0 As described in the documentation example, you can use the new @ connection directive in the schema:
type Query { users(first: Int,after: String): UserConnection @connection(for: "User") } type User { id: ID! name: String }
And return a connection < T > in the parser:
class QueryResolver implements GraphQLQueryResolver { public Connection<User> users(int first,String after,DataFetchingEnvironment env) { return new SimpleListConnection<>(Collections.singletonList(new User(1L,"Luke"))).get(env); } }
However, examples other than simple lists (for example, when edges must be extracted from the database) are scarce, and simplelistconnection is the only implementation provided by graphql Java so far
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码