added user overview
This commit is contained in:
parent
b5738c610d
commit
2ac082a4e4
5 changed files with 107 additions and 14 deletions
|
|
@ -5,9 +5,17 @@ import { toUserSchema } from './mappers/userMapper';
|
|||
|
||||
export async function UserOneResolver(
|
||||
_: any,
|
||||
{ id }: QueryUserOneArgs,
|
||||
{ input }: QueryUserOneArgs,
|
||||
{ identity }: IdentityContext
|
||||
): Promise<User> {
|
||||
const model = await prisma.user.findUniqueOrThrow({ where: { id } });
|
||||
if (input.id == null && input.username == null) throw new Error('Invalid user input.');
|
||||
if (input.id != null && input.username != null) throw new Error('Invalid user input.');
|
||||
|
||||
const model = await prisma.user.findUniqueOrThrow({
|
||||
where: {
|
||||
id: input.id != null ? input.id : undefined,
|
||||
username: input.username != null ? input.username : undefined
|
||||
}
|
||||
});
|
||||
return toUserSchema(model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ scalar JSON
|
|||
|
||||
type Query {
|
||||
identity: Identity!
|
||||
userOne(id: ID!): User!
|
||||
userOne(input: UserOneInput!): User!
|
||||
bookOne(id: ID!): Book!
|
||||
bookMany(input: BookManyInput!): BookManyOutput!
|
||||
bookChapterOne(id: ID!): BookChapter!
|
||||
|
|
@ -58,6 +58,11 @@ type User {
|
|||
updatedAt: String!
|
||||
}
|
||||
|
||||
input UserOneInput {
|
||||
id: ID
|
||||
username: String
|
||||
}
|
||||
|
||||
input PaginationFilterInput {
|
||||
terms: String
|
||||
offset: Int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue