This a semi-automated approach to creating a GraphQL schema from an existing database schema. Though manual coding was minimal and related to mapping custom db types to jpa entities. With this example database there were only 3 custom types.
To explore the generated schema graphically use the GraphQL Voyager tool.
Copy the contents of the schema.graphql file and paste it into the tool.
It seems to provide an accurate representation of the relationships within the db schema.
It also provides inputs etc.
JPA Buddy is a plugin for IntelliJ that can create jpa entities and repositories from an existing db schema.
graphql-jpa-query is a library that can create a GraphQL schema from jpa entities and repositories.
I've implemented the controller from one of the provided packages, and it's possible to access the data via GraphQL queries using a client such as Altair and pointing it at the endpoint http://localhost:8080/graphql
.
An advantage to this is that on adding a new entity to the db schema, the GraphQL schema is automatically updated.
The github repository has hints of how to create mutations, and mentions support for subscriptions, but I haven't figured out how yet.
hypersistence-utils is a library that provides database type mapping for jpa entities.