Skip to content

Commit 829fdc4

Browse files
committed
fix(document-builder): alias does not inject index type
1 parent 1dd9ffa commit 829fdc4

File tree

17 files changed

+328
-415
lines changed

17 files changed

+328
-415
lines changed

src/documentBuilder/requestMethods/requestMethods.test-d.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ import { DateScalar } from '../../../tests/_/fixtures/scalars.js'
44
import type { db } from '../../../tests/_/schemas/db.js'
55
import { Graffle } from '../../../tests/_/schemas/kitchen-sink/graffle/__.js'
66
import * as Schema from '../../../tests/_/schemas/kitchen-sink/schema.js'
7+
import { Graffle as Pokemon } from '../../../tests/_/schemas/pokemon/graffle/__.js'
78

89
const graffle = Graffle.create({ schema: Schema.schema }).scalar(DateScalar)
910

10-
const x = await graffle.query.id({ $include: false })
11+
// const pokemons = await Pokemon.create().query.pokemons({id:true})
12+
1113
// dprint-ignore
1214
test(`query`, async () => {
15+
expectTypeOf(await graffle.query.object({id:['id2',true]})).toEqualTypeOf<{id2:null|string} | null>()
1316
// scalar
1417
expectTypeOf(await graffle.query.id()).toEqualTypeOf<string | null>()
1518
// scalar none-nullable
16-
expectTypeOf(await graffle.query.idNonNull()).toEqualTypeOf<null | string>()
19+
expectTypeOf(await graffle.query.idNonNull()).toEqualTypeOf<string>()
1720
// scalar with optional arguments
1821
expectTypeOf<Parameters<typeof graffle.query.stringWithArgs>>().toEqualTypeOf<[input?: Graffle.SelectionSets.Query.stringWithArgs]>()
1922
// scalar with required arguments
@@ -23,16 +26,14 @@ test(`query`, async () => {
2326

2427
// scalar with explicit indicators
2528
// positive indicator
26-
expectTypeOf(await graffle.query.idNonNull(true)).toEqualTypeOf<null |string>()
29+
expectTypeOf(await graffle.query.idNonNull(true)).toEqualTypeOf<string>()
2730
// negative indicator
2831
// todo
2932
// expectTypeOf(await graffle.query.idNonNull(false)).toEqualTypeOf<null>()
3033
// negative indicator via directive
3134
// todo
3235
// expectTypeOf(await graffle.query.idNonNull({ $skip: false })).toEqualTypeOf<null>()
3336

34-
const x = await graffle.query.dateObject1({ $scalars: true })
35-
3637
// object
3738
expectTypeOf(graffle.query.dateObject1({ date1: true })).resolves.toEqualTypeOf<{ date1: Date | null } | null>()
3839
expectTypeOf(graffle.query.unionFooBar({ ___on_Foo: { id: true }})).resolves.toEqualTypeOf<{} | { id: string | null } | null>()

src/entrypoints/utilities-for-generated.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ export type { ConfigGetOutputError, HandleOutput, HandleOutputGraffleRootField }
44
export type { Config } from '../client/Settings/Config.js'
55
export { type DocumentRunner } from '../documentBuilder/requestMethods/document.js'
66
export * from '../documentBuilder/Select/__.js'
7-
export { type Exact, type ExactNonEmpty, type SimplifyExcept, type UnionExpanded } from '../lib/prelude.js'
7+
export {
8+
type AssertExtendsObject,
9+
type Exact,
10+
type ExactNonEmpty,
11+
type SimplifyExcept,
12+
type UnionExpanded,
13+
} from '../lib/prelude.js'
814
export { TypeFunction } from '../lib/type-function/__.js'
915
export { type GlobalRegistry } from '../types/GlobalRegistry/GlobalRegistry.js'
1016
export { Schema } from '../types/Schema/__.js'

0 commit comments

Comments
 (0)