From d5ff151e9e8f9e6d2cbc18da464742e34f74446c Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Fri, 20 Dec 2024 16:23:49 -0500 Subject: [PATCH] fix check errors --- src/lib/index.ts | 3 +- src/lib/server/pothos/schema/posts.ts | 8 ++-- src/lib/server/pothos/schema/users.ts | 59 +-------------------------- 3 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/lib/index.ts b/src/lib/index.ts index aa2aa7e..c7ab773 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,2 +1 @@ -// place files you want to import through the `$lib` alias in this folder. -export * from './components'; +// place files you want to import through the `$lib` alias in this folder. \ No newline at end of file diff --git a/src/lib/server/pothos/schema/posts.ts b/src/lib/server/pothos/schema/posts.ts index 1885f06..e02647b 100644 --- a/src/lib/server/pothos/schema/posts.ts +++ b/src/lib/server/pothos/schema/posts.ts @@ -61,7 +61,7 @@ builder.mutationFields((t) => ({ }, resolve: async (parent, args) => { const author = await prisma.user.findUnique({ - where: { id: Number(args.input.authorId) }, + where: { id: args.input.authorId }, }); if (!author) { throw new Error('Author does not exist!'); @@ -89,7 +89,7 @@ builder.mutationFields((t) => ({ resolve: async (parent, args) => { const post = await prisma.post.update({ where: { - id: Number(args.input.id), + id: args.input.id, }, data: { title: args.input.title ?? undefined, @@ -98,7 +98,7 @@ builder.mutationFields((t) => ({ ...(args.input.authorId && { author: { connect: { - id: Number(args.input.authorId), + id: args.input.authorId, }, }, }), @@ -107,4 +107,4 @@ builder.mutationFields((t) => ({ return post; }, }), -})); +})); \ No newline at end of file diff --git a/src/lib/server/pothos/schema/users.ts b/src/lib/server/pothos/schema/users.ts index 210ad57..6aef62b 100644 --- a/src/lib/server/pothos/schema/users.ts +++ b/src/lib/server/pothos/schema/users.ts @@ -16,27 +16,6 @@ export const User = builder.prismaObject('User', { }), }); -const CreateUser = builder.inputType('CreateUser', { - fields: (t) => ({ - email: t.string({ - required: true, - }), - name: t.string({ - required: true, - }), - }), -}); - -const UpdateUser = builder.inputType('UpdateUser', { - fields: (t) => ({ - id: t.id({ - required: true, - }), - email: t.string(), - name: t.string(), - }), -}); - builder.queryFields((t) => ({ users: t.prismaField({ type: [User], @@ -44,40 +23,4 @@ builder.queryFields((t) => ({ return await prisma.user.findMany(); }, }), -})); - -builder.mutationFields((t) => ({ - createUser: t.field({ - type: User, - args: { - input: t.arg({ required: true, type: CreateUser }), - }, - resolve: async (parent, args) => { - const post = await prisma.user.create({ - data: { - email: args.input.email, - name: args.input.name, - }, - }); - return post; - }, - }), - updateUser: t.field({ - type: User, - args: { - input: t.arg({ required: true, type: UpdateUser }), - }, - resolve: async (parent, args) => { - const post = await prisma.user.update({ - where: { - id: Number(args.input.id), - }, - data: { - email: args.input.email, - name: args.input.name ?? undefined, - }, - }); - return post; - }, - }), -})); +})); \ No newline at end of file