Comments (12)
In case this helps, I put together a little guide (still rough around the edges) to create a graphql microservice implementation, with the GraphQLServer (yoga) being hosted as a Lambda. Each microservice is "stitched" together to form a single BFF Service. https://gist.github.com/aqwert/6a041827d24ebec3275f75a910018e3f
And a diagram: https://github.com/aqwert/code_architecture_design/blob/master/client_graphql_microservices.md
from prisma-examples.
Hey guys I have made quite a bit of traction on this - auth/user service, goal service, gateway service to combine the schemas, dB services leverage prisma and I also do ssr rendering with nextjs. Still a way to go but itβs getting there π
Check it out and let me know what you think
https://github.com/ryannealmes/shakra
from prisma-examples.
Apparently, Apollo release their new tools to build API gateway and microservices.
I create a repository putting Apollo Federation and Prisma together.
https://github.com/dohaicuong/prisma-microservices
from prisma-examples.
@dohaicuong Thanks for sharing this.
One thing concerns me, though. How can Prisma ensure distributed transactions when using microservices? We should have events or something to communicate with other services.
from prisma-examples.
Hi @ryannealmes!
I already planned some things but I didn't have enough time to play with the code. Anyway, we can discuss here things in more detail so that we can figure out the best option and you can play with the code and give me know your feelings about it.
I think, a better approach would be to have different projects running independently of others and expose each service with a programmatically API with GraphQL Binding library. Note that services will be consumed from the API gateway and they will not be exposed to the client. I think this is a better approach than use schema stitching.
I will give a quick example. Let's say we have to build a simple app for movies. So, we will need a Movie service. We will also have an API gateway which will be exposed to our client apps (web app, iOS app, Android app...). So, this will be another different project which will use the previous service.
How can we connect with the service? You can make a simple network request with Axios (or another similar library) to the GraphQL API of the service or you can use GraphQL Binding library as I mentioned earlier (see oficial documentation for more details) to request data in a more elegant manner. You will be able to consume the services on your API gateway project like as follows:
// resolvers.js
const movieService = new MovieServiceBinding()
async function movie(parent, args, ctx, info) {
return await movieService.movie({ id: args.id }, info);
}
I hope my comment can be helpful. Let me know whatever, I am very interested on this topic, so we could go further with a more real and complex example.
from prisma-examples.
Thanks @jferrettiboke, I agree that this would be an excellent example! If anyone is interested in contributing this, I can point you into the right direction. You can find me in our Slack, my handle there is @nilan.
from prisma-examples.
I have been trying to figure this out for a couple of days. I have managed to spin up some stuff and looking to introduce a schema stitched api to tie everything together, but getting everything to run off a single docker-compose file is proving to be impossible :/
from prisma-examples.
Hey guys, I have really been enjoying working on a little pet project around this. It still needs lots of work, but I thought I would share it incase guys had comments that may benefit the exercise. Feel free to ping me on prisma slack (@ryannealmes) if you want to chat.
https://github.com/ryannealmes/shakra
I have managed to get auth/user service + goal service as 2 microservices stitched together and you can auth through the stitched api and pull anything you need. Also inter-service communication is handled prisma bindings ... so cool! @jferrettiboke I know you wanted to look at something without schema stitching, but I just couldn't resist ... it's too cool!
I want to go on to add a react front end and react native mobile app, devops and lots more. Also documentation probably has mistakes, but I will set it up on another PC just to make sure people can get started. Log issues if you find anything. Anyway feel free to tear it to shreds as well ... help me learn :)
from prisma-examples.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from prisma-examples.
I created a repository. Note how the example is using the shared database approach with no joins. Once Prisma supports multi-database, I think we could manage services easier with the same Prisma server at different databases.
Please, let me know guys what you think. Together, we can bring the best approaches and examples to the table.
from prisma-examples.
Hi @schickling @marktani! Do you know if anyone is working on completing this example?
from prisma-examples.
Sorry for the late reply.
That's what I've been looking at.
So I could say event driven is a good approach in this case, or something like Saga to ensure the distributed transactions would make sense. However, I think there is no silver bullet for distributed system like this.
Or we can see if there any supports from prisma team about the good approach for this maybe :))
from prisma-examples.
Related Issues (20)
- Update NestJS examples to no longer use beforeExit hook HOT 2
- Improve Next.js Rest API example
- GraphQL next.js example not working
- GraphQL Next.js example missing dependencies
- nuxt 3 prisma example not working on production HOT 1
- nuxtjs3 - db.ts example code does not match the referenced documentation page HOT 1
- nuxtjs3 - rest-nuxtjs example
- how to package prisma
- One-to-many relationship
- tutorial out of date: End-To-End Type-Safety with GraphQL, Prisma & React HOT 2
- Unauthorized Error when Creating a New Post HOT 1
- `typescript/rest-nextjs-express` doesn't work with `try-prisma`
- The domain try-prisma-analytics.com has expired
- Generate types from prisma schema models
- prisma-indexes HOT 1
- MongoDB indexes don't work with `prismagraphql/mongo-single-replica`
- PothosSchemaError: Ref ObjectRef<Profile> has not been implemented HOT 1
- postgresql-supabase instructions missing db seed step
- fix(typescript/trpc-nextjs): typo "singupUser" instead of "signupUser"
- chore(typescript/rest-nestjs): remove unused dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-examples.