Skip to content

Commit

Permalink
fix(document-builder): directive optional selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Nov 18, 2024
1 parent 3535e9e commit 1dd9ffa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/documentBuilder/InferResult/OutputObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@ type InlineFragmentKey_<$SelectionSet extends object, $Schema extends Schema, $N
: IsNeverViaDirective<$SelectionSet> extends true
? {}
: IsNullableViaDirective<$SelectionSet> extends true
? MakeObjectSelectionResultNullable<
? Partial<
OutputObject_<OmitDirectiveAndArgumentKeys<$SelectionSet>, $Schema, $Node>
>
: OutputObject_<OmitDirectiveAndArgumentKeys<$SelectionSet>, $Schema, $Node>

type MakeObjectSelectionResultNullable<$Result extends object> = {
[_ in keyof $Result]: null | $Result[_]
}

// dprint-ignore
type PickPositiveIndicatorAndNotAlias<$SelectionSet> = StringKeyof<
{
Expand Down
4 changes: 2 additions & 2 deletions src/documentBuilder/InferResult/__.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ assertEqual<$<{ stringWithArgs: { $: { string: '' } } }>, { stringWithArgs: null
assertEqual<$<{ ___: { id: true }}> , { id: null | string }>()
assertEqual<$<{ ___: { $include: false; id: true }}> , {}>()
assertEqual<$<{ ___: { $skip: true; id: true }}> , {}>()
assertEqual<$<{ ___: { $skip: boolean; idNonNull: true; listIntNonNull:true }}> , { idNonNull: string | null; listIntNonNull: number[] | null }>()
assertEqual<$<{ ___: { $include: boolean; idNonNull: true; listIntNonNull:true }}> , { idNonNull: string | null; listIntNonNull: number[] | null }>()
assertEqual<$<{ ___: { $skip: boolean; id: true; listIntNonNull:true }}> , { id?: string | null; listIntNonNull?: number[] }>()
assertEqual<$<{ ___: { $include: boolean; id: true; listIntNonNull:true }}> , { id?: string | null; listIntNonNull?: number[] }>()

// Errors
// @ts-expect-error invalid query
Expand Down

0 comments on commit 1dd9ffa

Please sign in to comment.