Skip to content

Commit

Permalink
fix(ts-client): thunk list objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Apr 14, 2024
1 parent cebd26d commit 1238a1c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Schema/Output/types/List.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { Base } from '../../core/helpers.js'
import type { Base, MaybeThunk } from '../../core/helpers.js'
import type { Named } from '../typeGroups.js'
import type { Nullable } from './Nullable.js'

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

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

export const List = <$Type extends InnerType>(type: $Type): List<$Type> => ({
export const List = <$Type extends InnerType>(type: MaybeThunk<$Type>): List<$Type> => ({
kind: `list`,
type,
// at type level "type" is not a thunk
type: type as any, // eslint-disable-line
})
4 changes: 4 additions & 0 deletions src/generator/__snapshots__/files.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export namespace Root {
}>
>
fooBarUnion: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
objectList: $.Field<$.Output.Nullable<$.Output.List<$.Output.Nullable<Object.Object1>>>, null>
objectListNonNull: $.Field<$.Output.List<Object.Object1>, null>
/**
* Query enum field documentation.
*/
Expand Down Expand Up @@ -422,6 +424,8 @@ export const Query = $.Object$(\`Query\`, {
}),
),
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
objectList: $.field($.Output.Nullable($.Output.List($.Output.Nullable(() => Object1)))),
objectListNonNull: $.field($.Output.List(() => Object1)),
abcEnum: $.field($.Output.Nullable(ABCEnum)),
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
interface: $.field($.Output.Nullable(() => Interface)),
Expand Down
2 changes: 2 additions & 0 deletions tests/ts/_/schema/generated/SchemaBuildtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export namespace Root {
}>
>
fooBarUnion: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
objectList: $.Field<$.Output.Nullable<$.Output.List<$.Output.Nullable<Object.Object1>>>, null>
objectListNonNull: $.Field<$.Output.List<Object.Object1>, null>
/**
* Query enum field documentation.
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/ts/_/schema/generated/SchemaRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export const Query = $.Object$(`Query`, {
}),
),
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
objectList: $.field($.Output.Nullable($.Output.List($.Output.Nullable(() => Object1)))),
objectListNonNull: $.field($.Output.List(() => Object1)),
abcEnum: $.field($.Output.Nullable(ABCEnum)),
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
interface: $.field($.Output.Nullable(() => Interface)),
Expand Down
2 changes: 2 additions & 0 deletions tests/ts/_/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Query {
objectNested: ObjectNested
objectWithArgs(string:String, int:Int, float:Float, boolean:Boolean, id:ID): Object1
fooBarUnion: FooBarUnion
objectList: [Object1]
objectListNonNull: [Object1!]!
"""
Query enum field documentation.
"""
Expand Down

0 comments on commit 1238a1c

Please sign in to comment.