-
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
17 changed files
with
154 additions
and
254 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { getTopic } from "../../../usecases"; | ||
import type { ResResolvers } from "./../../types.generated"; | ||
|
||
export const ResBase: Omit<ResResolvers, "__resolveType"> = { | ||
topic: async (res, _args, context, _info) => { | ||
const topic = await getTopic({ id: res.topicID }, context.ports); | ||
return topic; | ||
}, | ||
}; |
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,13 +1,6 @@ | ||
import type { ResDeleteResolvers } from './../../types.generated'; | ||
export const ResDelete: ResDeleteResolvers = { | ||
/* Implement ResDelete resolver logic here */ | ||
date: () => { /* ResDelete.date resolver is required because ResDelete.date exists but ResDeleteMapper.date does not */ }, | ||
dv: () => { /* ResDelete.dv resolver is required because ResDelete.dv exists but ResDeleteMapper.dv does not */ }, | ||
hash: () => { /* ResDelete.hash resolver is required because ResDelete.hash exists but ResDeleteMapper.hash does not */ }, | ||
id: () => { /* ResDelete.id resolver is required because ResDelete.id exists but ResDeleteMapper.id does not */ }, | ||
replyCount: () => { /* ResDelete.replyCount resolver is required because ResDelete.replyCount exists but ResDeleteMapper.replyCount does not */ }, | ||
self: () => { /* ResDelete.self resolver is required because ResDelete.self exists but ResDeleteMapper.self does not */ }, | ||
topic: () => { /* ResDelete.topic resolver is required because ResDelete.topic exists but ResDeleteMapper.topic does not */ }, | ||
uv: () => { /* ResDelete.uv resolver is required because ResDelete.uv exists but ResDeleteMapper.uv does not */ }, | ||
voteFlag: () => { /* ResDelete.voteFlag resolver is required because ResDelete.voteFlag exists but ResDeleteMapper.voteFlag does not */ } | ||
}; | ||
import type { ResDeleteResolvers } from "./../../types.generated"; | ||
import { ResBase } from "./ResBase"; | ||
|
||
export const ResDelete: ResDeleteResolvers = { | ||
...ResBase, | ||
}; |
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,14 +1,14 @@ | ||
import type { ResForkResolvers } from './../../types.generated'; | ||
export const ResFork: ResForkResolvers = { | ||
/* Implement ResFork resolver logic here */ | ||
date: () => { /* ResFork.date resolver is required because ResFork.date exists but ResForkMapper.date does not */ }, | ||
dv: () => { /* ResFork.dv resolver is required because ResFork.dv exists but ResForkMapper.dv does not */ }, | ||
hash: () => { /* ResFork.hash resolver is required because ResFork.hash exists but ResForkMapper.hash does not */ }, | ||
id: () => { /* ResFork.id resolver is required because ResFork.id exists but ResForkMapper.id does not */ }, | ||
replyCount: () => { /* ResFork.replyCount resolver is required because ResFork.replyCount exists but ResForkMapper.replyCount does not */ }, | ||
self: () => { /* ResFork.self resolver is required because ResFork.self exists but ResForkMapper.self does not */ }, | ||
topic: () => { /* ResFork.topic resolver is required because ResFork.topic exists but ResForkMapper.topic does not */ }, | ||
uv: () => { /* ResFork.uv resolver is required because ResFork.uv exists but ResForkMapper.uv does not */ }, | ||
voteFlag: () => { /* ResFork.voteFlag resolver is required because ResFork.voteFlag exists but ResForkMapper.voteFlag does not */ }, | ||
fork: () => { /* ResFork.fork resolver is required because ResFork.fork exists but ResForkMapper.fork does not */ } | ||
}; | ||
import { getTopic } from "../../../usecases"; | ||
import type { ResForkResolvers } from "./../../types.generated"; | ||
import { ResBase } from "./ResBase"; | ||
|
||
export const ResFork: ResForkResolvers = { | ||
...ResBase, | ||
fork: async (res, _args, context, _info) => { | ||
const fork = await getTopic({ id: res.forkID }, context.ports); | ||
if (fork.type !== "fork") { | ||
throw new Error(); | ||
} | ||
return fork; | ||
}, | ||
}; |
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,14 +1,11 @@ | ||
import type { ResHistoryResolvers } from './../../types.generated'; | ||
export const ResHistory: ResHistoryResolvers = { | ||
/* Implement ResHistory resolver logic here */ | ||
date: () => { /* ResHistory.date resolver is required because ResHistory.date exists but ResHistoryMapper.date does not */ }, | ||
dv: () => { /* ResHistory.dv resolver is required because ResHistory.dv exists but ResHistoryMapper.dv does not */ }, | ||
hash: () => { /* ResHistory.hash resolver is required because ResHistory.hash exists but ResHistoryMapper.hash does not */ }, | ||
id: () => { /* ResHistory.id resolver is required because ResHistory.id exists but ResHistoryMapper.id does not */ }, | ||
replyCount: () => { /* ResHistory.replyCount resolver is required because ResHistory.replyCount exists but ResHistoryMapper.replyCount does not */ }, | ||
self: () => { /* ResHistory.self resolver is required because ResHistory.self exists but ResHistoryMapper.self does not */ }, | ||
topic: () => { /* ResHistory.topic resolver is required because ResHistory.topic exists but ResHistoryMapper.topic does not */ }, | ||
uv: () => { /* ResHistory.uv resolver is required because ResHistory.uv exists but ResHistoryMapper.uv does not */ }, | ||
voteFlag: () => { /* ResHistory.voteFlag resolver is required because ResHistory.voteFlag exists but ResHistoryMapper.voteFlag does not */ }, | ||
history: () => { /* ResHistory.history resolver is required because ResHistory.history exists but ResHistoryMapper.history does not */ } | ||
}; | ||
import { getHistory } from "../../../usecases"; | ||
import type { ResHistoryResolvers } from "./../../types.generated"; | ||
import { ResBase } from "./ResBase"; | ||
|
||
export const ResHistory: ResHistoryResolvers = { | ||
...ResBase, | ||
history: async (res, _args, context, _info) => { | ||
const history = await getHistory({ id: res.historyID }, context.ports); | ||
return history; | ||
}, | ||
}; |
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,15 +1,23 @@ | ||
import type { ResNormalResolvers } from './../../types.generated'; | ||
export const ResNormal: ResNormalResolvers = { | ||
/* Implement ResNormal resolver logic here */ | ||
date: () => { /* ResNormal.date resolver is required because ResNormal.date exists but ResNormalMapper.date does not */ }, | ||
dv: () => { /* ResNormal.dv resolver is required because ResNormal.dv exists but ResNormalMapper.dv does not */ }, | ||
hash: () => { /* ResNormal.hash resolver is required because ResNormal.hash exists but ResNormalMapper.hash does not */ }, | ||
id: () => { /* ResNormal.id resolver is required because ResNormal.id exists but ResNormalMapper.id does not */ }, | ||
replyCount: () => { /* ResNormal.replyCount resolver is required because ResNormal.replyCount exists but ResNormalMapper.replyCount does not */ }, | ||
self: () => { /* ResNormal.self resolver is required because ResNormal.self exists but ResNormalMapper.self does not */ }, | ||
topic: () => { /* ResNormal.topic resolver is required because ResNormal.topic exists but ResNormalMapper.topic does not */ }, | ||
uv: () => { /* ResNormal.uv resolver is required because ResNormal.uv exists but ResNormalMapper.uv does not */ }, | ||
voteFlag: () => { /* ResNormal.voteFlag resolver is required because ResNormal.voteFlag exists but ResNormalMapper.voteFlag does not */ }, | ||
profile: () => { /* ResNormal.profile resolver is required because ResNormal.profile exists but ResNormalMapper.profile does not */ }, | ||
reply: () => { /* ResNormal.reply resolver is required because ResNormal.reply exists but ResNormalMapper.reply does not */ } | ||
}; | ||
import { getProfile, getRes } from "../../../usecases"; | ||
import type { ResNormalResolvers } from "./../../types.generated"; | ||
import { ResBase } from "./ResBase"; | ||
|
||
export const ResNormal: ResNormalResolvers = { | ||
...ResBase, | ||
reply: async (res, _args, context, _info) => { | ||
if (res.replyID !== null) { | ||
const reply = await getRes({ id: res.replyID }, context.ports); | ||
return reply; | ||
} else { | ||
return null; | ||
} | ||
}, | ||
profile: async (res, _args, context, _info) => { | ||
if (res.profileID !== null) { | ||
const profile = await getProfile({ id: res.profileID }, context.ports); | ||
return profile; | ||
} else { | ||
return null; | ||
} | ||
}, | ||
}; |
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,5 +1,6 @@ | ||
import type { ResTopicResolvers } from './../../types.generated'; | ||
export const ResTopic: ResTopicResolvers = { | ||
/* Implement ResTopic resolver logic here */ | ||
topic: () => { /* ResTopic.topic resolver is required because ResTopic.topic exists but ResTopicMapper.topic does not */ } | ||
}; | ||
import type { ResTopicResolvers } from "./../../types.generated"; | ||
import { ResBase } from "./ResBase"; | ||
|
||
export const ResTopic: ResTopicResolvers = { | ||
...ResBase, | ||
}; |
19 changes: 15 additions & 4 deletions
19
packages/server/src/schema/res/resolvers/Subscription/resAdded.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,4 +1,15 @@ | ||
import type { SubscriptionResolvers } from './../../../types.generated'; | ||
export const resAdded: NonNullable<SubscriptionResolvers['resAdded']> = { | ||
subscribe: async (_parent, _arg, _ctx) => { /* Implement Subscription.resAdded resolver logic here */ }, | ||
} | ||
import type { SubscriptionResolvers } from "./../../../types.generated"; | ||
import * as ixa from "ix/asynciterable"; | ||
import * as ixaOps from "ix/asynciterable/operators"; | ||
|
||
export const resAdded: NonNullable<SubscriptionResolvers["resAdded"]> = { | ||
subscribe: (_parent, args, context, _info) => | ||
ixa.from(context.ports.resRepo.subscribeInsertEvent(args.topic)).pipe( | ||
ixaOps.map((data) => ({ | ||
resAdded: { | ||
count: data.count, | ||
res: data.res.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
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,16 @@ | ||
import type { TopicResolvers } from "./../../types.generated"; | ||
import * as O from "fp-ts/lib/Option"; | ||
|
||
export const TopicBase: Omit<TopicResolvers, "__resolveType"> = { | ||
subscribe: async (topic, _args, context, _info) => { | ||
// TODO: N+1 | ||
const token = context.ports.authContainer.getTokenOrNull(); | ||
if (O.isNone(token)) { | ||
return null; | ||
} | ||
return await context.ports.topicRepo.getSubscription( | ||
topic.id, | ||
token.value.user | ||
); | ||
}, | ||
}; |
Oops, something went wrong.