Skip to content

Commit ee66c10

Browse files
committed
fix(ts-client): result types have no args
1 parent 512150d commit ee66c10

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/client/ResultSet/ResultSet.test-d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ test(`general`, () => {
4040
expectTypeOf<RS<{ object: { id: true } }>>().toEqualTypeOf<{ object: null | { id: string | null } }>()
4141
// non-nullable
4242
expectTypeOf<RS<{ objectNonNull: { id: true } }>>().toEqualTypeOf<{ objectNonNull: { id: string | null } }>()
43+
// with args
44+
expectTypeOf<RS<{ objectWithArgs: { $: { id: 'abc' }; id: true }}>>().toEqualTypeOf<{ objectWithArgs: null | { id: string | null } }>()
4345

4446
// scalars-wildcard
4547
expectTypeOf<RS<{ objectNonNull: { $scalars: true } }>>().toEqualTypeOf<{ objectNonNull: { __typename: "Object1"; string: null|string; int: null|number; float: null|number; boolean: null|boolean; id: null|string } }>()
@@ -53,6 +55,9 @@ test(`general`, () => {
5355
expectTypeOf<RS<{ fooBarUnion: { onFoo: { __typename: true } } }>>().toEqualTypeOf<{ fooBarUnion: null | {} | { __typename: "Foo" } }>()
5456
expectTypeOf<RS<{ fooBarUnion: { onFoo: { id: true } } }>>().toEqualTypeOf<{ fooBarUnion: null | {} | { id: null|string } }>()
5557
expectTypeOf<RS<{ fooBarUnion: { __typename: true; onFoo: { id: true } } }>>().toEqualTypeOf<{ fooBarUnion: null | { __typename: "Bar" } | { __typename: "Foo"; id: null|string } }>()
58+
// with Args
59+
expectTypeOf<RS<{ unionFooBarWithArgs: { $: { id: `abc` }, onFoo: { id: true } } }>>().toEqualTypeOf<{ unionFooBarWithArgs: null | {} | { id: null|string } }>()
60+
5661

5762
// Union fragments Case
5863
expectTypeOf<RS<{ lowerCaseUnion: { __typename:true, onLowerCaseObject: { id: true }, onLowerCaseObject2: { int: true } } }>>().toEqualTypeOf<{ lowerCaseUnion: null | { __typename: 'lowerCaseObject'; id: null|string } | { __typename: 'lowerCaseObject2'; int: null|number } }>()
@@ -67,6 +72,8 @@ test(`general`, () => {
6772
expectTypeOf<RS<{ interface: { __typename:true }}>>().toEqualTypeOf<{ interface: null | { __typename: 'Object1ImplementingInterface' } | { __typename: 'Object2ImplementingInterface' } }>()
6873
expectTypeOf<RS<{ interface: { onObject1ImplementingInterface: { __typename: true } }}>>().toEqualTypeOf<{ interface: null | { __typename: 'Object1ImplementingInterface' } | {}}>()
6974
expectTypeOf<RS<{ interface: { $scalars: true }}>>().toEqualTypeOf<{ interface: null | { __typename: 'Object1ImplementingInterface', id: null | string, int: null|number} | { __typename: 'Object2ImplementingInterface', id: null | string; boolean:null|boolean} }>()
75+
// with args
76+
expectTypeOf<RS<{ interfaceWithArgs: { $:{id:'abc'}; id: true }}>>().toEqualTypeOf<{ interfaceWithArgs: null | { id: null | string } }>()
7077

7178
// Alias
7279
// scalar

src/client/ResultSet/ResultSet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ export type Field<$SelectionSet, $Field extends SomeField, $Index extends Schema
6767
(
6868
| FieldDirectiveInclude<$SelectionSet>
6969
| FieldDirectiveSkip<$SelectionSet>
70-
| FieldType<$SelectionSet, $Field['type'], $Index>
70+
| FieldType<Omit<$SelectionSet, '$'>, $Field['type'], $Index>
7171
)
7272

7373
// dprint-ignore
7474
type FieldType<
7575
$SelectionSet,
7676
$Type extends Schema.Output.Any,
7777
$Index extends Schema.Index
78-
> =Simplify<
78+
> = Simplify<
7979
$Type extends Schema.__typename<infer $Value> ? $Value :
8080
$Type extends Schema.Output.Nullable<infer $InnerType> ? null | FieldType<$SelectionSet, $InnerType, $Index> :
8181
$Type extends Schema.Output.List<infer $InnerType> ? Array<FieldType<$SelectionSet, $InnerType, $Index>> :

0 commit comments

Comments
 (0)