-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Research what it would take to migrate the backend to Prisma #274
Comments
SummaryThe components used with a Prisma configuration are similar to Graphcool, but consist of an additional seperate GraphQL server layer between the client and the Prisma GraphQL server layer. For our implementation (and what the boilerplate examples use), this GraphQL server layer is implemented with the graphql-yoga package and automatically bound to the Prisma layer with the prisma-binding package. This separation provides more flexibility in regards to middleware or custom functionality needed, such as third party authorization. For this specific project it means we will need to move some of the authentication and permission logic around. See here for more information. https://www.prisma.io/docs/maintain/graphcool-to-prisma/overview-gcf1/#new-architecture:-your-graphql-server-uses-prisma-as-a-database-layer Advantages
Disadvantages
Hosting Options (Prisma Cloud)
Required Tasks
Research
|
Awesome. Thanks for this research @cvanem! Did you by chance look into what database gets backs the prisma servers when you create an app with something like |
Also, I'm going to edit the title of this card to reflect the work that you did on the research side to make way for a followup spike of an actual implementation of this work. |
@wdoug I dug into that source code a little but but got stuck trying to trace down the --boilerplate argument. My best guess to what it is actually doing is the same as running prisma deploy and auto-selecting the options for you and deploying to a public server. Let me investigate more and I will update this post. |
@wdoug I didn't see much on them. This has a bit on the demo servers, which I am guessing that is what is created with the boilerplates: https://www.prisma.io/docs/run-prisma-server/demo-servers-prisma-cloud-jfr3/ |
@cvanem Thanks for the research. Based on what I've read, I think we'll still need some form of "application server" that consumes the Prisma Server (hosted on Prisma Cloud?) so we can handle authentication and authorization. Do you know if my assumption is right? I was thinking we could use a lambda function (sort of like we do now) if all it really does is handle authentication and then forward the GraphQL request to Prisma? |
I thought that prisma could also host that for you. For example, I'm pretty sure that in the graphql boilerplate it hosted both the prisma database setup and the graphql-yoga application server. |
@wdoug Yeah I think it is hosting them both. As far as I can tell when you use prisma deploy (with a prisma account) , it automatically links you to a heroku account and deploys them there and sets up the database. |
What if you don't have a prisma account? Will it prompt you to create one like they had for the graphcool framework? |
Yeah, it gives you some options to pick from. You can create a new account and authorize from the CLI. I believe there is also an option to just enter a server address in. |
Where is the production database hosted now? |
Ah nice. I must have gotten confused looking at this boilerplate and this example of using Now deployment to host the application layer. There's a lot of documentation out there, but sometimes it doesn't all say the same thing. |
@cvanem We use Graphcool and Graphcool Cloud. Graphcool cloud hosts the database and the GraphQL layer and the application layer we use for auth. |
@dchao19 Yeah the deployment section here specifically says you need to handle deployment of the GraphQL application layer...so I think I may have stated that incorrectly above in regards to the Prism Cloud deployment hosting both the application and Prisma layers. I think I got confused as it is is working in my development environment, but in that scenario your PC would act as the application layer? I think I need to do a bit more research. |
@wdoug @dcha19 More detail on the Separation of Application and Database Layer So, if I understand, we would require a separate layer hosted somewhere in a production environment. graphql-yoga Deployment The biolerplate examples require you to run yarn start on both the server (graphql-yoga) directory and the application directory. So in a development environment the local PC acts as the application layer and the client. |
Oh, I must have been confused because some of the boilerplates don't use the application layer at all and just have the prisma database layer... Hmm. That's unfortunate. That means we would potentially have 4 different components for this: database, prisma server, application server, and frontend server right? We should probably look into our options for this before we move forward. I'd still like to see if we can take advantage of a free tier that doesn't sleep (i.e. not using heroku for the application layer). I wonder if we could use Netlify Functions for the authentication/application layer since we are already using Netlify for the frontend. I suppose it might also be worth looking into moving auth to Netlify Identity instead of Auth0 since Auth0 has proved to not be as simple as advertised (although that would probably be a bigger headache - maybe we could do it later). Zeit now might also be a decent option for the application layer if that doesn't work. Then what? Would we use Prisma cloud for the prisma layer and database? Or prisma cloud for the prisma layer and something like the free tier on Heroku Postgres? Could we push the prisma data layer up to wherever we are hosting the application layer? It seems like it would be beneficial for those to be co-located, but maybe for our purposes, it wouldn't matter much? Is this whole thing even worth it? Thoughts @cvanem, @dchao19? |
@wdoug The graphql-yoga examples indicate it is possible to use netlify-lambda for the application layer: https://github.com/prisma/graphql-yoga/tree/master/examples/lambda-netlify It might be some work to get it working correctly... As far as the Prisma layer goes, I believe you are looking at using docking containers if you want to host it somewhere else. Once you go this route, it gets harder to argue the benefits of migrating to Prisma. Also, I don't think Prisma Demo accounts are intended to be used in a production environment. They will work but there are some restrictions. More on this here.. How has Graphcool worked out for you guys so far? If you haven't had any issues with it, I would be inclined to argue that the Prisma migration is not worth the extra headaches and added maintenance. |
It has worked decently. We did have a period previously where we were running into some shortcomings of it and were debating how to proceed (see #203). One of the options we were considering was moving to Prisma, and at that time we ultimately decided to just continue using the graphcool-framework and use the apollo-link-rest library to pull in external data from REST APIs on the client. We figured that since we could generally work around the limitations we were facing at the time it wasn't worth investing the effort in migrating it and dealing with the additional infrastructure when that effort could be focused on other features or other Code for Denver projects. I am going to try to document some of the pros and cons that I see to migrating: Benefits of moving to Prisma:
Potential downsides
Based on the above list, I'm on the fence, but think probably the appropriate product decision is to defer additional work on migrating to Prisma for now, while simultaneously knowing that there are several things that could prompt that decision to change in the future. Meanwhile, from a personal learning perspective I am fairly interested in working on a spike implementation of migrating to prisma although certainly not commiting to actually following through with it. |
I'm going to reopen this as we are still discussing it |
Prisma 2 will be easier to deploy and thus a little easier to migrate to in addition to getting the newer features |
Prisma is the successor to the graphcool-framework backend that we are using currently. Previously we avoided this because we would have to set up a new database and jump through several other hoops.
It is possible this is still the case, but the benefits might be worth the cost. One thing to note is that running:
(see https://github.com/graphql-boilerplates/node-graphql-server/tree/master/basic) will automatically set up a database and a live graphql server for you, so maybe we can just use that functionality (I don't actually understand exactly what it is doing to be honest).
The text was updated successfully, but these errors were encountered: