gRPC is better to implement Microservices than GraphQL, but GraphQL is better to expose a set of Microservices to the web.
Cosmo Connect combines them and gives you the best of both worlds.
1. Define your GraphQL Schema
2. generate a service proto definition
3. implement the gRPC service
How did we come up with this approach? At WunderGraph, we're a heavy user of Go. It's a great language, but it also has its limits. For example, generics are very weak in Go, so a lot of workflows rely on code generation.
One tool that we're all familiar with is gqlgen, maintained by Steve Coffman. It's probable one of the best and most widely used implementations of GraphQL with Federation support, at least in the Go community.
The workflow is very simple.
1. Define your GraphQL Schema (sounds familiar)
2. generate Go stubs
3. implement Go stubs
As much as we liked this workflow, not everyone can use it, not every code base is written in Go, and not every company has the required skills.
So why not stick to the workflow, but make it more generic, so it can be used by everyone, any language, any framework? That's where gRPC comes into play. But what sounds simple, actually was a real challenge.
Frameworks like gqlgen do a lot more than just generating stubs and calling them. They handle the complexity of GraphQL, like parsing, validation, execution, etc...
The solution? We moved the complexity of GraphQL into Cosmo Router and kept the "Subgraph" contract as simple as we can. In a nutshell, we only create so called "loader" functions for our Services. They execute Queries or Mutations, or look up entities to resolve additional fields.
Problems like batching, authentication, authorization, etc. we're all handling in the Router. At the service layer, it's really just business logic and data loading.
That not just makes your service layer very slim in the sense that it's very little code, it's also just super lightweight.
Isn't that perfect for LLMs to work with? Very little complexity, strictly typed contracts. Much easier to test compared to a regular GraphQL Subgraph.
What's the most powerful feature of all? We can now add new capabilities to Cosmo Router, like for example Caching, and everyone immediately benefits, independent of language or framework. Even if you're running on Python or Ruby, all you did was implement loader functions.
If Apollo wanted to implement a new super powerful directive, they'd have to get all Subgraph frameworks to adopt and maintain it.
With Cosmo Connect, we just add it to the Router. We're now able to independently innovate at our own pace.
What's a good workflow to propose schema changes? It's a tradeoff between autonomy and governance, but we cannot skip it.
We've talked a lot with our customers and the community about their approaches to schema changes. Some use GitHub Pull Requests, some use tools like Miro or even Google Docs or Confluence to discuss changes.
But all of these solutions have their problems. The tools are not designed for the job. GitHub is great to track code changes and review them, but it's not designed to manage Schema over time. You can build something on top of GH, but it will never be great.
Miro, Google Docs, Confluence & similar tools come with a different set of challenges. Although they make realtime collaboration much easier, they are not designed for this kind of problem.
It can take an engineer multiple hours to set up a Miro board for a Schema discussion, but after a week or so, other changes made the board outdated and obsolete.
We've looked at all the existing tools and workflows our customers used and added a spark of "Vercel Previews". The outcome? Design schema collaboratively in realtime, combined with async threads and a Pull Request style review process.
Instead of just checking composition, breaking changes, linting, etc. we're also verifying that there are no open threads. It's a simple but powerful approach to ensure that all relevant stakeholders that the schema change is acceptable.
Join me at P99 CONF (free + virtual) for 50+ tech talks on building low-latency, data-intensive applications. 🎫 Register for free https://t.co/jxqNnmpVBs #P99CONF hosted by #ScyllaDB
Fun fact: even monkeys do not eat the banana fibrous threads and they accurately remove them before eating the fruit.
[📹 jlatosha]
https://t.co/5rOvti3ikb
This is the scariest tweet I've made in a long time.
On Friday I met with a psychiatrist, @MundinMd and did a 30 minute session, where I was her patient.
These are the notes that the system she was using, which uses @OpenAI's GPT as back end, made.
Wow. Thread: