|
1 | 1 | import { getUserId, Context } from '../../utils'
|
2 | 2 |
|
3 | 3 | export const profile = {
|
4 |
| - async createProfile(parent, { title, content }, ctx: Context, info) { |
5 |
| - const userId = getUserId(ctx) |
6 |
| - return ctx.prisma.profiles() |
7 |
| - //return ctx.prisma.createProfile({ |
8 |
| - //title, |
9 |
| - //content, |
10 |
| - //author: { |
11 |
| - //connect: { id: userId }, |
12 |
| - //}, |
13 |
| - //}) |
14 |
| - }, |
15 |
| - |
| 4 | + //async createProfile(parent, { title, content }, ctx: Context, info) { |
| 5 | + //const userId = getUserId(ctx) |
| 6 | + //return ctx.prisma.profiles() |
| 7 | + //return ctx.prisma.createProfile({ |
| 8 | + //title, |
| 9 | + //content, |
| 10 | + //author: { |
| 11 | + //connect: { id: userId }, |
| 12 | + //}, |
| 13 | + //}) |
| 14 | + //}, |
16 | 15 | //async publish(parent, { id }, ctx: Context, info) {
|
17 |
| - //const userId = getUserId(ctx) |
18 |
| - //const postExists = await ctx.prisma.$exists.post({ |
19 |
| - //id, |
20 |
| - //author: { id: userId }, |
21 |
| - //}) |
22 |
| - //if (!postExists) { |
23 |
| - //throw new Error(`Post not found or you're not the author`) |
24 |
| - //} |
25 |
| - |
26 |
| - //return ctx.prisma.updatePost({ |
27 |
| - //where: { id }, |
28 |
| - //data: { published: true }, |
29 |
| - //}) |
| 16 | + //const userId = getUserId(ctx) |
| 17 | + //const postExists = await ctx.prisma.$exists.post({ |
| 18 | + //id, |
| 19 | + //author: { id: userId }, |
| 20 | + //}) |
| 21 | + //if (!postExists) { |
| 22 | + //throw new Error(`Post not found or you're not the author`) |
| 23 | + //} |
| 24 | + //return ctx.prisma.updatePost({ |
| 25 | + //where: { id }, |
| 26 | + //data: { published: true }, |
| 27 | + //}) |
30 | 28 | //},
|
31 |
| - |
32 | 29 | //async deletePost(parent, { id }, ctx: Context, info) {
|
33 |
| - //const userId = getUserId(ctx) |
34 |
| - //const postExists = await ctx.prisma.$exists.post({ |
35 |
| - //id, |
36 |
| - //author: { id: userId }, |
37 |
| - //}) |
38 |
| - //if (!postExists) { |
39 |
| - //throw new Error(`Post not found or you're not the author`) |
40 |
| - //} |
41 |
| - |
42 |
| - //return ctx.prisma.deletePost({ id }) |
| 30 | + //const userId = getUserId(ctx) |
| 31 | + //const postExists = await ctx.prisma.$exists.post({ |
| 32 | + //id, |
| 33 | + //author: { id: userId }, |
| 34 | + //}) |
| 35 | + //if (!postExists) { |
| 36 | + //throw new Error(`Post not found or you're not the author`) |
| 37 | + //} |
| 38 | + //return ctx.prisma.deletePost({ id }) |
43 | 39 | //},
|
44 | 40 | }
|
0 commit comments