Skip to content

Commit 40aaec8

Browse files
committed
refactor(resolvers): separated Query
1 parent 575f6ee commit 40aaec8

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

src/resolvers/Mutation/activity-schedule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export async function addActivitySchedule(
1414
end,
1515
})
1616
} else {
17-
throw new Error('Not authorized user!')
17+
throw new Error('Not authorize, user!')
1818
}
1919
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Context } from '../../utils'
2+
3+
export async function getLocalizationsByLang(
4+
parent,
5+
{ lang },
6+
ctx: Context,
7+
info,
8+
) {
9+
console.log('Fetch localization for lang', lang)
10+
const map = new Map()
11+
const localizations = await ctx.prisma.localizations()
12+
for (let l of localizations) {
13+
const key = l.key
14+
console.log(key)
15+
}
16+
return localizations
17+
}

src/resolvers/Query/Profile.ts

Whitespace-only changes.

src/resolvers/Query/User.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getUserId, Context } from '../../utils'
2+
3+
export function me(parent, args, ctx: Context) {
4+
const id = getUserId(ctx)
5+
return ctx.prisma.user({ id })
6+
}

src/resolvers/Query/index.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
import { getUserId, Context } from '../../utils'
22

3-
export const Query = {
4-
translation(parent, { id }, ctx: Context) {
5-
return ctx.prisma.translation({ id })
6-
},
7-
localization(parent, { id }, ctx: Context) {
8-
return ctx.prisma.localization({ id })
9-
},
10-
profile(parent, { id }, ctx: Context) {
11-
return ctx.prisma.profile({ id })
12-
},
13-
activitySchedules(parent, args, ctx: Context) {
14-
return ctx.prisma.activitySchedules()
15-
},
16-
me(parent, args, ctx: Context) {
17-
const id = getUserId(ctx)
18-
return ctx.prisma.user({ id })
19-
},
20-
async getLocalizationsByLang(parent, { lang }, ctx: Context, info) {
21-
console.log('Fetch localization for lang', lang)
22-
const localizations = await ctx.prisma.localizations()
23-
return localizations
24-
},
25-
}
3+
export * from './Localization'
4+
export * from './User'

src/resolvers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Query } from './Query'
1+
import * as Query from './Query'
22
import * as Type from './Type'
33
import * as Subscription from './Subscription'
44
import * as Mutation from './Mutation'

0 commit comments

Comments
 (0)