hasura / hasura/graphql-engine

RFC: Community library of data models, postgres functions and constraints for the console

Open
#4,180 3 comments 12 reactions 2 assignees Claimed by @coco98 View on GitHub
a/data a/product-design k/rfc triage/3-rfc-wip
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

While setting up a database schema or doing data modelling in general, it would be immensely useful to be able to be able to use a best-practices reference schema to use as a starting point.

I imagine the experience to be something like this:
1. On the data tab on the console, I can browse a library of community contributed schemas
2. I can search for and import a schema into the console
3. This schema could consist of Postgres data models and Hasura metadata
4. These models and metadata get added to my current schema
5. I can then iterate on the few models that I have to shape it into something I need
6. I can also select a bunch of tables and "publish" the schema. The console will automatically detect the dependent objects to those tables and let me choose if I want to share tables, dependent views, functions, associated relationships, permissions etc

I imagine the schemas in the library to be a combination of full blown schemas or maybe even a few related tables put together.

Here are some examples that I think could be useful:
1. ecommerce stripe checkout
2. calendar: recurring events, events, cancelled events
3. realtime user and taxis (partial uber type schema)
4. trello schema (optimised for an offline first)

These examples can come with any combination of tables, views, functions, hasura relationships, hasura permissions.

In my mind I'm imagining a UI that's kind of like a combination of a searchable marketplace combined with a dbdiagram.io!

This idea can also be extended to:
- Postgres functions (fulltext-search, location)
- CHECK constraints (a library of common postgres constraints around simple field validation)

**Where are the "modules" in this library stored?**

1. It would be the simplest to think of these as github repositories that have a migrations folder containing an up.sql/down.sql and a metadata/ folder that contains the metadata files. Upon import, the console can "merge" the metadata and apply the SQL migrations
2. Postgres functions and check constraints could be a set of files in the hasura/graphql-engine/community repo that can be pulled in to the console

-------------------------------------------

**Questions to others!**

What kinds of reference schemas, hasura metadata examples, postgres functions/utilties would have helped you as you were using Hasura?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.