Skip to content

Commit

Permalink
QueryMutationとrootのResolverをリファクタリング (#1045)
Browse files Browse the repository at this point in the history
* `Query`と`Mutation`とrootのResolverをリファクタリング

Fixes #1042
Fixes #1036

* fx
  • Loading branch information
SnO2WMaN authored Dec 8, 2023
1 parent 8919aa0 commit d5c90c0
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 276 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { mkNeo4jService } from "./Neo4j/Neo4j.service.js";
import { mkNicovideoRegistrationRequestService } from "./NicovideoRegistrationRequest/NicovideoRegistrationRequest.service.js";
import { mkNicovideoRegistrationRequestEventService } from "./NicovideoRegistrationRequest/NicovideoRegistrationRequestEvent.service.js";
import { NicochuuService } from "./protobuf/nicochuu_connect.js";
import { makeResolvers } from "./resolvers/index.js";
import { makeResolvers } from "./resolvers.js";
import { CurrentUser, ServerContext, UserContext } from "./resolvers/types.js";
import typeDefs from "./schema.graphql";
import { mkSoundcloudMADSourceService } from "./SoundcloudMADSource/SoundcloudMADSource.service.js";
Expand Down
File renamed without changes.
68 changes: 68 additions & 0 deletions src/mutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* eslint sort-keys: 2 */

import { mkRegisterBilibiliMADResolver } from "./BilibiliMADSource/registerBilibiliMAD.resolver.js";
import { mkRequestBilibiliRegistrationResolver } from "./BilibiliRegistrationRequest/requestBilibiliRegistration.resolver.js";
import { resolverRejectRequestNicovideoRegistration } from "./NicovideoRegistrationRequest/rejectNicovideoRegistrationRequest.resolver.js";
import { resolverRequestNicovideoRegistration } from "./NicovideoRegistrationRequest/requestNicovideoRegistration.resolver.js";
import { resolverRegisterVideoFromNicovideo } from "./NicovideoVideoSource/registerVideoFromNicovideo.resolver.js";
import { type Resolvers } from "./resolvers/graphql.js";
import { addMylistToMylistGroup } from "./resolvers/Mutation/addMylistToMylistGroup/addMylistToMylistGroup.js";
import { addSemitagToVideo } from "./resolvers/Mutation/addSemitagToVideo/addSemitagToVideo.js";
import { addVideoToMylist } from "./resolvers/Mutation/addVideoToMylist/addVideoToMylist.js";
import { resolverChangeMylistShareRange } from "./resolvers/Mutation/changeMylistShareRange/resolver.js";
import { resolverChangeUserDisplayName } from "./resolvers/Mutation/changeUserDisplayName/resolver.js";
import { createMylist } from "./resolvers/Mutation/createMylist/createMylist.js";
import { createMylistGroup } from "./resolvers/Mutation/createMylistGroup/createMylistGroup.js";
import { resolverLikeVideo } from "./resolvers/Mutation/likeVideo/resolver.js";
import { resolverRejectSemitag } from "./resolvers/Mutation/rejectSemitag/resolver.js";
import { removeVideoFromMylist } from "./resolvers/Mutation/removeVideoFromMylist/removeVideoFromMylist.js";
import { resolverResolveSemitag } from "./resolvers/Mutation/resolveSemitag/resolver.js";
import { resolverUndoLikeVideo } from "./resolvers/Mutation/undoLikeVideo/resolver.js";
import { resolverWatchNotifications } from "./resolvers/Mutation/watchNotifications/resolver.js";
import { ResolverDeps } from "./resolvers/types.js";
import { mkRegisterSoundcloudMADResolver } from "./SoundcloudMADSource/registerSoundcloudMAD.resolver.js";
import { mkRequestSoundcloudRegistrationResolver } from "./SoundcloudRegistrationRequest/requestSoundcloudRegistration.resolver.js";
import { resolverAddTagToVideo } from "./Tag/addTagToVideo.resolver.js";
import { resolverExplicitizeTagParent } from "./Tag/explicitizeTagParent.resolver.js";
import { resolverImplicitizeTagParent } from "./Tag/implicitizeTagParent.resolver.js";
import { registerCategoryTag } from "./Tag/registerCategoryTag.resolver.js";
import { resolverRegisterCategoryTagTyping } from "./Tag/registerCategoryTagTyping.resolver.js";
import { resolverRegisterTag } from "./Tag/registerTag.resolver.js";
import { resolverRegisterTagParentRelation } from "./Tag/registerTagParentRelation.resolver.js";
import { resolverRemoveTagFromVideo } from "./Tag/removeTagFromVideo.resolver.js";
import { mkRequestYoutubeRegistrationResolver } from "./YoutubeRegistrationRequest/requestYoutubeRegistration.resolver.js";
import { resolverRegisterVideoFromYoutube } from "./YoutubeVideoSource/registerVideoFromYoutube.resolver.js";

export const resolveMutation = (deps: ResolverDeps) =>
({
addMylistToMylistGroup: addMylistToMylistGroup(deps),
addSemitagToVideo: addSemitagToVideo(deps),
addTagToVideo: resolverAddTagToVideo(deps),
addVideoToMylist: addVideoToMylist(deps),
changeMylistShareRange: resolverChangeMylistShareRange(deps),
changeUserDisplayName: resolverChangeUserDisplayName(deps),
createMylist: createMylist(deps),
createMylistGroup: createMylistGroup(deps),
explicitizeTagParent: resolverExplicitizeTagParent(deps),
implicitizeTagParent: resolverImplicitizeTagParent(deps),
likeVideo: resolverLikeVideo(deps),
registerBilibiliMAD: mkRegisterBilibiliMADResolver(deps),
registerCategoryTag: registerCategoryTag(deps),
registerCategoryTagTyping: resolverRegisterCategoryTagTyping(deps),
registerSoundcloudMAD: mkRegisterSoundcloudMADResolver(deps),
registerTag: resolverRegisterTag(deps),
registerTagParentRelation: resolverRegisterTagParentRelation(deps),
registerVideoFromNicovideo: resolverRegisterVideoFromNicovideo(deps),
registerVideoFromYoutube: resolverRegisterVideoFromYoutube(deps),
rejectNicovideoRegistrationRequest: resolverRejectRequestNicovideoRegistration(deps),
rejectSemitag: resolverRejectSemitag(deps),
removeTagFromVideo: resolverRemoveTagFromVideo(deps),
removeVideoFromMylist: removeVideoFromMylist(deps),
requestBilibiliRegistration: mkRequestBilibiliRegistrationResolver(deps),
requestNicovideoRegistration: resolverRequestNicovideoRegistration(deps),
requestSoundcloudRegistration: mkRequestSoundcloudRegistrationResolver(deps),
requestYoutubeRegistration: mkRequestYoutubeRegistrationResolver(deps),
resovleSemitag: resolverResolveSemitag(deps),
undoLikeVideo: resolverUndoLikeVideo(deps),
watchNotifications: resolverWatchNotifications(deps),
}) satisfies Required<Resolvers["Mutation"]>;
124 changes: 124 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* eslint sort-keys: [2, "asc", {caseSensitive: false}] */

import { mkFindBilibiliMADSourceResolver } from "./BilibiliMADSource/findBilibiliMADSource.resolver.js";
import { resolverGetBilibiliMADSource } from "./BilibiliMADSource/getBilibiliMADSource.resolver.js";
import { mkFindBilibiliRegistrationRequestByUrlResolver } from "./BilibiliRegistrationRequest/findBilibiliRegistrationRequestBySourceId.resolver.js";
import { resolverFindUncheckedBilibiliRegistrationRequests } from "./BilibiliRegistrationRequest/findUncheckedBilibiliRegistrationRequests.resolver.js";
import { resolverGetBilibiliRegistrationRequest } from "./BilibiliRegistrationRequest/getBilibiliRegistrationRequest.resolver.js";
import { resolverFetchBilibili } from "./FetchExternal/fetchBilibili.resolver.js";
import { fetchNicovideo } from "./FetchExternal/fetchNicovideo.js";
import { mkFetchSoundcloudResolver } from "./FetchExternal/fetchSoundcloud.resolver.js";
import { resolverFetchYoutube } from "./FetchExternal/fetchYoutube.js";
import { mkListNicovideoBotRegistrationRequestsResolver } from "./NicovideoBotRegistrationRequest/listNicovideoBotRegistrationRequests.resolver.js";
import { resolverFindNicovideoRegistrationRequest } from "./NicovideoRegistrationRequest/findNicovideoRegistrationRequest.resolver.js";
import { findNicovideoRegistrationRequests } from "./NicovideoRegistrationRequest/findNicovideoRegistrationRequests.resolver.js";
import { resolverFindUncheckedNicovideoRegistrationRequests } from "./NicovideoRegistrationRequest/findUncheckedNicovideoRegistrationRequests.resolver.js";
import { resolverFindUncheckedNicovideoRegistrationRequestsByOffset } from "./NicovideoRegistrationRequest/findUncheckedNicovideoRegistrationRequestsByOffset.resolver.js";
import { resolverGetNicovideoRegistrationRequest } from "./NicovideoRegistrationRequest/getNicovideoRegistrationRequest.js";
import { resolverFindNicovideoVideoSource } from "./NicovideoVideoSource/findNicovideoVideoSource.resolver.js";
import { getNicovideoVideoSource } from "./NicovideoVideoSource/getNicovideoVideoSource.resolver.js";
import { type Resolvers } from "./resolvers/graphql.js";
import { resolverFindMylist } from "./resolvers/Query/findMylist/findMylist.js";
import { findSemitags } from "./resolvers/Query/findSemitags/findSemitags.js";
import { getMylist } from "./resolvers/Query/getMylist/resolver.js";
import { getMylistGroup } from "./resolvers/Query/getMylistGroup/resolver.js";
import { getNotification } from "./resolvers/Query/getNotification/resolver.js";
import { resolverGetSemitag } from "./resolvers/Query/getSemitag/resolver.js";
import { resolverNotifications } from "./resolvers/Query/notifications/resolver.js";
import { resolverWhoami } from "./resolvers/Query/whoami/resolver.js";
import { ResolverDeps } from "./resolvers/types.js";
import { mkFindSoundcloudMADSourceResolver } from "./SoundcloudMADSource/findSoundcloudMADSource.resolver.js";
import { getSoundcloudMADSource } from "./SoundcloudMADSource/getSoundcloudMADSource.resolver.js";
import { resolverFindSoundcloudRegistrationRequest } from "./SoundcloudRegistrationRequest/findSoundcloudRegistrationRequest.resolver.js";
import { mkFindSoundcloudRegistrationRequestByUrlResolver } from "./SoundcloudRegistrationRequest/findSoundcloudRegistrationRequestByUrl.resolver.js";
import { resolverFindUncheckedSoundcloudRegistrationRequests } from "./SoundcloudRegistrationRequest/findUncheckedSoundcloudRegistrationRequests.resolver.js";
import { resolverGetSoundcloudRegistrationRequest } from "./SoundcloudRegistrationRequest/getSoundcloudRegistrationRequest.resolver.js";
import { mkCountAllTagsResolver } from "./Tag/countAllTags.resolver.js";
import { resolverFindTag } from "./Tag/findTag.resolver.js";
import { resolverFindTagBySerial } from "./Tag/findTagBySerial.resolver.js";
import { resolverFindTags } from "./Tag/findTags.resolver.js";
import { resolverGetAllCategoryTag } from "./Tag/getAllCategoryTag.resolver.js";
import { resolverGetAllTypeCategoryTag } from "./Tag/getAllTypeCategoryTag.resolver.js";
import { resolverGetTag } from "./Tag/getTag.resolver.js";
import { resolverSearchTags } from "./Tag/searchTags.resolver.js";
import { mkShowTimelineResolver } from "./Timeline/showTimeline.resolver.js";
import { resolverFindUser } from "./User/findUser.resolver.js";
import { resolverGetUser } from "./User/getUser.resolver.js";
import { mkViewerResolver } from "./User/viewer.resolver.js";
import { mkCalcMadCountGrowthResolver } from "./Video/calcMadCountGrowth.resolver.js";
import { mkCountAllMadsResolver } from "./Video/countAllMads.resolver.js";
import { resolverFindMadBySerial } from "./Video/findMadBySerial.resolver.js";
import { mkFindMadsByOffsetResolver } from "./Video/findMadsByOffset.resolver.js";
import { resolverFindVideo } from "./Video/findVideo.resolver.js";
import { resolverFindVideos } from "./Video/findVideos.resolver.js";
import { resolverGetVideo } from "./Video/getVideo.resolver.js";
import { resolverSearchVideos } from "./Video/searchVideos.resolver.js";
import { resolverFindUncheckedYoutubeRegistrationRequests } from "./YoutubeRegistrationRequest/findUncheckedYoutubeRegistrationRequests.resolver.js";
import { resolverFindYoutubeRegistrationRequest } from "./YoutubeRegistrationRequest/findYoutubeRegistrationRequest.resolver.js";
import { resolverGetYoutubeRegistrationRequest } from "./YoutubeRegistrationRequest/getYoutubeRegistrationRequest.resolver.js";
import { resolverFindYoutubeVideoSource } from "./YoutubeVideoSource/findYoutubeVideoSource.resolver.js";
import { getYoutubeVideoSource } from "./YoutubeVideoSource/getYoutubeVideoSource.resolver.js";

export const resolveQuery = (deps: ResolverDeps) =>
({
calcMadCountGrowth: mkCalcMadCountGrowthResolver(deps),
countAllMads: mkCountAllMadsResolver(deps),
countAllTags: mkCountAllTagsResolver(deps),
fetchBilibili: resolverFetchBilibili(deps),
fetchNicovideo: fetchNicovideo(),
fetchSoundcloud: mkFetchSoundcloudResolver(deps),
fetchYoutube: resolverFetchYoutube(),
findBilibiliMADSource: mkFindBilibiliMADSourceResolver(deps),
findBilibiliRegistrationRequestBySourceId: mkFindBilibiliRegistrationRequestByUrlResolver(deps),
findMadBySerial: resolverFindMadBySerial(deps),
findMadsByOffset: mkFindMadsByOffsetResolver({
...deps,
logger: deps.logger.child({ resolver: "Query.findMadsByOffset" }),
}),
findMylist: resolverFindMylist(deps),
findNicovideoRegistrationRequest: resolverFindNicovideoRegistrationRequest(deps),
findNicovideoRegistrationRequests: findNicovideoRegistrationRequests(deps),
findNicovideoVideoSource: resolverFindNicovideoVideoSource(deps),
findSemitags: findSemitags(deps),
findSoundcloudMADSource: mkFindSoundcloudMADSourceResolver(deps),
findSoundcloudRegistrationRequest: resolverFindSoundcloudRegistrationRequest(deps),
findSoundcloudRegistrationRequestByUrl: mkFindSoundcloudRegistrationRequestByUrlResolver(deps),
findTag: resolverFindTag(deps),
findTagBySerial: resolverFindTagBySerial(deps),
findTags: resolverFindTags(deps),
findUncheckedBilibiliRegistrationRequests: resolverFindUncheckedBilibiliRegistrationRequests(deps),
findUncheckedNicovideoRegistrationRequests: resolverFindUncheckedNicovideoRegistrationRequests(deps),
findUncheckedNicovideoRegistrationRequestsByOffset:
resolverFindUncheckedNicovideoRegistrationRequestsByOffset(deps),
findUncheckedSoundcloudRegistrationRequests: resolverFindUncheckedSoundcloudRegistrationRequests(deps),
findUncheckedYoutubeRegistrationRequests: resolverFindUncheckedYoutubeRegistrationRequests(deps),
findUser: resolverFindUser(deps),
findVideo: resolverFindVideo(deps),
findVideos: resolverFindVideos(deps),
findYoutubeRegistrationRequest: resolverFindYoutubeRegistrationRequest(deps),
findYoutubeVideoSource: resolverFindYoutubeVideoSource(deps),
getAllCategoryTag: resolverGetAllCategoryTag(deps),
getAllTypeCategoryTag: resolverGetAllTypeCategoryTag(deps),
getBilibiliMADSource: resolverGetBilibiliMADSource(deps),
getBilibiliRegistrationRequest: resolverGetBilibiliRegistrationRequest(deps),
getMylist: getMylist(deps),
getMylistGroup: getMylistGroup(deps),
getNicovideoRegistrationRequest: resolverGetNicovideoRegistrationRequest(deps),
getNicovideoVideoSource: getNicovideoVideoSource(deps),
getNotification: getNotification(deps),
getSemitag: resolverGetSemitag(deps),
getSoundcloudMADSource: getSoundcloudMADSource(deps),
getSoundcloudRegistrationRequest: resolverGetSoundcloudRegistrationRequest(deps),
getTag: resolverGetTag(deps),
getUser: resolverGetUser(deps),
getVideo: resolverGetVideo(deps),
getYoutubeRegistrationRequest: resolverGetYoutubeRegistrationRequest(deps),
getYoutubeVideoSource: getYoutubeVideoSource(deps),
listNicovideoBotRegistrationRequests: mkListNicovideoBotRegistrationRequestsResolver(deps),
notifications: resolverNotifications(deps),
searchTags: resolverSearchTags(deps),
searchVideos: resolverSearchVideos(deps),
showTimeline: mkShowTimelineResolver(deps),
viewer: mkViewerResolver({ ...deps }),
whoami: resolverWhoami(deps),
}) satisfies Required<Resolvers["Query"]>;
Loading

0 comments on commit d5c90c0

Please sign in to comment.