add prisma to graphql modules / yoga template

This commit is contained in:
2024-06-09 17:47:23 +02:00
parent 9775e859fa
commit b1c419143f
11 changed files with 1543 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { createServer } from "node:http";
import { useGraphQLModules } from "@envelop/graphql-modules";
import { createYoga } from "graphql-yoga";
import { application } from "./modules";
function main() {
const yoga = createYoga({ plugins: [useGraphQLModules(application)] });
const server = createServer(yoga);
server.listen(4000, () => {
console.info("Server is running on http://localhost:4000/graphql");
});
}
main();

View File

@@ -0,0 +1,25 @@
import { createModule, gql } from "graphql-modules";
export const exampleModule = createModule({
id: "example-module",
dirname: __dirname,
typeDefs: [
gql`
type Query {
hello: String!
world: World!
}
type World {
x: Int!
y: Int!
}
`,
],
resolvers: {
Query: {
hello: () => "world",
world: () => ({ x: 1, y: 2 }),
},
},
});

View File

@@ -0,0 +1,6 @@
import { createApplication } from "graphql-modules";
import { exampleModule } from "./example";
export const application = createApplication({
modules: [exampleModule],
});