Skip to content

Commit 118d1d7

Browse files
committed
fix(ts-client): no infer runtime objects
This is because of TypeScript's inability to infer from circular types.
1 parent 1238a1c commit 118d1d7

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,39 +291,57 @@ export const InputObject = $.InputObject(\`InputObject\`, {
291291
dateRequired: $.Input.field($Scalar.Date),
292292
})
293293
294+
// eslint-disable-next-line
295+
// @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.
294296
export const DateObject1 = $.Object$(\`DateObject1\`, {
295297
date1: $.field($.Output.Nullable($Scalar.Date)),
296298
})
297299
300+
// eslint-disable-next-line
301+
// @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.
298302
export const DateObject2 = $.Object$(\`DateObject2\`, {
299303
date2: $.field($.Output.Nullable($Scalar.Date)),
300304
})
301305
306+
// eslint-disable-next-line
307+
// @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.
302308
export const ObjectUnion = $.Object$(\`ObjectUnion\`, {
303309
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
304310
})
305311
312+
// eslint-disable-next-line
313+
// @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.
306314
export const Foo = $.Object$(\`Foo\`, {
307315
id: $.field($.Output.Nullable($Scalar.ID)),
308316
})
309317
318+
// eslint-disable-next-line
319+
// @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.
310320
export const Bar = $.Object$(\`Bar\`, {
311321
int: $.field($.Output.Nullable($Scalar.Int)),
312322
})
313323
324+
// eslint-disable-next-line
325+
// @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.
314326
export const ObjectNested = $.Object$(\`ObjectNested\`, {
315327
id: $.field($.Output.Nullable($Scalar.ID)),
316328
object: $.field($.Output.Nullable(() => Object1)),
317329
})
318330
331+
// eslint-disable-next-line
332+
// @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.
319333
export const lowerCaseObject = $.Object$(\`lowerCaseObject\`, {
320334
id: $.field($.Output.Nullable($Scalar.ID)),
321335
})
322336
337+
// eslint-disable-next-line
338+
// @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.
323339
export const lowerCaseObject2 = $.Object$(\`lowerCaseObject2\`, {
324340
int: $.field($.Output.Nullable($Scalar.Int)),
325341
})
326342
343+
// eslint-disable-next-line
344+
// @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.
327345
export const Object1 = $.Object$(\`Object1\`, {
328346
string: $.field($.Output.Nullable($Scalar.String)),
329347
int: $.field($.Output.Nullable($Scalar.Int)),
@@ -332,11 +350,15 @@ export const Object1 = $.Object$(\`Object1\`, {
332350
id: $.field($.Output.Nullable($Scalar.ID)),
333351
})
334352
353+
// eslint-disable-next-line
354+
// @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.
335355
export const Object1ImplementingInterface = $.Object$(\`Object1ImplementingInterface\`, {
336356
id: $.field($.Output.Nullable($Scalar.ID)),
337357
int: $.field($.Output.Nullable($Scalar.Int)),
338358
})
339359
360+
// eslint-disable-next-line
361+
// @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.
340362
export const Object2ImplementingInterface = $.Object$(\`Object2ImplementingInterface\`, {
341363
id: $.field($.Output.Nullable($Scalar.ID)),
342364
boolean: $.field($.Output.Nullable($Scalar.Boolean)),
@@ -356,6 +378,8 @@ export const Interface = $.Interface(\`Interface\`, { id: $.field($.Output.Nulla
356378
Object2ImplementingInterface,
357379
])
358380
381+
// eslint-disable-next-line
382+
// @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.
359383
export const Query = $.Object$(\`Query\`, {
360384
date: $.field($.Output.Nullable($Scalar.Date)),
361385
dateNonNull: $.field($Scalar.Date),

src/generator/code/schemaRuntime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const object = (config: Config, type: GraphQLObjectType) => {
9898
return `${field.name}: ${outputField(config, field)}`
9999
}).join(`,\n`)
100100
return `
101+
// eslint-disable-next-line
102+
// @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.
101103
export const ${type.name} = $.Object$(\`${type.name}\`, {
102104
${fields}
103105
})

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,57 @@ export const InputObject = $.InputObject(`InputObject`, {
1010
dateRequired: $.Input.field($Scalar.Date),
1111
})
1212

13+
// eslint-disable-next-line
14+
// @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.
1315
export const DateObject1 = $.Object$(`DateObject1`, {
1416
date1: $.field($.Output.Nullable($Scalar.Date)),
1517
})
1618

19+
// eslint-disable-next-line
20+
// @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.
1721
export const DateObject2 = $.Object$(`DateObject2`, {
1822
date2: $.field($.Output.Nullable($Scalar.Date)),
1923
})
2024

25+
// eslint-disable-next-line
26+
// @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.
2127
export const ObjectUnion = $.Object$(`ObjectUnion`, {
2228
fooBarUnion: $.field($.Output.Nullable(() => FooBarUnion)),
2329
})
2430

31+
// eslint-disable-next-line
32+
// @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.
2533
export const Foo = $.Object$(`Foo`, {
2634
id: $.field($.Output.Nullable($Scalar.ID)),
2735
})
2836

37+
// eslint-disable-next-line
38+
// @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.
2939
export const Bar = $.Object$(`Bar`, {
3040
int: $.field($.Output.Nullable($Scalar.Int)),
3141
})
3242

43+
// eslint-disable-next-line
44+
// @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.
3345
export const ObjectNested = $.Object$(`ObjectNested`, {
3446
id: $.field($.Output.Nullable($Scalar.ID)),
3547
object: $.field($.Output.Nullable(() => Object1)),
3648
})
3749

50+
// eslint-disable-next-line
51+
// @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.
3852
export const lowerCaseObject = $.Object$(`lowerCaseObject`, {
3953
id: $.field($.Output.Nullable($Scalar.ID)),
4054
})
4155

56+
// eslint-disable-next-line
57+
// @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.
4258
export const lowerCaseObject2 = $.Object$(`lowerCaseObject2`, {
4359
int: $.field($.Output.Nullable($Scalar.Int)),
4460
})
4561

62+
// eslint-disable-next-line
63+
// @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.
4664
export const Object1 = $.Object$(`Object1`, {
4765
string: $.field($.Output.Nullable($Scalar.String)),
4866
int: $.field($.Output.Nullable($Scalar.Int)),
@@ -51,11 +69,15 @@ export const Object1 = $.Object$(`Object1`, {
5169
id: $.field($.Output.Nullable($Scalar.ID)),
5270
})
5371

72+
// eslint-disable-next-line
73+
// @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.
5474
export const Object1ImplementingInterface = $.Object$(`Object1ImplementingInterface`, {
5575
id: $.field($.Output.Nullable($Scalar.ID)),
5676
int: $.field($.Output.Nullable($Scalar.Int)),
5777
})
5878

79+
// eslint-disable-next-line
80+
// @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.
5981
export const Object2ImplementingInterface = $.Object$(`Object2ImplementingInterface`, {
6082
id: $.field($.Output.Nullable($Scalar.ID)),
6183
boolean: $.field($.Output.Nullable($Scalar.Boolean)),
@@ -75,6 +97,8 @@ export const Interface = $.Interface(`Interface`, { id: $.field($.Output.Nullabl
7597
Object2ImplementingInterface,
7698
])
7799

100+
// eslint-disable-next-line
101+
// @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.
78102
export const Query = $.Object$(`Query`, {
79103
date: $.field($.Output.Nullable($Scalar.Date)),
80104
dateNonNull: $.field($Scalar.Date),

0 commit comments

Comments
 (0)