Graphback can easily be added to your existing Apollo GraphQL Node.js application.
Let's take a look at a very simple, minimal Apollo GraphQL server setup.
In just a few short steps, Graphback can be added to this project.
For this example we are going to assume that the project uses a PostgreSQL database.
To use PostgreSQL with Graphback install Knex.js with the Graphback PostgreSQL library:
Once installed, initialize a Knex client using your database credentials, and create a Knex database provider creator for Graphback:
For more on database support in Graphback, see Databases.
Graphback will only process GraphQL types which are annotated with
@model. This opt-in model enables you to combine Graphback enabled types and resolvers with your existing types that do not require bootstrapping.
In this scenario, we want
Note to be processed by Graphback.
For more advanced usage on how to configure your data models, see our Model guides.
Let's install Graphback and use it in the project.
buildGraphbackAPI will process your schema and generate a CRUD API with schema, resolvers, services and data sources.
Check out the buildGraphbackAPI for more advanced use cases like CRUD configuration and plugin extensions.
Now that you have added all the Graphback code, let's bring it together and add Graphback to your Apollo GraphQL server: