Super Graph can generate your initial app for you. The generated app will have config files, database migrations and seed files among other things like docker related files.
You can then add your database schema to the migrations, maybe create some seed data using the seed script and launch Super Graph. You're now good to go and can start working on your UI frontend in React, Vue or whatever.
And then create and launch your new app
Lets take a look at the files generated by Super Graph when you create a new app
Docker Compose is a great way to run multiple services while developing on your desktop or laptop. In our case we need Postgres and Super Graph to both be running and the
docker-compose.yml is configured to do just that. The Super Graph service is named
api you are free to change this. The Dockerfile can be used build a containr of your app for production deployment.
Run Super Graph with Docker compose
All the config files needed to configure Super Graph for your app are contained in this folder; to start you have
prod.yaml. When the
GO_ENV environment variable is set to
dev.yaml is used and the prod one when it's set to
production. Stage and Test are the other two environment options, but you can set the
GO_ENV to whatever you like (eg.
alpha-test) and Super Graph will look for a yaml file with that name to load config from.
Having data flowing through your API makes building your frontend UI so much easier. When crafting say a user profile wouldn't it be nice for the API to return a fake user with name, picture and all. This is why having the ability to seed your database is important. Seeding can also be used in production to setup some initial users like the admins or to add an initial set of products to a ecommerce store.
graphql to generate fake data and use GraphQL mutations to insert it into the database.
If you want to import a lot of data using a CSV file is the best and fastest option. The
import_csv command uses the
COPY FROM Postgres method to load massive amounts of data into tables. The first line of the CSV file must be the header with column names.
You can generate the following fake data for your seeding purposes. Below is the list of fake data functions supported by the built-in fake data library. For example
fake.image_url() will generate a fake image url or
fake.shuffle_strings(['hello', 'world', 'cool']) will generate a randomly shuffled version of that array of strings or
fake.rand_string(['hello', 'world', 'cool']) will return a random string from the array provided.
Easy database migrations is the most important thing when building products backend by a relational database. We make it super easy to manage and migrate your database.
Migrations in Super Graph are plain old Postgres SQL. Here's an example for the above migration:
We would encourage you to leverage triggers to maintain consistancy of your data; for example here are a couple triggers that you can add to your init migration and across your tables.