Skip to content

Commit 0540573

Browse files
committed
fix(lint): don't lint codegen template sources
graphql/codegen/src/core/codegen/templates/* are read verbatim at codegen time and written into generated clients, so import sorting there changes generated output and breaks client-generator snapshots.
1 parent bdce5bc commit 0540573

5 files changed

Lines changed: 72 additions & 69 deletions

File tree

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default [
2020
'**/*.generated.ts',
2121
'postgres/pg-ast/src/asts.ts',
2222
'postgres/pg-ast/src/wrapped.ts',
23+
// read verbatim at codegen time and written into generated clients
24+
'graphql/codegen/src/core/codegen/templates/**',
2325
// legacy fixture build script
2426
'__fixtures__/kitchen-sink/**'
2527
]

graphql/codegen/src/core/codegen/templates/cli-entry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
import { CLI, CLIOptions, getPackageJson } from 'inquirerer';
12-
1312
import { commands } from './commands';
1413

1514
if (process.argv.includes('--version') || process.argv.includes('-v')) {

graphql/codegen/src/core/codegen/templates/cli-utils.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,56 @@ export function coerceAnswers(
4949
}
5050

5151
switch (fieldType) {
52-
case 'boolean':
53-
if (typeof value === 'boolean') break;
54-
result[key] =
52+
case 'boolean':
53+
if (typeof value === 'boolean') break;
54+
result[key] =
5555
strValue === 'true' || strValue === '1' || strValue === 'yes';
56-
break;
57-
case 'int':
58-
if (typeof value === 'number') break;
59-
{
60-
const parsed = parseInt(strValue, 10);
61-
result[key] = isNaN(parsed) ? undefined : parsed;
62-
}
63-
break;
64-
case 'float':
65-
if (typeof value === 'number') break;
66-
{
67-
const parsed = parseFloat(strValue);
68-
result[key] = isNaN(parsed) ? undefined : parsed;
69-
}
70-
break;
71-
case 'json':
72-
if (typeof value === 'object') break;
73-
if (strValue === '') {
74-
result[key] = undefined;
75-
} else {
76-
try {
77-
result[key] = JSON.parse(strValue);
78-
} catch {
56+
break;
57+
case 'int':
58+
if (typeof value === 'number') break;
59+
{
60+
const parsed = parseInt(strValue, 10);
61+
result[key] = isNaN(parsed) ? undefined : parsed;
62+
}
63+
break;
64+
case 'float':
65+
if (typeof value === 'number') break;
66+
{
67+
const parsed = parseFloat(strValue);
68+
result[key] = isNaN(parsed) ? undefined : parsed;
69+
}
70+
break;
71+
case 'json':
72+
if (typeof value === 'object') break;
73+
if (strValue === '') {
7974
result[key] = undefined;
75+
} else {
76+
try {
77+
result[key] = JSON.parse(strValue);
78+
} catch {
79+
result[key] = undefined;
80+
}
8081
}
81-
}
82-
break;
83-
case 'uuid':
84-
// Empty UUIDs become undefined
85-
if (strValue === '') {
86-
result[key] = undefined;
87-
}
88-
break;
89-
case 'enum':
90-
// Enums stay as strings but empty ones become undefined
91-
if (strValue === '') {
92-
result[key] = undefined;
93-
}
94-
break;
95-
default:
96-
// String type: empty strings also become undefined to avoid
97-
// sending empty strings for optional fields
98-
if (strValue === '') {
99-
result[key] = undefined;
100-
}
101-
break;
82+
break;
83+
case 'uuid':
84+
// Empty UUIDs become undefined
85+
if (strValue === '') {
86+
result[key] = undefined;
87+
}
88+
break;
89+
case 'enum':
90+
// Enums stay as strings but empty ones become undefined
91+
if (strValue === '') {
92+
result[key] = undefined;
93+
}
94+
break;
95+
default:
96+
// String type: empty strings also become undefined to avoid
97+
// sending empty strings for optional fields
98+
if (strValue === '') {
99+
result[key] = undefined;
100+
}
101+
break;
102102
}
103103
}
104104

graphql/codegen/src/core/codegen/templates/orm-client.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ import type {
1919
ConnectionState,
2020
ConnectionStateListener,
2121
RealtimeConfig,
22+
SubscribeOptions,
2223
SubscriptionEvent,
2324
SubscriptionFieldMeta,
2425
Unsubscribe,
2526
} from './realtime';
2627
import { RealtimeManager } from './realtime';
2728

29+
export type {
30+
GraphQLAdapter,
31+
GraphQLError,
32+
QueryResult,
33+
} from '@constructive-io/graphql-query/runtime';
34+
2835
export type {
2936
ConnectionState,
3037
ConnectionStateListener,
@@ -37,11 +44,6 @@ export type {
3744
WsClient,
3845
} from './realtime';
3946
export { RealtimeManager } from './realtime';
40-
export type {
41-
GraphQLAdapter,
42-
GraphQLError,
43-
QueryResult,
44-
} from '@constructive-io/graphql-query/runtime';
4547

4648
/**
4749
* Default adapter that uses fetch for HTTP requests.

graphql/codegen/src/core/codegen/templates/query-builder.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export function buildSelections(
197197
buildOptionalArg('first', nested.first),
198198
nested.filter
199199
? t.argument({
200-
name: 'filter',
201-
value: buildValueAst(nested.filter),
202-
})
200+
name: 'filter',
201+
value: buildValueAst(nested.filter),
202+
})
203203
: null,
204204
buildEnumListArg('orderBy', nested.orderBy),
205205
]);
@@ -255,7 +255,7 @@ export function buildFindManyDocument<TSelect, TWhere>(
255255
select as Record<string, unknown>,
256256
connectionFieldsMap,
257257
operationName,
258-
)
258+
)
259259
: [t.field({ name: 'id' })];
260260

261261
const variableDefinitions: VariableDefinitionNode[] = [];
@@ -353,7 +353,7 @@ export function buildFindFirstDocument<TSelect, TWhere>(
353353
select as Record<string, unknown>,
354354
connectionFieldsMap,
355355
operationName,
356-
)
356+
)
357357
: [t.field({ name: 'id' })];
358358

359359
const variableDefinitions: VariableDefinitionNode[] = [];
@@ -431,7 +431,7 @@ export function buildCreateDocument<TSelect, TData>(
431431
select as Record<string, unknown>,
432432
connectionFieldsMap,
433433
operationName,
434-
)
434+
)
435435
: [t.field({ name: 'id' })];
436436

437437
return {
@@ -474,7 +474,7 @@ export function buildUpdateDocument<
474474
select as Record<string, unknown>,
475475
connectionFieldsMap,
476476
operationName,
477-
)
477+
)
478478
: [t.field({ name: 'id' })];
479479

480480
return {
@@ -516,7 +516,7 @@ export function buildUpdateByPkDocument<TSelect, TData>(
516516
select as Record<string, unknown>,
517517
connectionFieldsMap,
518518
operationName,
519-
)
519+
)
520520
: [t.field({ name: 'id' })];
521521

522522
return {
@@ -555,7 +555,7 @@ export function buildFindOneDocument<TSelect>(
555555
select as Record<string, unknown>,
556556
connectionFieldsMap,
557557
operationName,
558-
)
558+
)
559559
: [t.field({ name: 'id' })];
560560

561561
const variableDefinitions: VariableDefinitionNode[] = [
@@ -614,7 +614,7 @@ export function buildDeleteDocument<
614614
select as Record<string, unknown>,
615615
connectionFieldsMap,
616616
operationName,
617-
)
617+
)
618618
: [t.field({ name: 'id' })];
619619

620620
return {
@@ -653,7 +653,7 @@ export function buildDeleteByPkDocument<TSelect = undefined>(
653653
select as Record<string, unknown>,
654654
connectionFieldsMap,
655655
operationName,
656-
)
656+
)
657657
: [t.field({ name: 'id' })];
658658

659659
return {
@@ -716,7 +716,7 @@ export function buildCustomDocument<TSelect, TArgs>(
716716
actualSelect as Record<string, unknown>,
717717
connectionFieldsMap,
718718
entityType,
719-
)
719+
)
720720
: [];
721721

722722
const variableDefs = variableDefinitions.map((definition) =>
@@ -994,7 +994,7 @@ export function buildBulkInsertDocument<TSelect, TData>(
994994
select as Record<string, unknown>,
995995
connectionFieldsMap,
996996
operationName,
997-
)
997+
)
998998
: [t.field({ name: 'id' })];
999999

10001000
return {
@@ -1033,7 +1033,7 @@ export function buildBulkUpsertDocument<TSelect, TData>(
10331033
select as Record<string, unknown>,
10341034
connectionFieldsMap,
10351035
operationName,
1036-
)
1036+
)
10371037
: [t.field({ name: 'id' })];
10381038

10391039
return {
@@ -1072,7 +1072,7 @@ export function buildBulkUpdateDocument<TSelect, TWhere, TData>(
10721072
select as Record<string, unknown>,
10731073
connectionFieldsMap,
10741074
operationName,
1075-
)
1075+
)
10761076
: [t.field({ name: 'id' })];
10771077

10781078
return {
@@ -1110,7 +1110,7 @@ export function buildBulkDeleteDocument<TSelect, TWhere>(
11101110
select as Record<string, unknown>,
11111111
connectionFieldsMap,
11121112
operationName,
1113-
)
1113+
)
11141114
: [t.field({ name: 'id' })];
11151115

11161116
return {

0 commit comments

Comments
 (0)