spring-petclinic / spring-petclinic-graphql

PetClinic Example based on GraphQL
Other
212 stars 123 forks source link

Example with "Microservice" and DataLoader #43

Open nilshartmann opened 1 year ago

nilshartmann commented 1 year ago

Hi @arey and all!

I created another variation of the spring-petclinic-graphql example, that I needed for trainings and other demonstrations.

This version uses a second backend "micro service" (for managing Vets) that can be used to demonstrate working of DataLoaders when collecting data for a GraphQL response from other remote services.

Everything else is almost the same as in our current example. Do you think I should merge the "new" example to this repository? I think it's a more realistic example with two backend services and it's also important to have a DataLoader example.

You can find my repo here: https://github.com/nilshartmann/spring-petclinic-graphql-microservice

If interessted, I would merge that back into this repo.

Thanks, Nils

arey commented 1 year ago

Hi Nils, Thanks for sharing. I didn't see how GraphQL DataLoader is working. That's done with your Youtube video. It could be interesting to add this feature in the https://github.com/spring-petclinic repo. Your readme references the original readme. Thus be careful with the merge. And what is the behavior of the backend when vet-service is down? Regards Antoine

nilshartmann commented 1 year ago

Hi @arey ,

And what is the behavior of the backend when vet-service is down?

Good question. Currently the GraphQL request would fail. That is an interessting problem in GraphQL APIs that are connected to multiple backend services in general. If you don't want the request to fail, you have to make all the data that comes from other services nullable in the schema and then send null as a result (or an explicit error type). At a later time it would maybe possible to use stream and defer for fields that are backed by a remote service.