question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Database handling in graphback

See original GitHub issue

Background

Currently graphback-cli is pretty much strict about postgres as the only database. Database creation in graphback is done using knex which supports a bunch of relational databases.

graphback-cli has currently 3 main commands in it’s workflow with other proposed commands yet to be finalized. steps

  • Init creates the project with model and config
  • generate generates schema and resolvers
  • db creates and manages database resources

Discussion

Currently the moving parts which are dependent on database are the templates, resolver generation and database creation.

The user chooses from templates in the init command which are currently db specific(postgres).

  • we can separate templates into different database specific ones, like apollo-typescript-starter to apollo-typescript-pg/apollo-typescript-mongo
  • we can modify init command to inject db configs and docker-composes into templates with one skeleton.

The generate command generates schema and resolvers. The resolvers are currently implemented by a Knex resolver instance which generates resolvers which use knex. This is pluggable, so for it to support a no-SQL database like mongoDB would not be difficult.

#47 The db command will create db resources in local development server. Key point is to separate concerns regarding development and production. Database to be created can be selected as we start to support different databases. But the concern of db command is to create local database.

  • we can create a config file during init which store db config and accordingly create a docker-compose. But this will also have template as another moving piece which will be needed to configure.
  • we should support addition of new tables, new columns(the current implemetaion of graphback needs to be a modified a bit) but dropping columns is to be debated.

Finally, we should create a graphback migrate command that will generate database definitions.

Points to note

  • This is a development workflow. Dealing with production using graphback is to be ideated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
wtrockicommented, Aug 21, 2019

Really good discussion here. We need to get back to the updated idea of how database changes can be handled. Without bringing the tooling that can be used I think we need to think if we can build state aware generation process.

Our project would have this state from previous generation, this will allow us to calculate diff and then see diff on the database to deliver sql statements. If we do that separately we can benefit from large set of the open source libraries that do database management right.

So TL:DR idea is to detach database management problem from graphql problem by collecting schema changes and feeding them back to SQL Diff engine that can both apply changes directly or make migration scripts

0reactions
wtrockicommented, Sep 12, 2019

Content here outdated and we have couple separate issues. Closing this one

Read more comments on GitHub >

github_iconTop Results From Across the Web

Graphback | Graphback
... Manages complexity of database management ... Graphback provides command line client for generating fully functional GraphQL enabled Node.js server and ...
Read more >
Graphback: Out Of The Box GraphQL Server and Client - Morioh
graphback - Framework and CLI to add a GraphQLCRUD API layer to a GraphQL server ... function handle(Server $server, $workerId) { // Initialize...
Read more >
Applies the changes made to a data graph back to the database.
Given a PDO database handle and the special root object of a data graph, examine the change summary in the datagraph and applies...
Read more >
FileMaker with a Graph back-end (4 of 4) - YouTube
In this video I explain how to replace FileMaker tables and relationships with a Graph back -end database. Using the same movies example...
Read more >
SDO_DAS_Relational::applyChanges
Given a PDO database handle and the special root object of a data graph, examine the change summary in the datagraph and applies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found