Skip to content

Instantly share code, notes, and snippets.

@SilencerWeb
Created July 24, 2018 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilencerWeb/dc1acd12c123969f6c7fd39e680a7830 to your computer and use it in GitHub Desktop.
Save SilencerWeb/dc1acd12c123969f6c7fd39e680a7830 to your computer and use it in GitHub Desktop.
require('dotenv').config();
const { GraphQLServer } = require('graphql-yoga');
const { Prisma } = require('prisma-binding');
const schedule = require('node-schedule');
const { resolvers } = require('./resolvers');
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false,
},
context: req => ({
...req,
prisma: new Prisma({
typeDefs: './src/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
}),
}),
});
schedule.scheduleJob('*/5 * * * * *', async() => {
const tasks = await server.context.prisma.query.tasks(
{
where: {},
},
`
{
id
days {
id
status
}
}
`,
);
});
server.start(() => console.log(`GraphQL server is running on http://localhost:4000`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment