Hacker News new | ask | show | jobs
GraphQL for Event Driven Architecture
8 points by quantdaddy 1598 days ago
Hey guys, I've been working on a GraphQL library for typescript that enables building event driven architecture using GraphQL schema. It can be used to publish and consume events in a type safe way using any message broker (Kafka, .RabbitMQ, PubSub etc). I built this library to scratch my own itch when I was trying to building a type safe event driven communication between microservices: JSON schema and protobuf didn't feel elegant and were too verbose so I thought why not GraphQL. You can read more in my blog post here: https://graphql-eventbus.vercel.app/blog

Youtube Intro Video: https://www.youtube.com/watch?v=XLbShOmkKk0

Github: https://github.com/skk2142/graphql-eventbus

Docs: https://graphql-eventbus.vercel.app/

I'd love to get your feedback!

2 comments

> JSON schema and protobuf didn't feel elegant and were too verbose so I thought why not GraphQL

2 questions:

1. Are there tools out there that can translate between GraphQL schema, JSON schema and protobuf?

2. How would you version events

1. Not sure. I'm sure you can find something but not that I know of. Sounds like something that should exist. 2. I think of versioning as a two way process (at least for internal APIs): adding fields and removing fields. Removing fields could break your client but that's where the awesomeness of GraphQL shines. You know all the fields that are being consumed by your consumer so you can safely remove fields that are not being consumed. You can also mark fields as deprecated and this library logs a warning whenever a consumer is using that field. This property of explicitly asking for fields does not exist for protobuf so it's very difficult to remove fields.

More on this here: https://graphql-eventbus.vercel.app/docs/principles/thinking...

hope it makes sense!

Curious why you decided to go for GraphQL instead of something like Cloud Events spec (https://cloudevents.io)
Great question: I've commented on it here: https://graphql-eventbus.vercel.app/docs/principles/thinking... See the "Specification for Event based communication" section.

"While cloudevents does have a promising specification, it does not provide any runtime guarantees. It's similar to OpenAPI: a specification that is hard to follow because nothing enforces runtime compliance with the specification. While this specification makes sense for public Event APIs, we believe that GraphQL Eventbus offers a lot more for building your enterprise event bus."

GraphQL eventbus does incorporate some best practices from cloudevents and event architecture in general: it creates an eventID and publish time for each event and propagates metadata like requestId.