From cebd26d5338475dda64792f2009ff7e4a07ab3fe Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 13 Apr 2024 07:29:39 -0400 Subject: [PATCH] feat(ts-client): support non-null interface --- src/Schema/Field.ts | 3 ++- src/generator/__snapshots__/files.test.ts.snap | 6 ++++-- tests/ts/_/schema/generated/SchemaBuildtime.ts | 3 ++- tests/ts/_/schema/generated/SchemaRuntime.ts | 3 ++- tests/ts/_/schema/schema.graphql | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Schema/Field.ts b/src/Schema/Field.ts index 79fd9a846..053a7c33c 100644 --- a/src/Schema/Field.ts +++ b/src/Schema/Field.ts @@ -26,7 +26,8 @@ export type SomeField = Field< | Output.List | Output.Nullable | Output.Object$2 - | Output.Union, + | Output.Union + | Output.Interface | null>>, [any, ...any[]]>, Args | null > diff --git a/src/generator/__snapshots__/files.test.ts.snap b/src/generator/__snapshots__/files.test.ts.snap index d2c35cb8d..e1d92c2ba 100644 --- a/src/generator/__snapshots__/files.test.ts.snap +++ b/src/generator/__snapshots__/files.test.ts.snap @@ -53,7 +53,6 @@ export namespace Root { input: $.Input.Nullable }> > - interface: $.Field<$.Output.Nullable, null> id: $.Field<$.Output.Nullable<$Scalar.ID>, null> idNonNull: $.Field<$Scalar.ID, null> string: $.Field<$.Output.Nullable<$Scalar.String>, null> @@ -129,6 +128,8 @@ export namespace Root { */ abcEnum: $.Field<$.Output.Nullable, null> lowerCaseUnion: $.Field<$.Output.Nullable, null> + interface: $.Field<$.Output.Nullable, null> + interfaceNonNull: $.Field unionFooBar: $.Field<$.Output.Nullable, null> unionObject: $.Field<$.Output.Nullable, null> unionFooBarNonNull: $.Field @@ -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)), @@ -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), diff --git a/tests/ts/_/schema/generated/SchemaBuildtime.ts b/tests/ts/_/schema/generated/SchemaBuildtime.ts index 2c5771ae2..facf538e5 100644 --- a/tests/ts/_/schema/generated/SchemaBuildtime.ts +++ b/tests/ts/_/schema/generated/SchemaBuildtime.ts @@ -50,7 +50,6 @@ export namespace Root { input: $.Input.Nullable }> > - interface: $.Field<$.Output.Nullable, null> id: $.Field<$.Output.Nullable<$Scalar.ID>, null> idNonNull: $.Field<$Scalar.ID, null> string: $.Field<$.Output.Nullable<$Scalar.String>, null> @@ -126,6 +125,8 @@ export namespace Root { */ abcEnum: $.Field<$.Output.Nullable, null> lowerCaseUnion: $.Field<$.Output.Nullable, null> + interface: $.Field<$.Output.Nullable, null> + interfaceNonNull: $.Field unionFooBar: $.Field<$.Output.Nullable, null> unionObject: $.Field<$.Output.Nullable, null> unionFooBarNonNull: $.Field diff --git a/tests/ts/_/schema/generated/SchemaRuntime.ts b/tests/ts/_/schema/generated/SchemaRuntime.ts index e4aa79f20..3b88e0b68 100644 --- a/tests/ts/_/schema/generated/SchemaRuntime.ts +++ b/tests/ts/_/schema/generated/SchemaRuntime.ts @@ -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)), @@ -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), diff --git a/tests/ts/_/schema/schema.graphql b/tests/ts/_/schema/schema.graphql index 562757919..80cb9fe33 100644 --- a/tests/ts/_/schema/schema.graphql +++ b/tests/ts/_/schema/schema.graphql @@ -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 @@ -39,11 +38,12 @@ type Query { """ abcEnum: ABCEnum lowerCaseUnion: lowerCaseUnion + interface: Interface + interfaceNonNull: Interface! unionFooBar: FooBarUnion unionObject: ObjectUnion unionFooBarNonNull: FooBarUnion! unionObjectNonNull: ObjectUnion! - } interface DateInterface1 {