Skip to content

Commit

Permalink
improve(document-builder): simplify results
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Nov 18, 2024
1 parent 829fdc4 commit f73aecd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/documentBuilder/InferResult/OutputObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IsNever } from 'type-fest'
import type { IsNever, Simplify } from 'type-fest'
import { assertEqual } from '../../lib/assert-equal.js'
import type { AssertExtendsObject, GetOrNever, SimplifyExcept, StringKeyof } from '../../lib/prelude.js'
import type { TSErrorDescriptive } from '../../lib/ts-error.js'
Expand Down Expand Up @@ -27,13 +27,15 @@ type OutputObject_<
$Schema extends Schema,
$Node extends Schema.OutputObject,
> =
Select.SelectScalarsWildcard.IsSelectScalarsWildcard<$SelectionSet> extends true
// todo this needs to be an extension and/or only available when sddm is present
// todo what about when scalars wildcard is combined with other fields like relations?
? ScalarsWildcard<$SelectionSet, $Schema, $Node>
:
& NonAliasKeys<$SelectionSet, $Schema, $Node>
& Alias<$Schema, $Node, $SelectionSet>
Simplify<
Select.SelectScalarsWildcard.IsSelectScalarsWildcard<$SelectionSet> extends true
// todo this needs to be an extension and/or only available when sddm is present
// todo what about when scalars wildcard is combined with other fields like relations?
? ScalarsWildcard<$SelectionSet, $Schema, $Node>
:
& NonAliasKeys<$SelectionSet, $Schema, $Node>
& Alias<$Schema, $Node, $SelectionSet>
>

// dprint-ignore
type NonAliasKeys<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> = {
Expand Down
2 changes: 0 additions & 2 deletions src/documentBuilder/requestMethods/requestMethods.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { Graffle as Pokemon } from '../../../tests/_/schemas/pokemon/graffle/__.

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

// const pokemons = await Pokemon.create().query.pokemons({id:true})

// dprint-ignore
test(`query`, async () => {
expectTypeOf(await graffle.query.object({id:['id2',true]})).toEqualTypeOf<{id2:null|string} | null>()
Expand Down

0 comments on commit f73aecd

Please sign in to comment.