Skip to content

Commit 1238a1c

Browse files
committed
fix(ts-client): thunk list objects
1 parent cebd26d commit 1238a1c

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

src/Schema/Output/types/List.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { Base } from '../../core/helpers.js'
1+
import type { Base, MaybeThunk } from '../../core/helpers.js'
22
import type { Named } from '../typeGroups.js'
33
import type { Nullable } from './Nullable.js'
44

55
type InnerType = Named | Nullable<any> | List<any>
66

77
export type List<$Type extends InnerType> = Base.List<$Type>
88

9-
export const List = <$Type extends InnerType>(type: $Type): List<$Type> => ({
9+
export const List = <$Type extends InnerType>(type: MaybeThunk<$Type>): List<$Type> => ({
1010
kind: `list`,
11-
type,
11+
// at type level "type" is not a thunk
12+
type: type as any, // eslint-disable-line
1213
})

src/generator/__snapshots__/files.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export namespace Root {
123123
}>
124124
>
125125
fooBarUnion: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
126+
objectList: $.Field<$.Output.Nullable<$.Output.List<$.Output.Nullable<Object.Object1>>>, null>
127+
objectListNonNull: $.Field<$.Output.List<Object.Object1>, null>
126128
/**
127129
* Query enum field documentation.
128130
*/
@@ -422,6 +424,8 @@ export const Query = $.Object$(\`Query\`, {
422424
}),
423425
),
424426
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
427+
objectList: $.field($.Output.Nullable($.Output.List($.Output.Nullable(() => Object1)))),
428+
objectListNonNull: $.field($.Output.List(() => Object1)),
425429
abcEnum: $.field($.Output.Nullable(ABCEnum)),
426430
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
427431
interface: $.field($.Output.Nullable(() => Interface)),

tests/ts/_/schema/generated/SchemaBuildtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export namespace Root {
120120
}>
121121
>
122122
fooBarUnion: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
123+
objectList: $.Field<$.Output.Nullable<$.Output.List<$.Output.Nullable<Object.Object1>>>, null>
124+
objectListNonNull: $.Field<$.Output.List<Object.Object1>, null>
123125
/**
124126
* Query enum field documentation.
125127
*/

tests/ts/_/schema/generated/SchemaRuntime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export const Query = $.Object$(`Query`, {
143143
}),
144144
),
145145
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
146+
objectList: $.field($.Output.Nullable($.Output.List($.Output.Nullable(() => Object1)))),
147+
objectListNonNull: $.field($.Output.List(() => Object1)),
146148
abcEnum: $.field($.Output.Nullable(ABCEnum)),
147149
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
148150
interface: $.field($.Output.Nullable(() => Interface)),

tests/ts/_/schema/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type Query {
3333
objectNested: ObjectNested
3434
objectWithArgs(string:String, int:Int, float:Float, boolean:Boolean, id:ID): Object1
3535
fooBarUnion: FooBarUnion
36+
objectList: [Object1]
37+
objectListNonNull: [Object1!]!
3638
"""
3739
Query enum field documentation.
3840
"""

0 commit comments

Comments
 (0)