Giter VIP home page Giter VIP logo

Comments (12)

aqwert avatar aqwert commented on May 17, 2024 4

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.

ryannealmes avatar ryannealmes commented on May 17, 2024 4

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.

dohaicuong avatar dohaicuong commented on May 17, 2024 4

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.

jferrettiboke avatar jferrettiboke commented on May 17, 2024 2

@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.

jferrettiboke avatar jferrettiboke commented on May 17, 2024 1

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.

marktani avatar marktani commented on May 17, 2024

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.

ryannealmes avatar ryannealmes commented on May 17, 2024

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.

ryannealmes avatar ryannealmes commented on May 17, 2024

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.

stale avatar stale commented on May 17, 2024

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.

jferrettiboke avatar jferrettiboke commented on May 17, 2024

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.

otrebu avatar otrebu commented on May 17, 2024

Hi @schickling @marktani! Do you know if anyone is working on completing this example?

from prisma-examples.

dohaicuong avatar dohaicuong commented on May 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.