Skip to content

Commit 893ad01

Browse files
committed
fix(ts-client): no infer runtime unions
1 parent 310f10c commit 893ad01

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,16 @@ export const Object2ImplementingInterface = $.Object$(\`Object2ImplementingInter
392392
boolean: $.field($.Output.Nullable($Scalar.Boolean)),
393393
})
394394
395+
// eslint-disable-next-line
396+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
395397
export const DateUnion = $.Union(\`DateUnion\`, [DateObject1, DateObject2])
396398
399+
// eslint-disable-next-line
400+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
397401
export const FooBarUnion = $.Union(\`FooBarUnion\`, [Foo, Bar])
398402
403+
// eslint-disable-next-line
404+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
399405
export const lowerCaseUnion = $.Union(\`lowerCaseUnion\`, [lowerCaseObject, lowerCaseObject2])
400406
401407
export const DateInterface1 = $.Interface(\`DateInterface1\`, { date1: $.field($.Output.Nullable($Scalar.Date)) }, [

src/generator/code/schemaRuntime.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ const index = (config: Config) => {
7272
const union = (config: Config, type: GraphQLUnionType) => {
7373
// todo probably need thunks here
7474
const members = type.getTypes().map(t => t.name).join(`, `)
75-
return `export const ${type.name} = $.Union(\`${type.name}\`, [${members}])\n`
75+
return `
76+
// eslint-disable-next-line
77+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
78+
export const ${type.name} = $.Union(\`${type.name}\`, [${members}])\n`
7679
}
7780

7881
const interface$ = (config: Config, type: GraphQLInterfaceType) => {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ export const Object2ImplementingInterface = $.Object$(`Object2ImplementingInterf
9191
boolean: $.field($.Output.Nullable($Scalar.Boolean)),
9292
})
9393

94+
// eslint-disable-next-line
95+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
9496
export const DateUnion = $.Union(`DateUnion`, [DateObject1, DateObject2])
9597

98+
// eslint-disable-next-line
99+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
96100
export const FooBarUnion = $.Union(`FooBarUnion`, [Foo, Bar])
97101

102+
// eslint-disable-next-line
103+
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
98104
export const lowerCaseUnion = $.Union(`lowerCaseUnion`, [lowerCaseObject, lowerCaseObject2])
99105

100106
export const DateInterface1 = $.Interface(`DateInterface1`, { date1: $.field($.Output.Nullable($Scalar.Date)) }, [

0 commit comments

Comments
 (0)