File tree Expand file tree Collapse file tree 4 files changed +42
-18
lines changed Expand file tree Collapse file tree 4 files changed +42
-18
lines changed Original file line number Diff line number Diff line change 10
10
"lint" : " tslint -p ."
11
11
},
12
12
"dependencies" : {
13
- "@vichurch/model" : " 1.1.1 " ,
13
+ "@vichurch/model" : " 1.1.2 " ,
14
14
"bara" : " 2.4.0" ,
15
15
"bcryptjs" : " 2.4.3" ,
16
16
"graphql-yoga" : " 1.17.4" ,
Original file line number Diff line number Diff line change 1
1
import { Context } from '../../utils'
2
2
3
- export async function getLocalizationsByLang (
3
+ export interface Label {
4
+ key : string
5
+ text : string
6
+ }
7
+
8
+ export async function labels (
4
9
parent ,
5
- { lang } ,
10
+ { code } ,
6
11
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
12
+ ) : Promise < Array < Label > > {
13
+ const query = `
14
+ query labels($code: String) {
15
+ translations(where: {language: {code: $code}}) {
16
+ language {
17
+ name
18
+ }
19
+ localization {
20
+ key
21
+ }
22
+ text
23
+ }
24
+ }
25
+ `
26
+ const res = await ctx . prisma . $graphql ( query , { code } )
27
+ const labels = res . translations . map ( ( r : any ) => ( {
28
+ key : r . localization . key ,
29
+ text : r . text ,
30
+ } ) )
31
+ return labels
32
+ }
33
+
34
+ export async function localizations ( parent , args , ctx : Context ) {
35
+ return ctx . prisma . localizations ( )
17
36
}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ type Query {
5
5
activitySchedules : [ActivitySchedule ! ]
6
6
localizations : [Localization ! ]
7
7
me : User
8
- getLocalizationsByLang ( lang : String ! ): [Localization ! ]!
8
+ labels ( code : String ! ): [Label ! ]!
9
9
}
10
10
11
11
type Mutation {
@@ -19,6 +19,11 @@ type Subscription {
19
19
profileSubscription : Profile
20
20
}
21
21
22
+ type Label {
23
+ key : String !
24
+ text : String !
25
+ }
26
+
22
27
type AuthPayload {
23
28
token : String !
24
29
user : User !
Original file line number Diff line number Diff line change 190
190
version "0.5.4"
191
191
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.5.4.tgz#b863a4191e525206819e008097ebf0fb2e3a1cdc"
192
192
193
-
194
- version "1.1.1 "
195
- resolved "https://registry.yarnpkg.com/@vichurch/model/-/model-1.1.1 .tgz#004c0c52adec1115f76fb9fbf704a1f4faea4cca "
196
- integrity sha512-7igPPXLJTavbGMozJsM3iaT5O+dvUO70UK5aczvqWLbcVPpl9ZHMG+D09t5XScNb7JzKC021MK1I3lKbAxlATg ==
193
+
194
+ version "1.1.2 "
195
+ resolved "https://registry.yarnpkg.com/@vichurch/model/-/model-1.1.2 .tgz#835a602c02e4fe17837baeca7663cd7d5b450a33 "
196
+ integrity sha512-gd571cir/qZkU0pkLIzf1XJncYomsjtdIHx7yv64hbLloOXyaEYE+vZQUHRli3xGlu0LgUmciY5BK+8VgQRNag ==
197
197
dependencies :
198
198
graphql "14.1.1"
199
199
prisma-client-lib "1.26.3"
You can’t perform that action at this time.
0 commit comments