Skip to content

Commit 414f6b0

Browse files
Fix issues after rebasing (#10563)
* Fix missing dep * chore(dependencies): updated changesets for modified dependencies * Fix dev-tests --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 6af5ec9 commit 414f6b0

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-codegen/typescript-operations": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@graphql-codegen/schema-ast@^5.0.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/schema-ast/v/5.0.0) (to `dependencies`)

dev-test/standalone-operations/import-schema-types/_types.generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type * as Types from './_base.generated';
1+
import type * as Types from './_base.generated.js';
22

33
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
44
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };

packages/plugins/typescript/operations/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@graphql-codegen/plugin-helpers": "^6.1.0",
17+
"@graphql-codegen/schema-ast": "^5.0.0",
1718
"@graphql-codegen/typescript": "^5.0.7",
1819
"@graphql-codegen/visitor-plugin-common": "6.2.2",
1920
"auto-bind": "~4.0.0",

packages/plugins/typescript/operations/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const plugin: PluginFunction<TypeScriptDocumentsPluginConfig, Types.Compl
6464
};
6565
};
6666

67-
export { TypeScriptDocumentsVisitor };
67+
export { TypeScriptDocumentsVisitor, type TypeScriptDocumentsPluginConfig };
6868

6969
const semanticToStrict = async (schema: GraphQLSchema): Promise<GraphQLSchema> => {
7070
try {

packages/plugins/typescript/operations/src/visitor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
getNodeComment,
2424
wrapTypeWithModifiers,
2525
} from '@graphql-codegen/visitor-plugin-common';
26+
import { normalizeImportExtension } from '@graphql-codegen/plugin-helpers';
2627
import autoBind from 'auto-bind';
2728
import {
2829
type DocumentNode,
@@ -370,8 +371,11 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
370371
identifiers: [],
371372
},
372373
typesImport: true,
373-
// FIXME: rebase with master for the new extension
374-
emitLegacyCommonJSImports: true,
374+
emitLegacyCommonJSImports: this.config.emitLegacyCommonJSImports,
375+
importExtension: normalizeImportExtension({
376+
emitLegacyCommonJSImports: this.config.emitLegacyCommonJSImports,
377+
importExtension: this.config.importExtension,
378+
}),
375379
}),
376380
];
377381
}

packages/plugins/typescript/operations/tests/extract-all-types.spec.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { mergeOutputs, Types } from '@graphql-codegen/plugin-helpers';
22
import { validateTs } from '@graphql-codegen/testing';
33
import { buildSchema, parse } from 'graphql';
4-
import { plugin as tsPlugin } from '../../typescript/src/index.js';
5-
import { plugin, TypeScriptDocumentsPluginConfig } from '../src/index.js';
4+
import { plugin, type TypeScriptDocumentsPluginConfig } from '../src/index.js';
65

76
describe('extractAllFieldsToTypes: true', () => {
8-
const validate = async (content: Types.PluginOutput, config: any = {}, pluginSchema) => {
9-
const m = mergeOutputs([await tsPlugin(pluginSchema, [], config, { outputFile: '' }), content]);
7+
const validate = async (content: Types.PluginOutput) => {
8+
const m = mergeOutputs([content]);
109
validateTs(m, undefined, undefined, undefined, []);
1110

1211
return m;
@@ -197,7 +196,7 @@ describe('extractAllFieldsToTypes: true', () => {
197196
"
198197
`);
199198

200-
await validate(content, config, dummyUserTestSchema);
199+
await validate(content);
201200
});
202201

203202
const complexTestSchemaWithUnionsAndInterfaces = buildSchema(/* GraphQL */ `
@@ -551,7 +550,7 @@ describe('extractAllFieldsToTypes: true', () => {
551550
"
552551
`);
553552

554-
await validate(content, config, complexTestSchemaWithUnionsAndInterfaces);
553+
await validate(content);
555554
});
556555

557556
it('should extract types from multiple fragments (mergeFragmentTypes: true)', async () => {
@@ -725,7 +724,7 @@ describe('extractAllFieldsToTypes: true', () => {
725724
"
726725
`);
727726

728-
await validate(content, config, complexTestSchemaWithUnionsAndInterfaces);
727+
await validate(content);
729728
});
730729

731730
it("should extract types from multiple fragments (inlineFragmentTypes: 'combine')", async () => {
@@ -968,7 +967,7 @@ describe('extractAllFieldsToTypes: true', () => {
968967
"
969968
`);
970969

971-
await validate(content, config, complexTestSchemaWithUnionsAndInterfaces);
970+
await validate(content);
972971
});
973972

974973
it("should extract types from multiple fragments (inlineFragmentTypes: 'mask')", async () => {
@@ -1209,7 +1208,7 @@ describe('extractAllFieldsToTypes: true', () => {
12091208
"
12101209
`);
12111210

1212-
await validate(content, config, complexTestSchemaWithUnionsAndInterfaces);
1211+
await validate(content);
12131212
});
12141213

12151214
it('fields with shared types and no fragments should use the shared type interface name', async () => {
@@ -1302,7 +1301,7 @@ describe('extractAllFieldsToTypes: true', () => {
13021301
"
13031302
`);
13041303

1305-
await validate(content, config, nestedInterfacesSchema);
1304+
await validate(content);
13061305
});
13071306

13081307
// Exception case for Issue #10502 - shared schema for fragment tests
@@ -1411,7 +1410,7 @@ describe('extractAllFieldsToTypes: true', () => {
14111410
export type GetNotificationsQuery = GetNotificationsQuery_Query;
14121411
"
14131412
`);
1414-
await validate(content, config, notificationSchema);
1413+
await validate(content);
14151414
});
14161415

14171416
it('named fragments should use their name and not parent type name', async () => {
@@ -1492,6 +1491,6 @@ describe('extractAllFieldsToTypes: true', () => {
14921491
export type GetNotificationsQuery = GetNotificationsQuery_Query;
14931492
"
14941493
`);
1495-
await validate(content, config, notificationSchema);
1494+
await validate(content);
14961495
});
14971496
});

0 commit comments

Comments
 (0)