Skip to main content
Version: Next (2.x)

Wrapping up

With the modules in place, all that's left is an entry point that hands the generated schema to a GraphQL server.

Create the application

src/app.ts:

import { createServer } from "node:http";
import { createApplication } from "@baeta/core";
import { createYoga } from "graphql-yoga";
// Baeta automatically exports all modules
import modules from "./modules/index.ts";

const baeta = createApplication({
modules,
// Register app plugins like auth or complexity here
// plugins: [authAppPlugin, complexityAppPlugin],
});

const yoga = createYoga({
schema: baeta.schema,
});

const server = createServer((req, res) => {
void yoga(req, res);
});

server.listen(4000, () => {
console.log(
`🚀 Server ready at http://localhost:4000${yoga.graphqlEndpoint}`,
);
});
note

This example uses GraphQL Yoga because the setup is short. Baeta works with any GraphQL server — see the Application guide for Apollo Server and other integrations.

Start the server

yarn start

What's next

You now have a running GraphQL API. From here:

tip

The examples folder has runnable apps for each of the above plus federation, pagination, Prisma, and Cloudflare Workers.