-
Notifications
You must be signed in to change notification settings - Fork 73
Hook into existing database without migrations #630
Comments
It would also be nice if graphback could be used entirely without Docker, and just hook into an existing Postgres database through a config file that points to the database URL, username, password, etc |
Graphback is designed as a set of tools rather than closed ecosystem. It consists:
Each of those can be used separately or together. I will add more info into the docs to make this clear. As for the "bring your own database" - technically this is really simple to achieve however, graphback at the moment is not providing db to graphql mapping package, which means that data from the database needs to conform with the graphql fields and types. This limitation can be resolved by:
In both cases there will be some extra work needed that might depend on the structure of your database etc. To support that we can have a community runtime layer that works with Bookshelf. See: knex/knex#498 When we think about it we are closer to AWS App Sync rather than Prisma2 only because Schema really drives the data. In TL;DR Graphback will give much more flexibility and freedom (and migration patterns) but it will mean much more work required on developer side to figure out the best pattern As a team we are really interested in getting some community taction in those cases as we can do much better job at making Graphback successful and something that community really wants.
Graphback can be used without docker. We provide docker for convenience and also support SQL Lite. You can choose your database when executing EDIT: To really make this successful we will need to know your take on my response and more details about your setup like database type and difference between database field and graphql type |
Very detailed response, thank you.
I would love some more documentation or direction on how to do 1 and 2. As for my setup, I'm using Postgres, and a GraphQL schema that was originally generated using Prisma's introspection command. I can post some select examples here if you need them. I generated the GraphQL schema with I believe Prisma v1.21.1. Once the original GraphQL schema was generated, I transitioned to using manual updates to the schema, not using the introspection command every time a database migration occurred. Prisma is able to understand my custom GraphQL schema and map it to the underlying Postgres types. This is very convenient. Ideally, I as a developer would not need to write any custom mapping code to get my GraphQL schema to work with a Postgres, MySQL, or other database. I believe each of the database types should have their own plugins, adapters, runtimes, or whatever you might want to call them for resolving GraphQL queries against them. Prisma was working on things like OpenCRUD, trying to create standards for many of these problems. I know they are moving away from that, but is anyone picking up the slack here? Seems like graphback is just going to be creating yet another opinionated set of generated CRUD queries. I'm not saying graphback's would be worse, but it would be nice if we could standardize this. I haven't dug into graphback yet to really see how things work, I should be able to dedicate some significant time to it sometime in the next month. I have a number of requirements that I'm looking for, not sure if this is the best time or place to list these, but perhaps:
Perhaps graphback is already doing a lot of these things, and perhaps the documentation just isn't in a state where all of these things are obviously understood without further inquiry. I'm really excited about this project, I hope it can be great! |
Thank you so much for investing your time for such amazing feedback. We will need more time to digest all the points and come up with a solid plan (and direct actions/issues). I would like to be able to provide info on what we could do and when. Graphback is still in early beta phase and we are working towards an official release that will clarify docs. Your assumptions are correct. I think we need to clarify better what graphback does and how to use it for different use cases in docs. |
Hi @lastmjs - thanks for your detailed response which shows us some really strong uses cases for Graphback. We are now in the design phase of an architectural change, which will make Graphback more flexible and easier to add more customisation cases in the future. You can gain more context of this refactor in #635.
Our documentation does not have directions for this. We will be adding a runtime mapping solution that should resolve this though. Tracked in #637
This is something we are aware is missing - the current custom mapping code was really only a temporary solution to document until we can map fields during runtime. We have a
We had a look into OpenCRUD some more and there really doesn't seem to be much activity or adoption. I've created #638 for us to take a deeper dive into the specification, try and get some opinions from the wider community and see if we should adopt it.
Our new plugin architecture will allow us to bring those use cases basing on libraries that are available in the community.
We are in the process of refactoring to use a plugin-based approach, which will use the generated schema (with annotations and directives) as the input source to the generator packages. This will let users bring their own custom directives and annotations for their specific use cases.
Within only a couple of months Graphback has pivoted from being a CLI-based GraphQL server generator to integrating into the graphql-cli as the generator for the server and database. Our documentation is still a little bit disjointed in this regard and we have intentions to fill that void soon (#631). With our new planned plugin-based architecture it should soon become easier to do a lot of these things! |
Hi We have done initial work for supporting that use case in our plugin based architecture. We going to provide short blog post soon explaining the nature of the changes. For the field mapping we still need to connect existing implementations with the CRUD layer that is being used by resolvers. @craicoverflow is going to deal with that. We going to support mapping for:
Mappings will be done by utilizing `@db' annotations that will give developers the ultimate flexibility with very little to no work needed outside annotating your input schema. |
Update. We have made major improvements to enable this case. What we have at the moment:
To be done:
|
Hopefully I'll have time soon on my project to spend a bit of time seeing how this is all looking, great work! |
This has been working very well for me! |
I'm not sure if this is possible in graphback, but I would love it to be. One essential thing that Prisma 1 does is allow users to hook into an existing database, and allow other tools to handle migrations. This allowed me to generate all of my GraphQL infrastructure using Prisma, but for an already-existing Postgres DB whose migrations are handled with Rails' Active Record. Because we're still in the process of migrating away from our Rails app, it is convenient to allow the Rails app to handle database migrations.
Does graphback support this type of workflow? Could it? As Prisma 2 seems to be going in a direction that I don't agree with, I'm assessing the viability of graphback as a replacement
The text was updated successfully, but these errors were encountered: