There are several options here.
- It's probably best not to display the entity directly. Entities are direct representations of the database and, as such, probably should not be directly disclosed, but should be enclosed in a DTO (possibly allowing you to paginate, align relationships or do what is appropriate).
- If you just need to map the class (entity or not) to
GraphQLObjectType
, graphql-java-annotations is the easiest (and most restricted) route - If you want to represent the entire entity graph through GraphQL, then graphql-jpa (as Sriram suggests ) is best for you, as he intended to do just that by adding page numbering, aggregation, and sorting.
- If you want to automatically represent not only the / DTO entity class, but also the operations on it (for example, an arbitrary service class), look at graphql-spqr (I am the author of this project)
source share