add prisma to graphql modules / yoga template
This commit is contained in:
14
web/other/graphql-modules-yoga-prisma-starter/src/main.ts
Normal file
14
web/other/graphql-modules-yoga-prisma-starter/src/main.ts
Normal 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();
|
||||
@@ -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 }),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createApplication } from "graphql-modules";
|
||||
import { exampleModule } from "./example";
|
||||
|
||||
export const application = createApplication({
|
||||
modules: [exampleModule],
|
||||
});
|
||||
Reference in New Issue
Block a user