Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKnarf committed Mar 5, 2024
1 parent fdf10f6 commit 7fd5f82
Show file tree
Hide file tree
Showing 5 changed files with 448 additions and 13 deletions.
21 changes: 21 additions & 0 deletions packages/bff-graphql-poc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "bff-graphql-poc",
"scripts": {
"dev": "nodemon --watch 'src/**' --ext 'ts' --exec './src/index.ts'"
},
"dependencies": {
"@fastify/websocket": "^9.0.0",
"@tsconfig/node20": "^20.1.2",
"fastify": "^4.26.1",
"graphql": "^16.8.1",
"graphql-http": "^1.22.0",
"graphql-ws": "^5.15.0",
"nexus": "^1.3.0",
"nodemon": "^3.0.3"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^5.3.3"
},
"type": "module"
}
23 changes: 23 additions & 0 deletions packages/bff-graphql-poc/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning --loader ts-node/esm
import Fastify from 'fastify';
import fastifyWebsocket from '@fastify/websocket';
import { makeHandler } from 'graphql-ws/lib/use/@fastify/websocket';
import { createHandler } from 'graphql-http/lib/use/fastify';
import { schema } from './schema.ts';

const port = 4000;
const app = Fastify();
app.get('/', async function handler (request, reply) {
return { hello: 'world' }
});

app.register(fastifyWebsocket);

app.register(async (fastify) => {
fastify.get('/graphql', { websocket: true }, makeHandler({ schema }));
});

app.post('/graphql', createHandler({ schema }));

app.listen({ port });
console.log(`Listening to port ${port}`);
17 changes: 17 additions & 0 deletions packages/bff-graphql-poc/src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { makeSchema, objectType } from 'nexus';

const Query = objectType({
name: 'Query',
definition(t) {
t.field('hello', {
type: 'String',
resolve: () => {
return 'Hello!';
},
});
},
});

export const schema = makeSchema({
types: [Query]
});
13 changes: 13 additions & 0 deletions packages/bff-graphql-poc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "@tsconfig/node20/tsconfig.json",

"ts-node": {
"transpileOnly": true,
"files": true,

"compilerOptions": {
}
},
"compilerOptions": {
}
}
Loading

0 comments on commit 7fd5f82

Please sign in to comment.