NN
Size: a a a
NN
U
U
U
const { GraphQLServer } = require('graphql-yoga');
const { Prisma: PrismaBinding } = require('prisma-binding');
const { typeDefs } = require('./generated/prisma-client/prisma-schema');
const binding = new PrismaBinding({
typeDefs,
endpoint: 'http://localhost:4466',
secret: "abcd1234",
});
const autoForwardTo = crud => Object.keys(crud)
.map(key => ({
[key]: (_, args, __, info) => crud[key](args, info),
}))
.reduce((obj, fn) => ({ ...obj, ...fn }), {})
const resolvers = {
Query: autoForwardTo(binding.query),
Mutation: autoForwardTo(binding.mutation),
};
const server = new GraphQLServer({
typeDefs: 'src/schema.graphql',
resolvers,
context: req => ({
...req,
binding,
debug: true,
}),
});
server.start(() =>
console.log(`GraphQL server is running on http://localhost:4000`)
);
U
U
NN
NN
NN
NN
RR
NN
NN
NN
NN
NN
NN
NN
RR
RR