File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
src/core/edgedb/generator Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 1
1
import { createClient } from 'edgedb' ;
2
2
import { IndentationText , Project , QuoteKind } from 'ts-morph' ;
3
+ import { codecs , registerCustomScalarCodecs } from '../codecs' ;
3
4
import { generateSchema } from './generate-schema' ;
4
5
import { generateInlineQueries } from './inline-queries' ;
5
6
import { generateQueryBuilder } from './query-builder' ;
6
7
import { generateQueryFiles } from './query-files' ;
7
- import { changeScalarCodecsToOurCustomTypes } from './scalars' ;
8
+ import { setTsTypesFromOurScalarCodecs } from './scalars' ;
8
9
import { GeneratorParams } from './util' ;
9
10
10
11
( async ( ) => {
@@ -29,7 +30,8 @@ import { GeneratorParams } from './util';
29
30
edgedbDir : project . addDirectoryAtPath ( 'src/core/edgedb' ) ,
30
31
} ;
31
32
32
- changeScalarCodecsToOurCustomTypes ( ) ;
33
+ await registerCustomScalarCodecs ( client , codecs ) ;
34
+ setTsTypesFromOurScalarCodecs ( ) ;
33
35
34
36
try {
35
37
await generateQueryBuilder ( params ) ;
Original file line number Diff line number Diff line change 1
1
import { scalarToLiteralMapping } from '@edgedb/generate/dist/genutil.js' ;
2
2
import { mapEntries } from '@seedcompany/common' ;
3
- import { SCALAR_CODECS } from 'edgedb/dist/codecs/codecs.js' ;
4
- import { KNOWN_TYPENAMES } from 'edgedb/dist/codecs/consts.js' ;
5
3
import { codecs } from '../codecs' ;
6
4
7
5
export const customScalars = mapEntries ( codecs , ( codec ) => [
8
6
codec . info . ts ,
9
7
codec . info ,
10
8
] ) . asMap ;
11
9
12
- export function changeScalarCodecsToOurCustomTypes ( ) {
13
- for ( const codec of codecs ) {
14
- const fqName = `${ codec . info . module } ::${ codec . info . type } ` ;
15
-
16
- // codecs are used for edgeql files & inline queries ($.analyzeQuery)
17
- const id = KNOWN_TYPENAMES . get ( fqName ) ;
18
- id && SCALAR_CODECS . set ( id , new codec ( id ) ) ;
19
-
20
- // this is used for schema interfaces
21
- scalarToLiteralMapping [ fqName ] . type = codec . info . ts ;
10
+ export function setTsTypesFromOurScalarCodecs ( ) {
11
+ // this is used for schema interfaces
12
+ for ( const { info } of codecs ) {
13
+ const fqName = `${ info . module } ::${ info . type } ` ;
14
+ scalarToLiteralMapping [ fqName ] . type = info . ts ;
22
15
}
23
16
}
You can’t perform that action at this time.
0 commit comments