A GraphQL server with pure Code-First approach out of the box.
Stack:
The server is built using a simple Fastify application and Apollo server is consumed as a middleware in order to keep the maximum flexibility.
The GraphQL layer embraces the "code first" approach using Nexus.
- code first approach
- strong type-safety
- declarative configuration
- flexibility, you have access to the Fastify app
- configuration fully documented (TSDoc)
import { join } from 'path';
import { v4 as uuid } from 'uuid';
import Marbre from 'marbre';
import { context } from './api';
import { PORT } from './env';
import * as types from './graphql';
const marbre = new Marbre({
types,
context,
contextType: {
module: join(__dirname, 'api/context.ts'),
name: 'GqlContext',
},
sourceTypes: join(__dirname, 'api/sourceTypes.ts'),
outputDir: join(__dirname, 'api/generated/'),
port: PORT,
fastify: {
genReqId: () => uuid(),
},
});
(async () => {
await marbre.start();
})();
Mozilla Public License v2.0