-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bec0861
commit 78214e2
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { User as DbUser } from '@prisma/client' | ||
import { ObjectType, Field, Int } from 'type-graphql' | ||
|
||
@ObjectType() | ||
export class User { | ||
constructor(user: DbUser) { | ||
this.id = user.id | ||
this.username = user.username | ||
this.name = user.name | ||
} | ||
|
||
@Field(() => Int) | ||
id: number | ||
|
||
@Field() | ||
username: string | ||
|
||
@Field() | ||
name: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Resolver, Query } from 'type-graphql' | ||
|
||
import { User } from '#graphql/models/UserModel' | ||
import { prisma } from '#src/prisma' | ||
|
||
@Resolver() | ||
export class UserResolver { | ||
@Query(() => [User]) | ||
async users(): Promise<User[]> { | ||
return prisma.user.findMany() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters