DEV Community

Cover image for Build a Modular GraphQL Backend for LLMs with Cosmo Plugins
Stefan  ๐Ÿš€
Stefan ๐Ÿš€

Posted on

Build a Modular GraphQL Backend for LLMs with Cosmo Plugins

We were trying to make API orchestration easier. Instead, we built a backend framework for LLMs. And it's actually good.

If you like the idea of vibe-coding backend services with LLMs, keep reading. If not, skip to the part where we reduce 20 API calls per page to just 1.

What Are Cosmo Plugins?

A plugin is a module that:

  • Has a schema
  • Gets a gRPC definition
  • Uses Cursor to generate the adapter
  • Runs as a subprocess inside the Cosmo Router (thanks to go-plugin)

Every plugin maps to a piece of your Supergraph. You can build modular monoliths or microservices. You can mix both. Itโ€™s up to you.

Why We Built This

We were working with a customer who had thousands of REST-ish APIs. Rewriting them all to GraphQL? Not gonna happen. But they wanted to use a Supergraph.

So we built a way to use LLMs to do the translation. One plugin per service. One query per page. Thatโ€™s it.

Quickstart: Your First Plugin

npx wgc@latest router plugin init hello-world

Enter fullscreen mode Exit fullscreen mode

This scaffolds a full setup. Open Cursor in the plugin dir. Use the built-in prompts to generate code. Modify the schema if needed. Done.

Add another module? Run the init command again. Update the Router config to compose it.

Handling Dependencies

Handled. Thatโ€™s what Federation does best. Declare your needs. The Router composes and resolves it.

Learn More and Join Us

Weโ€™re just scratching the surface. Let us know what you build.

Originally published on WunderGraphโ€™s blog

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.