Wrapping up
Now that we have our modules ready, let's create and run our GraphQL application.
Create the application
Create an entry point for your application in 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,
});
export const yoga = createYoga({
schema: baeta.schema,
});
const server = createServer(yoga);
server.listen(4000, () => {
console.log(
`🚀 Server ready at http://localhost:4000${yoga.graphqlEndpoint}`,
);
});
note
We're using GraphQL Yoga for this example due to its simple setup, but Baeta is compatible with all GraphQL servers like Apollo Server, Express GraphQL, and others.
Start the application
Run your application with:
yarn start
What's Next?
Now that you have a running GraphQL API, you can:
- Add authorization
- Implement caching
- Safeguard from malicious operations
- Add validation
- Add custom directives
tip
Visit our examples repository for more complex implementations and real-world usage patterns.