File tree Expand file tree Collapse file tree 4 files changed +65
-12
lines changed Expand file tree Collapse file tree 4 files changed +65
-12
lines changed Original file line number Diff line number Diff line change @@ -190,13 +190,15 @@ npm-types:generate-graphql:
190
190
- .rails
191
191
stage : build
192
192
script :
193
- - bundle exec rake graphql:schema:idl
193
+ - bundle exec rake graphql:schema:dump
194
194
artifacts :
195
195
expire_in : 7 days
196
196
paths :
197
197
- tmp/schema.graphql
198
+ - tmp/schema.json
198
199
- tooling/graphql/types/
199
200
201
+
200
202
.npm-types:publish-graphql :
201
203
image : node:22.16.0
202
204
needs :
@@ -218,6 +220,10 @@ npm-types:publish-graphql-dry-run:
218
220
script :
219
221
- !reference [.npm-types:publish-graphql, script]
220
222
- npm publish --dry-run
223
+ artifacts :
224
+ expire_in : 7 days
225
+ paths :
226
+ - tooling/graphql/types/index.d.ts
221
227
rules :
222
228
- if : $C0_GH_REF_NAME != "main"
223
229
Original file line number Diff line number Diff line change
1
+ import type { CodegenConfig } from '@graphql-codegen/cli' ;
2
+ import { readFileSync } from "node:fs" ;
3
+
4
+ type Schema = {
5
+ data : {
6
+ __schema : {
7
+ types : Array < { kind : string ; name : string ; } > ;
8
+ } ;
9
+ } ;
10
+ }
11
+
12
+ const schemaData = readFileSync ( '../../../tmp/schema.json' , 'utf-8' ) ;
13
+ const schema : Schema = JSON . parse ( schemaData ) ;
14
+
15
+ const globalIds = schema . data . __schema . types
16
+ . filter ( type => type . kind === 'SCALAR' && type . name . endsWith ( 'ID' ) )
17
+
18
+ const scalars = {
19
+ JSON : {
20
+ input : 'any' ,
21
+ output : 'any' ,
22
+ } ,
23
+ Time : {
24
+ input : 'string' ,
25
+ output : 'string' ,
26
+ }
27
+ }
28
+
29
+
30
+ globalIds . forEach ( type => {
31
+ const typeConfig = `\`gid://sagittarius/${ type . name . replace ( / I D $ / , '' ) } /\${number}\``
32
+
33
+ scalars [ type . name ] = {
34
+ input : typeConfig ,
35
+ output : typeConfig ,
36
+ } ;
37
+ } ) ;
38
+
39
+
40
+ const config : CodegenConfig = {
41
+ schema : "../../../tmp/schema.graphql" ,
42
+ generates : {
43
+ './index.d.ts' : {
44
+ plugins : [
45
+ "typescript"
46
+ ] ,
47
+ config : {
48
+ scalars,
49
+ strictScalars : true ,
50
+ declarationKind : 'interface' ,
51
+ }
52
+ } ,
53
+ } ,
54
+ } ;
55
+
56
+
57
+ export default config ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
"main" : " index.js" ,
6
6
"types" : " index.d.ts" ,
7
7
"scripts" : {
8
- "generate" : " graphql-codegen --config codegen.yml "
8
+ "generate" : " graphql-codegen --config codegen.ts "
9
9
},
10
10
"repository" : {
11
11
"type" : " git" ,
You can’t perform that action at this time.
0 commit comments