Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: make executable schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Enda Phelan committed Oct 12, 2020
1 parent 094a2ae commit 1fcee77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion templates/ts-fastify-mongodb-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "Apache 2.0",
"dependencies": {
"@graphback/runtime-mongo": "1.0.1",
"@graphql-tools/merge": "6.2.4",
"@graphql-tools/schema": "6.2.4",
"dotenv": "8.2.0",
"fastify": "3.6.0",
"fastify-cors": "4.1.0",
Expand All @@ -31,6 +31,7 @@
"@graphql-codegen/add": "2.0.1",
"@graphql-codegen/typescript": "1.17.9",
"@types/glob": "7.1.3",
"@types/node": "14.11.8",
"@types/graphql": "14.2.3",
"@types/node-fetch": "2.5.7",
"graphback-cli": "1.0.1",
Expand Down
17 changes: 12 additions & 5 deletions templates/ts-fastify-mongodb-backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('dotenv').config();
import mercurius from 'mercurius';
import { buildGraphbackAPI } from 'graphback';
import { createMongoDbProvider } from '@graphback/runtime-mongo';
import fastify from 'fastify';
import fastifyCors from 'fastify-cors';
import fastifyCors from 'fastify-cors';
import { loadConfigSync } from 'graphql-config';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { connectDB } from './db';
import { noteResolvers } from './resolvers/noteResolvers';
import { mergeResolvers } from '@graphql-tools/merge';

async function start() {
const app = fastify();

app.register(fastifyCors, {});
app.register(fastifyCors as any);

const graphbackExtension = 'graphback';
const config = loadConfigSync({
Expand All @@ -35,10 +36,16 @@ async function start() {
dataProviderCreator: createMongoDbProvider(db)
});

const schema = makeExecutableSchema({
typeDefs, resolvers: [
resolvers,
noteResolvers
]
})

app.register((mercurius as any), {
schema: typeDefs,
schema,
graphiql: true,
resolvers: mergeResolvers([resolvers, noteResolvers]),
context: contextCreator,
subscription: true
});
Expand Down

0 comments on commit 1fcee77

Please sign in to comment.