Wrapping up
Create the application
Our modules are now ready to use!
We can create an entry point for our application in src/app.ts
:
import { createApplication } from '@baeta/core';
import { userModule } from './modules/user';
import { userPhotosModule } from './modules/user-photos';
import { createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';
const baeta = createApplication({
modules: [userModule, userPhotosModule],
});
const yoga = createYoga({
schema: baeta.schema,
});
const server = createServer(yoga);
server.listen(4000, () => {
console.log('🚀 Server ready at http://localhost:4000/graphql');
});
note
We are using graphql-yoga because it's very easy to setup, but Baeta is compatible with all graphql servers.
Start the application
That's it! You can now start your application by running the following command:
yarn start
# or
yarn baeta build --watch --generate --onSuccess='node --enable-source-maps dist/app.js'