Skip to content

Commit

Permalink
feat(ts-client): support non-null interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Apr 13, 2024
1 parent b85b50b commit cebd26d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Schema/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export type SomeField = Field<
| Output.List<any>
| Output.Nullable<any>
| Output.Object$2<string, any>
| Output.Union<string, [any, ...any[]]>,
| Output.Union<string, [any, ...any[]]>
| Output.Interface<string, Record<string, Field<any, Args<any> | null>>, [any, ...any[]]>,
Args<any> | null
>

Expand Down
6 changes: 4 additions & 2 deletions src/generator/__snapshots__/files.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export namespace Root {
input: $.Input.Nullable<InputObject.InputObject>
}>
>
interface: $.Field<$.Output.Nullable<Interface.Interface>, null>
id: $.Field<$.Output.Nullable<$Scalar.ID>, null>
idNonNull: $.Field<$Scalar.ID, null>
string: $.Field<$.Output.Nullable<$Scalar.String>, null>
Expand Down Expand Up @@ -129,6 +128,8 @@ export namespace Root {
*/
abcEnum: $.Field<$.Output.Nullable<Enum.ABCEnum>, null>
lowerCaseUnion: $.Field<$.Output.Nullable<Union.lowerCaseUnion>, null>
interface: $.Field<$.Output.Nullable<Interface.Interface>, null>
interfaceNonNull: $.Field<Interface.Interface, null>
unionFooBar: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
unionObject: $.Field<$.Output.Nullable<Object.ObjectUnion>, null>
unionFooBarNonNull: $.Field<Union.FooBarUnion, null>
Expand Down Expand Up @@ -373,7 +374,6 @@ export const Query = $.Object$(\`Query\`, {
),
dateArgNonNullListNonNull: $.field($.Output.Nullable($Scalar.Date), $.Args({ date: $.Input.List($Scalar.Date) })),
dateArgInputObject: $.field($.Output.Nullable($Scalar.Date), $.Args({ input: $.Input.Nullable(InputObject) })),
interface: $.field($.Output.Nullable(() => Interface)),
id: $.field($.Output.Nullable($Scalar.ID)),
idNonNull: $.field($Scalar.ID),
string: $.field($.Output.Nullable($Scalar.String)),
Expand Down Expand Up @@ -424,6 +424,8 @@ export const Query = $.Object$(\`Query\`, {
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
abcEnum: $.field($.Output.Nullable(ABCEnum)),
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
interface: $.field($.Output.Nullable(() => Interface)),
interfaceNonNull: $.field(() => Interface),
unionFooBar: $.field($.Output.Nullable(() => FooBarUnion)),
unionObject: $.field($.Output.Nullable(() => ObjectUnion)),
unionFooBarNonNull: $.field(() => FooBarUnion),
Expand Down
3 changes: 2 additions & 1 deletion tests/ts/_/schema/generated/SchemaBuildtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export namespace Root {
input: $.Input.Nullable<InputObject.InputObject>
}>
>
interface: $.Field<$.Output.Nullable<Interface.Interface>, null>
id: $.Field<$.Output.Nullable<$Scalar.ID>, null>
idNonNull: $.Field<$Scalar.ID, null>
string: $.Field<$.Output.Nullable<$Scalar.String>, null>
Expand Down Expand Up @@ -126,6 +125,8 @@ export namespace Root {
*/
abcEnum: $.Field<$.Output.Nullable<Enum.ABCEnum>, null>
lowerCaseUnion: $.Field<$.Output.Nullable<Union.lowerCaseUnion>, null>
interface: $.Field<$.Output.Nullable<Interface.Interface>, null>
interfaceNonNull: $.Field<Interface.Interface, null>
unionFooBar: $.Field<$.Output.Nullable<Union.FooBarUnion>, null>
unionObject: $.Field<$.Output.Nullable<Object.ObjectUnion>, null>
unionFooBarNonNull: $.Field<Union.FooBarUnion, null>
Expand Down
3 changes: 2 additions & 1 deletion tests/ts/_/schema/generated/SchemaRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const Query = $.Object$(`Query`, {
),
dateArgNonNullListNonNull: $.field($.Output.Nullable($Scalar.Date), $.Args({ date: $.Input.List($Scalar.Date) })),
dateArgInputObject: $.field($.Output.Nullable($Scalar.Date), $.Args({ input: $.Input.Nullable(InputObject) })),
interface: $.field($.Output.Nullable(() => Interface)),
id: $.field($.Output.Nullable($Scalar.ID)),
idNonNull: $.field($Scalar.ID),
string: $.field($.Output.Nullable($Scalar.String)),
Expand Down Expand Up @@ -146,6 +145,8 @@ export const Query = $.Object$(`Query`, {
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
abcEnum: $.field($.Output.Nullable(ABCEnum)),
lowerCaseUnion: $.field($.Output.Nullable(() => lowerCaseUnion)),
interface: $.field($.Output.Nullable(() => Interface)),
interfaceNonNull: $.field(() => Interface),
unionFooBar: $.field($.Output.Nullable(() => FooBarUnion)),
unionObject: $.field($.Output.Nullable(() => ObjectUnion)),
unionFooBarNonNull: $.field(() => FooBarUnion),
Expand Down
4 changes: 2 additions & 2 deletions tests/ts/_/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Query {
dateArgNonNullList(date: [Date]!): Date
dateArgNonNullListNonNull(date: [Date!]!): Date
dateArgInputObject(input: InputObject): Date
interface: Interface
id: ID
idNonNull: ID!
string: String
Expand All @@ -39,11 +38,12 @@ type Query {
"""
abcEnum: ABCEnum
lowerCaseUnion: lowerCaseUnion
interface: Interface
interfaceNonNull: Interface!
unionFooBar: FooBarUnion
unionObject: ObjectUnion
unionFooBarNonNull: FooBarUnion!
unionObjectNonNull: ObjectUnion!

}

interface DateInterface1 {
Expand Down

0 comments on commit cebd26d

Please sign in to comment.