Skip to content

Commit c090f00

Browse files
author
Salah Eddine Lalami
authored
πŸš€ Feature/improve graphql server setup (#3)
* ✨ Improve graphql server setup * πŸš€ Graphql server setup improved
1 parent 0beccaa commit c090f00

File tree

30 files changed

+2890
-588
lines changed

30 files changed

+2890
-588
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
npm-debug.log*
2424
yarn-debug.log*
2525
yarn-error.log*
26-
yarn.lock
2726

2827
# local env files
2928
.env.local

β€Žcodegen.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
overwrite: true
2-
schema: 'schema.graphql'
2+
schema: 'graphql/schema.graphql'
33
documents: null
44
generates:
55
graphql/generated/schemaType.ts:

β€Žgraphql/context/index.tsβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// import { PrismaClient } from '@prisma/client';
2+
// import prisma from '@/lib/prisma';
3+
// import { getSession } from 'next-auth/react';
4+
5+
export type Context = {
6+
session: any; // TODO: set session types
7+
};
8+
9+
export function createContext({}) {
10+
// const session = await getSession({ req }); // TODO: credentials not working on graphql studio (/api/graphql)
11+
return {
12+
session: { isAuth: true },
13+
};
14+
}

β€Žgraphql/resolvers/mutation/books.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žgraphql/resolvers/mutation/index.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žgraphql/resolvers/mutation/users.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žgraphql/resolvers/propriety.tsβ€Ž

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import { resolverType } from 'fast-graphql';
22

3+
import * as schemaType from '@/graphql/generated/schemaType';
4+
35
const Query = {
46
proprietyList: () => {
57
return [{ title: 'Nextjs' }];
68
},
79

8-
propriety: (id: string) => {
9-
return { title: 'Nextjs' };
10+
propriety: (
11+
parent: any,
12+
args: any,
13+
ctx: any
14+
): schemaType.Query['propriety'] => {
15+
const { id } = args;
16+
17+
return { title: 'Nextjs', id };
1018
},
1119
};
1220

1321
const Mutation = {
14-
addPropriety: (body: any) => {
22+
addPropriety: (body: any): schemaType.Mutation['addPropriety'] => {
1523
return { title: 'this is addPropriety mutuation' };
1624
},
1725
};

β€Žgraphql/resolvers/query/books.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žgraphql/resolvers/query/index.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žgraphql/resolvers/query/users.tsβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
Β (0)