-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
194 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const query: NonNullable<QueryResolvers['query']> = async (_parent, _arg, _ctx) => { /* Implement Query.query resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const query: NonNullable<QueryResolvers["query"]> = async ( | ||
_obj, | ||
_args, | ||
_ctx, | ||
_info | ||
) => { | ||
return {}; | ||
}; |
20 changes: 18 additions & 2 deletions
20
packages/server/src/schema/client/resolvers/Query/clients.ts
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 |
---|---|---|
@@ -1,2 +1,18 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const clients: NonNullable<QueryResolvers['clients']> = async (_parent, _arg, _ctx) => { /* Implement Query.clients resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const clients: NonNullable<QueryResolvers["clients"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const clients = await context.ports.clientRepo.find( | ||
context.ports.authContainer.getTokenMasterOrNull(), | ||
{ | ||
id: args.query.id ?? null, | ||
self: args.query.self ?? null, | ||
} | ||
); | ||
return clients.map((c) => | ||
c.toAPI(context.ports.authContainer.getTokenMasterOrNull()) | ||
); | ||
}; |
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,13 @@ | ||
import { DateQuery } from "../ports/types"; | ||
import { stringToDate } from "./stringToDate"; | ||
import * as G from "./types.generated"; | ||
|
||
export function convertDateQuery(query: G.DateQuery | null): DateQuery | null { | ||
if (query === null) { | ||
return null; | ||
} | ||
return { | ||
date: stringToDate(query.date).toISOString(), | ||
type: query.type, | ||
}; | ||
} |
23 changes: 21 additions & 2 deletions
23
packages/server/src/schema/history/resolvers/Query/histories.ts
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const histories: NonNullable<QueryResolvers['histories']> = async (_parent, _arg, _ctx) => { /* Implement Query.histories resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
import { convertDateQuery } from "../../../convertDateQuery"; | ||
|
||
export const histories: NonNullable<QueryResolvers["histories"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const histories = await context.ports.historyRepo.find( | ||
{ | ||
id: args.query.id ?? null, | ||
date: convertDateQuery(args.query.date ?? null), | ||
topic: args.query.topic ?? null, | ||
}, | ||
args.limit | ||
); | ||
return histories.map((x) => | ||
x.toAPI(context.ports.authContainer.getTokenOrNull()) | ||
); | ||
}; |
21 changes: 19 additions & 2 deletions
21
packages/server/src/schema/profile/resolvers/Query/profiles.ts
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 |
---|---|---|
@@ -1,2 +1,19 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const profiles: NonNullable<QueryResolvers['profiles']> = async (_parent, _arg, _ctx) => { /* Implement Query.profiles resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const profiles: NonNullable<QueryResolvers["profiles"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const profiles = await context.ports.profileRepo.find( | ||
context.ports.authContainer, | ||
{ | ||
id: args.query.id ?? null, | ||
self: args.query.self ?? null, | ||
} | ||
); | ||
return profiles.map((p) => | ||
p.toAPI(context.ports.authContainer.getTokenOrNull()) | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,27 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const reses: NonNullable<QueryResolvers['reses']> = async (_parent, _arg, _ctx) => { /* Implement Query.reses resolver logic here */ }; | ||
import { convertDateQuery } from "../../../convertDateQuery"; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const reses: NonNullable<QueryResolvers["reses"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const reses = await context.ports.resRepo.find( | ||
context.ports.authContainer, | ||
{ | ||
id: args.query.id ?? null, | ||
date: convertDateQuery(args.query.date ?? null), | ||
topic: args.query.topic ?? null, | ||
hash: args.query.hash ?? null, | ||
profile: args.query.profile ?? null, | ||
notice: args.query.notice ?? null, | ||
reply: args.query.reply ?? null, | ||
self: args.query.self ?? null, | ||
text: args.query.text ?? null, | ||
}, | ||
args.limit | ||
); | ||
return reses.map((x) => | ||
x.toAPI(context.ports.authContainer.getTokenOrNull()) | ||
); | ||
}; |
19 changes: 17 additions & 2 deletions
19
packages/server/src/schema/storage/resolvers/Query/storages.ts
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 |
---|---|---|
@@ -1,2 +1,17 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const storages: NonNullable<QueryResolvers['storages']> = async (_parent, _arg, _ctx) => { /* Implement Query.storages resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const storages: NonNullable<QueryResolvers["storages"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const storages = await context.ports.storageRepo.find( | ||
context.ports.authContainer.getToken(), | ||
{ | ||
key: args.query.key ?? null, | ||
keyPrefix: args.query.keyPrefix ?? null, | ||
} | ||
); | ||
return storages.map((x) => x.toAPI(context.ports.authContainer.getToken())); | ||
}; |
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,6 @@ | ||
export function stringToDate(date: string | Date): Date { | ||
if (typeof date === "string") { | ||
return new Date(date); | ||
} | ||
return date; | ||
} |
12 changes: 10 additions & 2 deletions
12
packages/server/src/schema/topic/resolvers/Query/topicTags.ts
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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const topicTags: NonNullable<QueryResolvers['topicTags']> = async (_parent, _arg, _ctx) => { /* Implement Query.topicTags resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const topicTags: NonNullable<QueryResolvers["topicTags"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
return await context.ports.topicRepo.findTags(args.limit); | ||
}; |
23 changes: 21 additions & 2 deletions
23
packages/server/src/schema/topic/resolvers/Query/topics.ts
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const topics: NonNullable<QueryResolvers['topics']> = async (_parent, _arg, _ctx) => { /* Implement Query.topics resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const topics: NonNullable<QueryResolvers["topics"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
const topic = await context.ports.topicRepo.find( | ||
{ | ||
id: args.query.id ?? null, | ||
title: args.query.title ?? null, | ||
tags: args.query.tags ?? null, | ||
activeOnly: args.query.activeOnly ?? null, | ||
parent: args.query.parent ?? null, | ||
}, | ||
args.skip, | ||
args.limit | ||
); | ||
return topic.map((t) => t.toAPI()); | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,14 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const user: NonNullable<QueryResolvers['user']> = async (_parent, _arg, _ctx) => { /* Implement Query.user resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const user: NonNullable<QueryResolvers["user"]> = async ( | ||
_obj, | ||
_args, | ||
context, | ||
_info | ||
) => { | ||
return ( | ||
await context.ports.userRepo.findOne( | ||
context.ports.authContainer.getToken().user | ||
) | ||
).toAPI(); | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const userID: NonNullable<QueryResolvers['userID']> = async (_parent, _arg, _ctx) => { /* Implement Query.userID resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
export const userID: NonNullable<QueryResolvers["userID"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
return await context.ports.userRepo.findID(args.sn); | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
import type { QueryResolvers } from './../../../types.generated'; | ||
export const userSN: NonNullable<QueryResolvers['userSN']> = async (_parent, _arg, _ctx) => { /* Implement Query.userSN resolver logic here */ }; | ||
import type { QueryResolvers } from "./../../../types.generated"; | ||
|
||
export const userSN: NonNullable<QueryResolvers["userSN"]> = async ( | ||
_obj, | ||
args, | ||
context, | ||
_info | ||
) => { | ||
return (await context.ports.userRepo.findOne(args.id)).sn; | ||
}; |