File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33gql-codegen.mts
44check
55schema.json
6+ client-schema.json
7+ server-schema.json
Original file line number Diff line number Diff line change 11export { Actor , ActorContext , Config } from './config.js'
22export { run } from './main.js'
3- export { loadSchemaFromFile } from './schema/utils.js'
3+ export {
4+ loadClientSchemaFromFile ,
5+ loadServerSchemaFromFile
6+ } from './schema/utils.js'
47export * as actors from './actors/index.js'
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ export const clientSchema = z.object({
88 operations : z . record ( z . string ( ) , operationSchema ) ,
99 directives : z . record ( z . string ( ) , directiveSchema )
1010} )
11+ export type ClientSchema = z . infer < typeof clientSchema > ;
Original file line number Diff line number Diff line change 1- import { z } from 'zod/v4'
2- import { serverSchema } from './server.js'
3- import { clientSchema } from './client/root.js'
1+ import { ClientSchema } from './client/root.js' ;
2+ import { ServerSchema } from './server.js' ;
43
5- export const rootSchema = z . object ( {
6- server : serverSchema ,
7- client : clientSchema
8- } ) . strict ( )
9-
10- export type RootSchema = z . infer < typeof rootSchema >
4+ export interface RootSchema {
5+ server : ServerSchema
6+ client : ClientSchema
7+ }
Original file line number Diff line number Diff line change 11import { describe , it , expect } from 'vitest'
2- import testJSON from './test.json' with { type : 'json' }
3- import { rootSchema } from './root.js'
2+ import testServerJSON from './test-server.json' with { type : 'json' }
3+ import testClientJSON from './test-client.json' with { type : 'json' }
4+ import { serverSchema } from './server.js'
5+ import { clientSchema } from './client/root.js'
46
5- describe ( 'Schema ' , ( ) => {
7+ describe ( 'Server schema ' , ( ) => {
68 it ( 'Should parse ok' , ( ) => {
7- const result = rootSchema . safeParse ( testJSON )
9+ const result = serverSchema . safeParse ( testServerJSON )
10+ expect ( result . success , result . error ?. message || '' ) . toBe ( true )
11+ } )
12+ } )
13+
14+ describe ( 'Client schema' , ( ) => {
15+ it ( 'Should parse ok' , ( ) => {
16+ const result = clientSchema . safeParse ( testClientJSON )
817 expect ( result . success , result . error ?. message || '' ) . toBe ( true )
918 } )
1019} )
Original file line number Diff line number Diff line change @@ -106,3 +106,4 @@ export const serverSchema = z.object({
106106 scalars : z . array ( z . string ( ) ) ,
107107 inputs : z . record ( z . string ( ) , inputSchema )
108108} )
109+ export type ServerSchema = z . infer < typeof serverSchema > ;
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { PathOrFileDescriptor , readFileSync } from 'fs' ;
2- import { rootSchema , RootSchema } from './root.js' ;
2+ import { ServerSchema , serverSchema } from './server.js' ;
3+ import { ClientSchema , clientSchema } from './client/root.js' ;
34
4- export function loadSchemaFromFile ( p : PathOrFileDescriptor ) : RootSchema {
5- return rootSchema . parse ( JSON . parse ( readFileSync ( p ) . toString ( ) ) )
5+ export function loadServerSchemaFromFile (
6+ p : PathOrFileDescriptor
7+ ) : ServerSchema {
8+ return serverSchema . parse ( JSON . parse ( readFileSync ( p ) . toString ( ) ) )
9+ }
10+
11+ export function loadClientSchemaFromFile (
12+ p : PathOrFileDescriptor
13+ ) : ClientSchema {
14+ return clientSchema . parse ( JSON . parse ( readFileSync ( p ) . toString ( ) ) )
615}
You can’t perform that action at this time.
0 commit comments