diff --git a/.changeset/@graphql-codegen_add-10849-dependencies.md b/.changeset/@graphql-codegen_add-10849-dependencies.md deleted file mode 100644 index 79fda52504c..00000000000 --- a/.changeset/@graphql-codegen_add-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/add": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_cli-10848-dependencies.md b/.changeset/@graphql-codegen_cli-10848-dependencies.md deleted file mode 100644 index 534ba9a3bfa..00000000000 --- a/.changeset/@graphql-codegen_cli-10848-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/cli": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/client-preset@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/client-preset/v/workspace:^) (from `^6.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_cli-10849-dependencies.md b/.changeset/@graphql-codegen_cli-10849-dependencies.md deleted file mode 100644 index 7ecb61bf4b4..00000000000 --- a/.changeset/@graphql-codegen_cli-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/cli": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/core@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/core/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_client-preset-10848-dependencies.md b/.changeset/@graphql-codegen_client-preset-10848-dependencies.md deleted file mode 100644 index c27028a8e70..00000000000 --- a/.changeset/@graphql-codegen_client-preset-10848-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/client-preset": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/gql-tag-operations@^6.0.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/gql-tag-operations/v/6.0.0) (from `6.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_client-preset-10849-dependencies.md b/.changeset/@graphql-codegen_client-preset-10849-dependencies.md deleted file mode 100644 index 0088d64210f..00000000000 --- a/.changeset/@graphql-codegen_client-preset-10849-dependencies.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@graphql-codegen/client-preset": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/add@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/add/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/gql-tag-operations@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/gql-tag-operations/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/typed-document-node@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typed-document-node/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/typescript@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/typescript-operations@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript-operations/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_core-10849-dependencies.md b/.changeset/@graphql-codegen_core-10849-dependencies.md deleted file mode 100644 index c807dce7b2a..00000000000 --- a/.changeset/@graphql-codegen_core-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/core": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_fragment-matcher-10849-dependencies.md b/.changeset/@graphql-codegen_fragment-matcher-10849-dependencies.md deleted file mode 100644 index be8fd022ac7..00000000000 --- a/.changeset/@graphql-codegen_fragment-matcher-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/fragment-matcher": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_gql-tag-operations-10849-dependencies.md b/.changeset/@graphql-codegen_gql-tag-operations-10849-dependencies.md deleted file mode 100644 index e4ec5e8a8b3..00000000000 --- a/.changeset/@graphql-codegen_gql-tag-operations-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/gql-tag-operations": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_graphql-modules-preset-10849-dependencies.md b/.changeset/@graphql-codegen_graphql-modules-preset-10849-dependencies.md deleted file mode 100644 index dd7a939d467..00000000000 --- a/.changeset/@graphql-codegen_graphql-modules-preset-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/graphql-modules-preset": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_introspection-10849-dependencies.md b/.changeset/@graphql-codegen_introspection-10849-dependencies.md deleted file mode 100644 index 4afe1fdfdc8..00000000000 --- a/.changeset/@graphql-codegen_introspection-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/introspection": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_schema-ast-10849-dependencies.md b/.changeset/@graphql-codegen_schema-ast-10849-dependencies.md deleted file mode 100644 index 4b915bbd9ac..00000000000 --- a/.changeset/@graphql-codegen_schema-ast-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/schema-ast": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_testing-10849-dependencies.md b/.changeset/@graphql-codegen_testing-10849-dependencies.md deleted file mode 100644 index cfdafdac444..00000000000 --- a/.changeset/@graphql-codegen_testing-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/testing": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_time-10849-dependencies.md b/.changeset/@graphql-codegen_time-10849-dependencies.md deleted file mode 100644 index a732dde57f1..00000000000 --- a/.changeset/@graphql-codegen_time-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/time": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typed-document-node-10849-dependencies.md b/.changeset/@graphql-codegen_typed-document-node-10849-dependencies.md deleted file mode 100644 index ec963f630b1..00000000000 --- a/.changeset/@graphql-codegen_typed-document-node-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/typed-document-node": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-10849-dependencies.md b/.changeset/@graphql-codegen_typescript-10849-dependencies.md deleted file mode 100644 index 1388a448b83..00000000000 --- a/.changeset/@graphql-codegen_typescript-10849-dependencies.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@graphql-codegen/typescript": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/schema-ast@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/schema-ast/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.1`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-document-nodes-10849-dependencies.md b/.changeset/@graphql-codegen_typescript-document-nodes-10849-dependencies.md deleted file mode 100644 index 8ae03d5d69e..00000000000 --- a/.changeset/@graphql-codegen_typescript-document-nodes-10849-dependencies.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@graphql-codegen/typescript-document-nodes": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-operations-10849-dependencies.md b/.changeset/@graphql-codegen_typescript-operations-10849-dependencies.md deleted file mode 100644 index 36db54e1a03..00000000000 --- a/.changeset/@graphql-codegen_typescript-operations-10849-dependencies.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@graphql-codegen/typescript-operations": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/schema-ast@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/schema-ast/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.1`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-resolvers-10849-dependencies.md b/.changeset/@graphql-codegen_typescript-resolvers-10849-dependencies.md deleted file mode 100644 index cc3adec674f..00000000000 --- a/.changeset/@graphql-codegen_typescript-resolvers-10849-dependencies.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@graphql-codegen/typescript-resolvers": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.1`, in `dependencies`) - - Updated dependency [`@graphql-codegen/typescript@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/workspace:^) (from `^6.0.0`, in `dependencies`) - - Updated dependency [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_visitor-plugin-common-10849-dependencies.md b/.changeset/@graphql-codegen_visitor-plugin-common-10849-dependencies.md deleted file mode 100644 index a9012d48e6e..00000000000 --- a/.changeset/@graphql-codegen_visitor-plugin-common-10849-dependencies.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@graphql-codegen/visitor-plugin-common": patch ---- -dependencies updates: - - Updated dependency [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) (from `^7.0.0`, in `dependencies`) diff --git a/.changeset/legal-cobras-hang.md b/.changeset/legal-cobras-hang.md deleted file mode 100644 index df4a4075a40..00000000000 --- a/.changeset/legal-cobras-hang.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@graphql-codegen/client-preset': patch ---- - -Fix package pinning diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9fa4e4cc7b..9c9eea99207 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,9 +30,7 @@ jobs: githubToken: ${{ secrets.GITHUB_TOKEN }} release-stable: - if: - github.event_name == 'push' && github.event.pull_request.head.repo.full_name == - github.repository + if: github.event_name == 'push' uses: the-guild-org/shared-config/.github/workflows/release-stable.yml@f4eea983237a44bb0ca19c3348dacbfdfcdbec23 # main permissions: id-token: write # allows OIDC publishing @@ -41,7 +39,6 @@ jobs: with: nodeVersion: 24 packageManager: pnpm - buildScript: build releaseScript: release secrets: githubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/dev-test/general/.env b/dev-test/general/.env index f41607e8459..5e6f403b415 100644 --- a/dev-test/general/.env +++ b/dev-test/general/.env @@ -1 +1 @@ -SCHEMA_PATH=./dev-test/general/test-schema/schema.graphql +SCHEMA_PATH=./test-schema/schema.graphql diff --git a/dev-test/general/codegen.ts b/dev-test/general/codegen.ts index 9b4dc009f9b..9ae87dd63e2 100644 --- a/dev-test/general/codegen.ts +++ b/dev-test/general/codegen.ts @@ -4,234 +4,228 @@ const config: CodegenConfig = { hooks: { afterAllFileWrite: ['prettier --write'] }, emitLegacyCommonJSImports: false, generates: { - './dev-test/general/test-schema/resolvers-types.ts': { - schema: './dev-test/general/test-schema/schema-text.js', + './test-schema/resolvers-types.ts': { + schema: './test-schema/schema-text.js', plugins: ['typescript', 'typescript-resolvers'], }, - './dev-test/general/test-schema/flow-types.flow.js': { - schema: './dev-test/general/test-schema/schema.json', + './test-schema/flow-types.flow.js': { + schema: './test-schema/schema.json', plugins: ['flow', 'flow-resolvers'], }, - './dev-test/general/test-schema/resolvers-root.ts': { - schema: './dev-test/general/test-schema/schema-with-root.graphql', + './test-schema/resolvers-root.ts': { + schema: './test-schema/schema-with-root.graphql', plugins: ['typescript', 'typescript-resolvers'], }, - './dev-test/general/test-schema/resolvers-federation.ts': { - schema: './dev-test/general/test-schema/schema-federation.graphql', + './test-schema/resolvers-federation.ts': { + schema: './test-schema/schema-federation.graphql', config: { federation: true }, plugins: ['typescript', 'typescript-resolvers'], }, - './dev-test/general/test-schema/resolvers-stitching.ts': { - schema: './dev-test/general/test-schema/schema-text.js', + './test-schema/resolvers-stitching.ts': { + schema: './test-schema/schema-text.js', plugins: ['typescript', { 'typescript-resolvers': { noSchemaStitching: false } }], }, - './dev-test/general/test-schema/typings.ts': { - schema: './dev-test/general/test-schema/schema.json', + './test-schema/typings.ts': { + schema: './test-schema/schema.json', plugins: ['typescript', 'typescript-resolvers'], }, - './dev-test/general/test-schema/typings.avoidOptionals.ts': { - schema: './dev-test/general/test-schema/schema.json', + './test-schema/typings.avoidOptionals.ts': { + schema: './test-schema/schema.json', config: { avoidOptionals: true }, plugins: ['typescript'], }, - './dev-test/general/test-schema/typings.wrapped.ts': { - schema: './dev-test/general/test-schema/schema.json', + './test-schema/typings.wrapped.ts': { + schema: './test-schema/schema.json', plugins: [ { add: { content: 'declare namespace GraphQL {' } }, { add: { placement: 'append', content: '}' } }, 'typescript', ], }, - './dev-test/general/test-schema/env.types.ts': { + './test-schema/env.types.ts': { schema: process.env.SCHEMA_PATH, plugins: ['typescript'], }, - './dev-test/general/test-schema/typings.immutableTypes.ts': { - schema: './dev-test/general/test-schema/schema.json', + './test-schema/typings.immutableTypes.ts': { + schema: './test-schema/schema.json', config: { imutableTypes: true }, plugins: ['typescript'], }, - './dev-test/general/test-schema/typings.enum.ts': { - schema: './dev-test/general/test-schema/schema-object.js', + './test-schema/typings.enum.ts': { + schema: './test-schema/schema-object.js', plugins: ['typescript'], }, - './dev-test/general/githunt/graphql-declared-modules.d.ts': { - schema: './dev-test/general/githunt/schema.json', + './githunt/graphql-declared-modules.d.ts': { + schema: './githunt/schema.json', documents: [ - './dev-test/general/githunt/**/*.graphql', + './githunt/**/*.graphql', './dev-test/general-outer-dir/githunt/**/*.graphql', '!**/nothing-should-use-this-query.graphql', ], plugins: ['typescript-graphql-files-modules'], }, - './dev-test/general/githunt/typed-document-nodes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/typed-document-nodes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', plugins: ['typescript-operations', 'typed-document-node'], }, - './dev-test/general/githunt/types.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.preResolveTypes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.preResolveTypes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.onlyEnums.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.onlyEnums.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { generateOperationTypes: false }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.preResolveTypes.onlyOperationTypes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.preResolveTypes.onlyOperationTypes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.flatten.preResolveTypes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.flatten.preResolveTypes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { preResolveTypes: true, flattenGeneratedTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.enumsAsTypes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.enumsAsTypes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { enumType: 'string-literal' }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.d.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.d.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: {}, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.avoidOptionals.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.avoidOptionals.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { avoidOptionals: true }, plugins: ['typescript-operations'], }, - './dev-test/general/githunt/types.immutableTypes.ts': { - schema: './dev-test/general/githunt/schema.json', - documents: './dev-test/general/githunt/**/*.graphql', + './githunt/types.immutableTypes.ts': { + schema: './githunt/schema.json', + documents: './githunt/**/*.graphql', config: { immutableTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.excludeQueryAlpha.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: [ - './dev-test/general/star-wars/**/*.graphql', - '!./dev-test/general/star-wars/**/ExcludeQueryAlpha.graphql', - ], + './star-wars/types.excludeQueryAlpha.ts': { + schema: './star-wars/schema.json', + documents: ['./star-wars/**/*.graphql', '!./star-wars/**/ExcludeQueryAlpha.graphql'], plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.excludeQueryBeta.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: [ - './dev-test/general/star-wars/**/*.graphql', - '!./dev-test/general/star-wars/**/ExcludeQueryBeta.graphql', - ], + './star-wars/types.excludeQueryBeta.ts': { + schema: './star-wars/schema.json', + documents: ['./star-wars/**/*.graphql', '!./star-wars/**/ExcludeQueryBeta.graphql'], plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.preResolveTypes.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.preResolveTypes.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.OnlyEnums.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.OnlyEnums.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { onlyEnums: true }, plugins: ['typescript'], }, - './dev-test/general/star-wars/types.preResolveTypes.onlyOperationTypes.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.preResolveTypes.onlyOperationTypes.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/test-schema/types.preResolveTypes.ts': { - schema: './dev-test/general/test-schema/schema.graphql', + './test-schema/types.preResolveTypes.ts': { + schema: './test-schema/schema.graphql', documents: ['query test { testArr1 testArr2 testArr3 }'], config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/test-schema/types.preResolveTypes.onlyOperationTypes.ts': { - schema: './dev-test/general/test-schema/schema.graphql', + './test-schema/types.preResolveTypes.onlyOperationTypes.ts': { + schema: './test-schema/schema.graphql', documents: ['query test { testArr1 testArr2 testArr3 }'], config: { preResolveTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.d.ts': { - schema: './dev-test/general/star-wars/schema.json', + './star-wars/types.d.ts': { + schema: './star-wars/schema.json', config: { enumType: 'string-literal' }, plugins: ['typescript-operations'], }, - './dev-test/general/modules/': { - schema: './dev-test/general/modules/*/types/*.graphql', + './modules/': { + schema: './modules/*/types/*.graphql', preset: 'graphql-modules', presetConfig: { baseTypesPath: 'types.ts', filename: 'generated.ts' }, plugins: ['typescript', 'typescript-resolvers'], }, - './dev-test/general/star-wars/types.globallyAvailable.d.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.globallyAvailable.d.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { noExport: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.avoidOptionals.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.avoidOptionals.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { avoidOptionals: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.immutableTypes.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.immutableTypes.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', config: { immutableTypes: true }, plugins: ['typescript-operations'], }, - './dev-test/general/star-wars/types.skipSchema.ts': { - schema: './dev-test/general/star-wars/schema.json', - documents: './dev-test/general/star-wars/**/*.graphql', + './star-wars/types.skipSchema.ts': { + schema: './star-wars/schema.json', + documents: './star-wars/**/*.graphql', plugins: ['typescript-operations'], }, - './dev-test/general/gql-tag-operations/gql/': { - schema: './dev-test/general/gql-tag-operations/schema.graphql', - documents: './dev-test/general/gql-tag-operations/src/**/*.ts', + './gql-tag-operations/gql/': { + schema: './gql-tag-operations/schema.graphql', + documents: './gql-tag-operations/src/**/*.ts', preset: 'client', }, - './dev-test/general/gql-tag-operations/graphql/': { - schema: './dev-test/general/gql-tag-operations/schema.graphql', - documents: './dev-test/general/gql-tag-operations/src/**/*.ts', + './gql-tag-operations/graphql/': { + schema: './gql-tag-operations/schema.graphql', + documents: './gql-tag-operations/src/**/*.ts', preset: 'client', }, - './dev-test/general/gql-tag-operations-urql/gql/': { - schema: './dev-test/general/gql-tag-operations-urql/schema.graphql', - documents: './dev-test/general/gql-tag-operations-urql/src/**/*.ts', + './gql-tag-operations-urql/gql/': { + schema: './gql-tag-operations-urql/schema.graphql', + documents: './gql-tag-operations-urql/src/**/*.ts', preset: 'client', presetConfig: { augmentedModuleName: '@urql/core' }, }, - './dev-test/general/gql-tag-operations-masking/gql/': { - schema: './dev-test/general/gql-tag-operations-masking/schema.graphql', - documents: './dev-test/general/gql-tag-operations-masking/src/**/*.tsx', + './gql-tag-operations-masking/gql/': { + schema: './gql-tag-operations-masking/schema.graphql', + documents: './gql-tag-operations-masking/src/**/*.tsx', preset: 'client', presetConfig: { fragmentMasking: true }, }, - './dev-test/general/test-null-value/result.d.ts': { - schema: './dev-test/general/test-null-value/schema.graphql', - documents: ['./dev-test/general/test-null-value/query.ts'], + './test-null-value/result.d.ts': { + schema: './test-null-value/schema.graphql', + documents: ['./test-null-value/query.ts'], plugins: ['typescript-operations'], config: { // The combination of these two flags caused the following issue: @@ -240,8 +234,8 @@ const config: CodegenConfig = { mergeFragmentTypes: true, }, }, - './dev-test/general/subpath-import/result.d.ts': { - schema: './dev-test/general/subpath-import/schema.graphql', + './subpath-import/result.d.ts': { + schema: './subpath-import/schema.graphql', plugins: ['typescript', 'typescript-resolvers'], config: { contextType: '\\#test-null-value/context#TestContext', @@ -251,8 +245,8 @@ const config: CodegenConfig = { }, }, }, - './dev-test/general/test-federation/generated/types.ts': { - schema: './dev-test/general/test-federation/schema.gql', + './test-federation/generated/types.ts': { + schema: './test-federation/schema.gql', plugins: ['typescript', 'typescript-resolvers'], config: { mapperTypeSuffix: 'Mapper', @@ -265,45 +259,43 @@ const config: CodegenConfig = { }, }, // #region externalDocuments option - './dev-test/general/external-documents/app/types.generated.ts': { - schema: './dev-test/general/external-documents/schema.graphqls', - documents: ['./dev-test/general/external-documents/app/*.graphql.ts'], - externalDocuments: ['./dev-test/general/external-documents/lib/*.graphql.ts'], + './external-documents/app/types.generated.ts': { + schema: './external-documents/schema.graphqls', + documents: ['./external-documents/app/*.graphql.ts'], + externalDocuments: ['./external-documents/lib/*.graphql.ts'], plugins: ['typescript-operations'], }, // #endregion // standalone-operations/import-schema-types - './dev-test/general/standalone-operations/import-schema-types/_base.generated.ts': { - schema: './dev-test/general/standalone-operations/schema.graphql', - documents: ['./dev-test/general/standalone-operations/import-schema-types/*.graphql'], + './standalone-operations/import-schema-types/_base.generated.ts': { + schema: './standalone-operations/schema.graphql', + documents: ['./standalone-operations/import-schema-types/*.graphql'], plugins: ['typescript-operations'], config: { generateOperationTypes: false, }, }, - './dev-test/general/standalone-operations/import-schema-types/_types.generated.ts': { - schema: './dev-test/general/standalone-operations/schema.graphql', - documents: ['./dev-test/general/standalone-operations/import-schema-types/*.graphql'], + './standalone-operations/import-schema-types/_types.generated.ts': { + schema: './standalone-operations/schema.graphql', + documents: ['./standalone-operations/import-schema-types/*.graphql'], plugins: ['typescript-operations'], config: { - importSchemaTypesFrom: - './dev-test/general/standalone-operations/import-schema-types/_base.generated.ts', + importSchemaTypesFrom: './standalone-operations/import-schema-types/_base.generated.ts', }, }, // standalone-operations/with-typescript-plugin - './dev-test/general/standalone-operations/with-typescript-plugin/_base.generated.ts': { - schema: './dev-test/general/standalone-operations/schema.graphql', + './standalone-operations/with-typescript-plugin/_base.generated.ts': { + schema: './standalone-operations/schema.graphql', plugins: ['typescript'], }, - './dev-test/general/standalone-operations/with-typescript-plugin/_types.generated.ts': { - schema: './dev-test/general/standalone-operations/schema.graphql', - documents: ['./dev-test/general/standalone-operations/with-typescript-plugin/*.graphql'], + './standalone-operations/with-typescript-plugin/_types.generated.ts': { + schema: './standalone-operations/schema.graphql', + documents: ['./standalone-operations/with-typescript-plugin/*.graphql'], plugins: ['typescript-operations'], config: { - importSchemaTypesFrom: - './dev-test/general/standalone-operations/with-typescript-plugin/_base.generated.ts', + importSchemaTypesFrom: './standalone-operations/with-typescript-plugin/_base.generated.ts', }, }, }, diff --git a/dev-test/general/githunt/graphql-declared-modules.d.ts b/dev-test/general/githunt/graphql-declared-modules.d.ts index e4c6d75e683..c8316061698 100644 --- a/dev-test/general/githunt/graphql-declared-modules.d.ts +++ b/dev-test/general/githunt/graphql-declared-modules.d.ts @@ -1,12 +1,3 @@ -declare module '*/current-user.query.graphql' { - import { DocumentNode } from 'graphql'; - const defaultDocument: DocumentNode; - export const CurrentUserForProfileFromOutsideDirectory: DocumentNode; - export const CurrentUserForProfile: DocumentNode; - - export default defaultDocument; -} - declare module '*/comment-added.subscription.graphql' { import { DocumentNode } from 'graphql'; const defaultDocument: DocumentNode; @@ -31,6 +22,14 @@ declare module '*/comments-page-comment.fragment.graphql' { export default defaultDocument; } +declare module '*/current-user.query.graphql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const CurrentUserForProfile: DocumentNode; + + export default defaultDocument; +} + declare module '*/feed-entry.fragment.graphql' { import { DocumentNode } from 'graphql'; const defaultDocument: DocumentNode; diff --git a/dev-test/general/package.json b/dev-test/general/package.json new file mode 100644 index 00000000000..74bad3cbe5a --- /dev/null +++ b/dev-test/general/package.json @@ -0,0 +1,26 @@ +{ + "name": "dev-test-general", + "version": "0.0.1", + "description": "Kitchen sink of various setups. For new dev-test, consider creating new project for better targetting", + "private": true, + "scripts": { + "generate": "pnpm generate:esm", + "generate:cjs": "node ../../packages/graphql-codegen-cli/dist/cjs/bin.js --require dotenv/config --config codegen.ts dotenv_config_path=.env", + "generate:esm": "node ../../packages/graphql-codegen-cli/dist/esm/bin.js --require dotenv/config --config codegen.ts dotenv_config_path=.env", + "watch": "pnpm watch:esm", + "watch:cjs": "pnpm generate:cjs --watch", + "watch:esm": "pnpm generate:esm --watch" + }, + "devDependencies": { + "@graphql-codegen/add": "workspace:*", + "@graphql-codegen/cli": "workspace:*", + "@graphql-codegen/flow": "3.0.1", + "@graphql-codegen/flow-resolvers": "3.0.1", + "@graphql-codegen/graphql-modules-preset": "workspace:*", + "@graphql-codegen/typed-document-node": "workspace:*", + "@graphql-codegen/typescript": "workspace:*", + "@graphql-codegen/typescript-graphql-files-modules": "4.0.1", + "@graphql-codegen/typescript-operations": "workspace:*", + "@graphql-codegen/typescript-resolvers": "workspace:*" + } +} diff --git a/dev-test/general/test-schema/flow-types.flow.js b/dev-test/general/test-schema/flow-types.flow.js index 4b3cd55f7e0..f8ac067469a 100644 --- a/dev-test/general/test-schema/flow-types.flow.js +++ b/dev-test/general/test-schema/flow-types.flow.js @@ -1,7 +1,8 @@ // @flow import { type GraphQLResolveInfo } from 'graphql'; -export type $RequireFields = $Diff & $ObjMapi(k: Key) => $NonMaybeType<$ElementType>>; +export type $RequireFields = $Diff & + $ObjMapi(k: Key) => $NonMaybeType<$ElementType>>; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = {| ID: string, @@ -17,7 +18,6 @@ export type Query = {| userById?: ?User, |}; - export type QueryUserByIdArgs = {| id: $ElementType, |}; @@ -33,21 +33,21 @@ export type Resolver = ( parent: Parent, args: Args, context: Context, - info: GraphQLResolveInfo + info: GraphQLResolveInfo, ) => Promise | Result; export type SubscriptionSubscribeFn = ( parent: Parent, args: Args, context: Context, - info: GraphQLResolveInfo + info: GraphQLResolveInfo, ) => AsyncIterator | Promise>; export type SubscriptionResolveFn = ( parent: Parent, args: Args, context: Context, - info: GraphQLResolveInfo + info: GraphQLResolveInfo, ) => Result | Promise; export interface SubscriptionSubscriberObject { @@ -71,10 +71,14 @@ export type SubscriptionResolver = ( parent: Parent, context: Context, - info: GraphQLResolveInfo + info: GraphQLResolveInfo, ) => ?Types | Promise; -export type IsTypeOfResolverFn = (obj: T, context: Context, info: GraphQLResolveInfo) => boolean | Promise; +export type IsTypeOfResolverFn = ( + obj: T, + context: Context, + info: GraphQLResolveInfo, +) => boolean | Promise; export type NextResolverFn = () => Promise; @@ -83,7 +87,7 @@ export type DirectiveResolverFn Result | Promise; export type ResolverTypeWrapper = Promise | T; @@ -106,12 +110,23 @@ export type ResolversParentTypes = { User: User, }; -export type QueryResolvers> = { +export type QueryResolvers< + ContextType = any, + ParentType = $ElementType, +> = { allUsers?: Resolver>, ParentType, ContextType>, - userById?: Resolver, ParentType, ContextType, $RequireFields>, + userById?: Resolver< + ?$ElementType, + ParentType, + ContextType, + $RequireFields, + >, }; -export type UserResolvers> = { +export type UserResolvers< + ContextType = any, + ParentType = $ElementType, +> = { email?: Resolver<$ElementType, ParentType, ContextType>, id?: Resolver<$ElementType, ParentType, ContextType>, name?: Resolver<$ElementType, ParentType, ContextType>, @@ -122,4 +137,3 @@ export type Resolvers = { Query?: QueryResolvers, User?: UserResolvers, }; - diff --git a/examples/persisted-documents/package.json b/examples/persisted-documents/package.json index 05740ae13bd..7c3ae337497 100644 --- a/examples/persisted-documents/package.json +++ b/examples/persisted-documents/package.json @@ -17,6 +17,7 @@ "@babel/preset-env": "7.29.5", "@babel/preset-typescript": "7.28.5", "@graphql-codegen/cli": "workspace:*", + "@graphql-codegen/client-preset": "workspace:*", "@graphql-typed-document-node/core": "3.2.0" }, "bob": false diff --git a/package.json b/package.json index 802063eab37..e6a412a6523 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,12 @@ "build": "bob build", "postbuild": "pnpm fix-bins", "clean": "rimraf node_modules/", - "dev-test:generate": "pnpm dev-test:generate:esm", - "dev-test:generate:cjs": "node packages/graphql-codegen-cli/dist/cjs/bin.js --require dotenv/config --config ./dev-test/general/codegen.ts dotenv_config_path=dev-test/general/.env", - "dev-test:generate:esm": "node packages/graphql-codegen-cli/dist/esm/bin.js --require dotenv/config --config ./dev-test/general/codegen.ts dotenv_config_path=dev-test/general/.env", - "dev-test:watch": "pnpm dev-test:watch:esm", - "dev-test:watch:cjs": "node packages/graphql-codegen-cli/dist/cjs/bin.js --require dotenv/config --watch --config ./dev-test/general/codegen.ts dotenv_config_path=dev-test/general/.env", - "dev-test:watch:esm": "node packages/graphql-codegen-cli/dist/esm/bin.js --require dotenv/config --watch --config ./dev-test/general/codegen.ts dotenv_config_path=dev-test/general/.env", + "dev-test:generate": "pnpm --filter=\"dev-test*\" generate", + "dev-test:generate:cjs": "pnpm --filter=\"dev-test*\" generate:cjs", + "dev-test:generate:esm": "pnpm --filter=\"dev-test*\" generate:esm", + "dev-test:watch": "pnpm --filter=\"dev-test*\" watch", + "dev-test:watch:cjs": "pnpm --filter=\"dev-test*\" watch:cjs", + "dev-test:watch:esm": "pnpm --filter=\"dev-test*\" watch:esm", "examples:build": "set -o xtrace && eval $(node scripts/print-example-ci-command.js build)", "examples:codegen": "set -o xtrace && eval $(node scripts/print-example-ci-command.js codegen)", "examples:test:end2end": "set -o xtrace && eval $(node scripts/print-example-ci-command.js test:end2end)", @@ -40,17 +40,6 @@ "@changesets/cli": "2.31.0", "@eslint/eslintrc": "3.3.5", "@eslint/js": "10.0.1", - "@graphql-codegen/add": "workspace:*", - "@graphql-codegen/cli": "workspace:*", - "@graphql-codegen/client-preset": "workspace:*", - "@graphql-codegen/flow": "3.0.1", - "@graphql-codegen/flow-resolvers": "3.0.2", - "@graphql-codegen/graphql-modules-preset": "workspace:*", - "@graphql-codegen/typed-document-node": "workspace:*", - "@graphql-codegen/typescript": "workspace:*", - "@graphql-codegen/typescript-graphql-files-modules": "4.0.1", - "@graphql-codegen/typescript-operations": "workspace:*", - "@graphql-codegen/typescript-resolvers": "workspace:*", "@ianvs/prettier-plugin-sort-imports": "4.7.1", "@theguild/eslint-config": "0.13.4", "@theguild/prettier-config": "3.0.1", diff --git a/packages/graphql-codegen-cli/CHANGELOG.md b/packages/graphql-codegen-cli/CHANGELOG.md index 3e8b7778438..73bf7b0588f 100644 --- a/packages/graphql-codegen-cli/CHANGELOG.md +++ b/packages/graphql-codegen-cli/CHANGELOG.md @@ -1,5 +1,48 @@ # @graphql-codegen/cli +## 7.1.0 + +### Minor Changes + +- [#10855](https://github.com/dotansimha/graphql-code-generator/pull/10855) + [`cfc4fc3`](https://github.com/dotansimha/graphql-code-generator/commit/cfc4fc3e659bf34df7e114c7f02eda583b2d0918) + Thanks [@eddeee888](https://github.com/eddeee888)! - Add + disableFederationDirectiveAndScalarInjection config to better support Federation v2 + +### Patch Changes + +- Updated dependencies + [[`cbf9544`](https://github.com/dotansimha/graphql-code-generator/commit/cbf95443b41bda82852d0396f3ab15310e22e2ae)]: + - @graphql-codegen/core@6.1.0 + +## 7.0.1 + +### Patch Changes + +- [#10848](https://github.com/dotansimha/graphql-code-generator/pull/10848) + [`f3ce427`](https://github.com/dotansimha/graphql-code-generator/commit/f3ce427e251c45b87f462a4584381a76989c628d) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/client-preset@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/client-preset/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/core@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/core/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`f3ce427`](https://github.com/dotansimha/graphql-code-generator/commit/f3ce427e251c45b87f462a4584381a76989c628d), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`f3ce427`](https://github.com/dotansimha/graphql-code-generator/commit/f3ce427e251c45b87f462a4584381a76989c628d)]: + - @graphql-codegen/client-preset@6.0.1 + - @graphql-codegen/core@6.0.1 + ## 7.0.0 ### Major Changes diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index 69a2291d056..f1f2fe5b98a 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/cli", - "version": "7.0.0", + "version": "7.1.0", "type": "module", "repository": { "type": "git", @@ -111,6 +111,15 @@ "yargs": "^18.0.0" }, "devDependencies": { + "@graphql-codegen/add": "workspace:*", + "@graphql-codegen/flow": "3.0.1", + "@graphql-codegen/flow-resolvers": "3.0.1", + "@graphql-codegen/graphql-modules-preset": "workspace:*", + "@graphql-codegen/typed-document-node": "workspace:*", + "@graphql-codegen/typescript": "workspace:*", + "@graphql-codegen/typescript-graphql-files-modules": "4.0.1", + "@graphql-codegen/typescript-operations": "workspace:*", + "@graphql-codegen/typescript-resolvers": "workspace:*", "@inquirer/testing": "3.3.6", "@parcel/watcher": "^2.1.0", "@types/is-glob": "4.0.4", diff --git a/packages/graphql-codegen-cli/src/codegen.ts b/packages/graphql-codegen-cli/src/codegen.ts index 58e3d286dd9..217cef5256c 100644 --- a/packages/graphql-codegen-cli/src/codegen.ts +++ b/packages/graphql-codegen-cli/src/codegen.ts @@ -44,6 +44,8 @@ const makeDefaultLoader = (from: string) => { * as import.meta is unavailable in a CommonJS context * and furthermore unavailable in stable Node.js. **/ + // FIXME(pnpm-update): this causes dev-test devDeps to be brought into CLI's package.json, which is not ideal. + // Note that `relativeRequire.resolve(mod)` seems to work correctly for ESM as well. mod : relativeRequire.resolve(mod) ); diff --git a/packages/graphql-codegen-cli/tests/codegen.spec.ts b/packages/graphql-codegen-cli/tests/codegen.spec.ts index 7c5c754fb29..b3db7613f60 100644 --- a/packages/graphql-codegen-cli/tests/codegen.spec.ts +++ b/packages/graphql-codegen-cli/tests/codegen.spec.ts @@ -1505,4 +1505,86 @@ describe('Codegen Executor', () => { expect(result.length).toBe(1); expect(result[0].content).toContain('export type WpCoreImageBlockForGalleryFragment = '); }); + + describe('Federation', () => { + it('should include federation directives and scalar when federation: true ', async () => { + const { result } = await executeCodegen({ + schema: [SIMPLE_TEST_SCHEMA], + generates: { + 'out1.graphql': { + plugins: ['schema-ast'], + }, + }, + config: { + federation: true, + }, + }); + + expect(result[0].content).toContain('directive @external on FIELD_DEFINITION'); + expect(result[0].content).toContain( + 'directive @requires(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).toContain( + 'directive @provides(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).toContain( + 'directive @key(fields: _FieldSet!) on OBJECT | INTERFACE', + ); + expect(result[0].content).toContain('scalar _FieldSet'); + }); + it('should not include federation directives and scalar when federation: true and disableFederationDirectiveAndScalarInjection: true', async () => { + const { result } = await executeCodegen({ + schema: [SIMPLE_TEST_SCHEMA], + generates: { + 'out1.graphql': { + plugins: ['schema-ast'], + }, + }, + config: { + federation: true, + disableFederationDirectiveAndScalarInjection: true, + }, + }); + + expect(result[0].content).not.toContain('directive @external on FIELD_DEFINITION'); + expect(result[0].content).not.toContain( + 'directive @requires(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).not.toContain( + 'directive @provides(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).not.toContain( + 'directive @key(fields: _FieldSet!) on OBJECT | INTERFACE', + ); + expect(result[0].content).not.toContain('scalar _FieldSet'); + expect(result[0].content).toContain('type MyType'); + }); + it('should not include federation directives and scalar when federation: false and disableFederationDirectiveAndScalarInjection: true', async () => { + const { result } = await executeCodegen({ + schema: [SIMPLE_TEST_SCHEMA], + generates: { + 'out1.graphql': { + plugins: ['schema-ast'], + }, + }, + config: { + federation: false, + disableFederationDirectiveAndScalarInjection: true, + }, + }); + + expect(result[0].content).not.toContain('directive @external on FIELD_DEFINITION'); + expect(result[0].content).not.toContain( + 'directive @requires(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).not.toContain( + 'directive @provides(fields: _FieldSet!) on FIELD_DEFINITION', + ); + expect(result[0].content).not.toContain( + 'directive @key(fields: _FieldSet!) on OBJECT | INTERFACE', + ); + expect(result[0].content).not.toContain('scalar _FieldSet'); + expect(result[0].content).toContain('type MyType'); + }); + }); }); diff --git a/packages/graphql-codegen-core/CHANGELOG.md b/packages/graphql-codegen-core/CHANGELOG.md index ca854d78a68..ee8f86479b9 100644 --- a/packages/graphql-codegen-core/CHANGELOG.md +++ b/packages/graphql-codegen-core/CHANGELOG.md @@ -1,5 +1,25 @@ # @graphql-codegen/core +## 6.1.0 + +### Minor Changes + +- [#10788](https://github.com/dotansimha/graphql-code-generator/pull/10788) + [`cbf9544`](https://github.com/dotansimha/graphql-code-generator/commit/cbf95443b41bda82852d0396f3ab15310e22e2ae) + Thanks [@robertobadalamenti](https://github.com/robertobadalamenti)! - Add + disableFederationDirectiveAndScalarInjection config to better support Federation v2 + +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 6.0.0 ### Major Changes diff --git a/packages/graphql-codegen-core/package.json b/packages/graphql-codegen-core/package.json index e300e208c4c..33075258295 100644 --- a/packages/graphql-codegen-core/package.json +++ b/packages/graphql-codegen-core/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/core", - "version": "6.0.0", + "version": "6.1.0", "type": "module", "repository": { "type": "git", diff --git a/packages/graphql-codegen-core/src/codegen.ts b/packages/graphql-codegen-core/src/codegen.ts index a9bc042641f..09c84562a75 100644 --- a/packages/graphql-codegen-core/src/codegen.ts +++ b/packages/graphql-codegen-core/src/codegen.ts @@ -58,9 +58,20 @@ export async function codegen(options: Types.GenerateOptions): Promise { } const federationInConfig: boolean = pickFlag('federation', options.config); + /** + * @description When set to `true`, it disables the automatic injection of legacy Federation v1 directives and scalars (such as `@key`, `@external`, and `_FieldSet`). + */ + const disableFederationDirectiveAndScalarInjection: boolean = pickFlag( + 'disableFederationDirectiveAndScalarInjection', + options.config, + ); const isFederation = prioritize(federationInConfig, false); - if (isFederation && !hasFederationSpec(options.schemaAst || options.schema)) { + if ( + isFederation && + !disableFederationDirectiveAndScalarInjection && + !hasFederationSpec(options.schemaAst || options.schema) + ) { additionalTypeDefs.push(federationSpec); } diff --git a/packages/plugins/other/add/CHANGELOG.md b/packages/plugins/other/add/CHANGELOG.md index 5e6e4dd9f07..24a4a3dace2 100644 --- a/packages/plugins/other/add/CHANGELOG.md +++ b/packages/plugins/other/add/CHANGELOG.md @@ -1,5 +1,16 @@ # @graphql-codegen/add +## 7.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 7.0.0 ### Major Changes diff --git a/packages/plugins/other/add/package.json b/packages/plugins/other/add/package.json index 2ebbc7f1a33..81aa646d68f 100644 --- a/packages/plugins/other/add/package.json +++ b/packages/plugins/other/add/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/add", - "version": "7.0.0", + "version": "7.0.1", "type": "module", "description": "GraphQL Code Generator plugin for adding custom content to your output file", "repository": { diff --git a/packages/plugins/other/fragment-matcher/CHANGELOG.md b/packages/plugins/other/fragment-matcher/CHANGELOG.md index 08456bd4e5b..f3a9122d309 100644 --- a/packages/plugins/other/fragment-matcher/CHANGELOG.md +++ b/packages/plugins/other/fragment-matcher/CHANGELOG.md @@ -1,5 +1,16 @@ # @graphql-codegen/fragment-matcher +## 7.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 7.0.0 ### Major Changes diff --git a/packages/plugins/other/fragment-matcher/package.json b/packages/plugins/other/fragment-matcher/package.json index 2de779f190e..50ecf77ea02 100644 --- a/packages/plugins/other/fragment-matcher/package.json +++ b/packages/plugins/other/fragment-matcher/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/fragment-matcher", - "version": "7.0.0", + "version": "7.0.1", "type": "module", "description": "graphql-code-generate plugin for generating fragments matcher introspection file", "repository": { diff --git a/packages/plugins/other/introspection/CHANGELOG.md b/packages/plugins/other/introspection/CHANGELOG.md index dcfc324d711..3b01c2377df 100644 --- a/packages/plugins/other/introspection/CHANGELOG.md +++ b/packages/plugins/other/introspection/CHANGELOG.md @@ -1,5 +1,22 @@ # @graphql-codegen/introspection +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.0 ### Major Changes diff --git a/packages/plugins/other/introspection/package.json b/packages/plugins/other/introspection/package.json index d57af836856..af15a5929f4 100644 --- a/packages/plugins/other/introspection/package.json +++ b/packages/plugins/other/introspection/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/introspection", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator plugin for generating an introspection JSON file for a GraphQLSchema", "repository": { diff --git a/packages/plugins/other/schema-ast/CHANGELOG.md b/packages/plugins/other/schema-ast/CHANGELOG.md index a0f0ff2c187..9226ddfa0a8 100644 --- a/packages/plugins/other/schema-ast/CHANGELOG.md +++ b/packages/plugins/other/schema-ast/CHANGELOG.md @@ -1,5 +1,16 @@ # @graphql-codegen/schema-ast +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 6.0.0 ### Major Changes diff --git a/packages/plugins/other/schema-ast/package.json b/packages/plugins/other/schema-ast/package.json index 42e7cfa831f..fcd0cec25e3 100644 --- a/packages/plugins/other/schema-ast/package.json +++ b/packages/plugins/other/schema-ast/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/schema-ast", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator plugin for generating a .graphql file from a given schema", "repository": { diff --git a/packages/plugins/other/time/CHANGELOG.md b/packages/plugins/other/time/CHANGELOG.md index 6a9e2a73454..546ad9d028a 100644 --- a/packages/plugins/other/time/CHANGELOG.md +++ b/packages/plugins/other/time/CHANGELOG.md @@ -1,5 +1,16 @@ # @graphql-codegen/time +## 7.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 7.0.0 ### Major Changes diff --git a/packages/plugins/other/time/package.json b/packages/plugins/other/time/package.json index 916b0b65288..fb89a0a6b99 100644 --- a/packages/plugins/other/time/package.json +++ b/packages/plugins/other/time/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/time", - "version": "7.0.0", + "version": "7.0.1", "type": "module", "description": "GraphQL Code Generator plugin for adding the current time for an output file", "repository": { diff --git a/packages/plugins/other/visitor-plugin-common/CHANGELOG.md b/packages/plugins/other/visitor-plugin-common/CHANGELOG.md index e6ec65d2a73..fd440507b70 100644 --- a/packages/plugins/other/visitor-plugin-common/CHANGELOG.md +++ b/packages/plugins/other/visitor-plugin-common/CHANGELOG.md @@ -1,5 +1,25 @@ # @graphql-codegen/visitor-plugin-common +## 7.0.4 + +### Patch Changes + +- [#10554](https://github.com/dotansimha/graphql-code-generator/pull/10554) + [`446aef4`](https://github.com/dotansimha/graphql-code-generator/commit/446aef48b53f80d39b4a8d661eb5f028c35c784c) + Thanks [@eddeee888](https://github.com/eddeee888)! - Fix fragments not getting deduped when + documentMode=graphQLTag + +## 7.0.3 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 7.0.2 ### Patch Changes diff --git a/packages/plugins/other/visitor-plugin-common/package.json b/packages/plugins/other/visitor-plugin-common/package.json index 3c0acb831d6..c74349e4e43 100644 --- a/packages/plugins/other/visitor-plugin-common/package.json +++ b/packages/plugins/other/visitor-plugin-common/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/visitor-plugin-common", - "version": "7.0.2", + "version": "7.0.4", "type": "module", "repository": { "type": "git", diff --git a/packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts index 7031b74b983..c5b377f7de0 100644 --- a/packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts @@ -328,7 +328,10 @@ export class ClientSideBaseVisitor< return fragmentNames.map(document => this.getFragmentVariableName(document)); } - protected _includeFragments(fragments: string[]): string { + protected _includeFragments( + fragments: string[], + nodeKind: 'FragmentDefinition' | 'OperationDefinition', + ): string { if (fragments && fragments.length > 0) { if ( this.config.documentMode === DocumentMode.documentNode || @@ -342,6 +345,9 @@ export class ClientSideBaseVisitor< if (this.config.documentMode === DocumentMode.documentNodeImportFragments) { return ''; } + if (nodeKind !== 'OperationDefinition') { + return ''; + } return String(fragments.map(name => '${' + name + '}').join('\n')); } @@ -355,13 +361,14 @@ export class ClientSideBaseVisitor< protected _gql(node: FragmentDefinitionNode | OperationDefinitionNode): string { const includeNestedFragments = this.config.documentMode === DocumentMode.documentNode || - this.config.documentMode === DocumentMode.string; + this.config.documentMode === DocumentMode.string || + node.kind === 'OperationDefinition'; const fragmentNames = this._extractFragments(node, includeNestedFragments); const fragments = this._transformFragments(fragmentNames); const doc = this._prepareDocument(` ${print(node).split('\\').join('\\\\') /* Re-escape escaped values in GraphQL syntax */} - ${this._includeFragments(fragments)}`); + ${this._includeFragments(fragments, node.kind)}`); if (this.config.documentMode === DocumentMode.documentNode) { let gqlObj = gqlTag([doc]); diff --git a/packages/plugins/typescript/document-nodes/CHANGELOG.md b/packages/plugins/typescript/document-nodes/CHANGELOG.md index e75cb4a86bf..5b72932757c 100644 --- a/packages/plugins/typescript/document-nodes/CHANGELOG.md +++ b/packages/plugins/typescript/document-nodes/CHANGELOG.md @@ -1,5 +1,22 @@ # @graphql-codegen/typescript-document-nodes +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.0 ### Major Changes diff --git a/packages/plugins/typescript/document-nodes/package.json b/packages/plugins/typescript/document-nodes/package.json index ab392f36774..dfa2795d195 100644 --- a/packages/plugins/typescript/document-nodes/package.json +++ b/packages/plugins/typescript/document-nodes/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-document-nodes", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator plugin for generating TypeScript modules with embedded GraphQL document nodes", "repository": { diff --git a/packages/plugins/typescript/gql-tag-operations/CHANGELOG.md b/packages/plugins/typescript/gql-tag-operations/CHANGELOG.md index be6bf10c5fb..713a6c82d75 100644 --- a/packages/plugins/typescript/gql-tag-operations/CHANGELOG.md +++ b/packages/plugins/typescript/gql-tag-operations/CHANGELOG.md @@ -1,5 +1,22 @@ # @graphql-codegen/gql-tag-operations +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.0 ### Major Changes diff --git a/packages/plugins/typescript/gql-tag-operations/package.json b/packages/plugins/typescript/gql-tag-operations/package.json index 76e7578791d..de718aa1d49 100644 --- a/packages/plugins/typescript/gql-tag-operations/package.json +++ b/packages/plugins/typescript/gql-tag-operations/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/gql-tag-operations", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator plugin for generating a typed gql tag function", "repository": { diff --git a/packages/plugins/typescript/operations/CHANGELOG.md b/packages/plugins/typescript/operations/CHANGELOG.md index 11ab81b7f98..9c87944a3fd 100644 --- a/packages/plugins/typescript/operations/CHANGELOG.md +++ b/packages/plugins/typescript/operations/CHANGELOG.md @@ -1,5 +1,27 @@ # @graphql-codegen/typescript-operations +## 6.0.3 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/schema-ast@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/schema-ast/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.1`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/schema-ast@6.0.1 + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.2 ### Patch Changes diff --git a/packages/plugins/typescript/operations/package.json b/packages/plugins/typescript/operations/package.json index 2f4b8ed9a8f..8007b703cf3 100644 --- a/packages/plugins/typescript/operations/package.json +++ b/packages/plugins/typescript/operations/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-operations", - "version": "6.0.2", + "version": "6.0.3", "type": "module", "description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments", "repository": { diff --git a/packages/plugins/typescript/resolvers/CHANGELOG.md b/packages/plugins/typescript/resolvers/CHANGELOG.md index e0ccf31e97e..2e6cb17c4b9 100644 --- a/packages/plugins/typescript/resolvers/CHANGELOG.md +++ b/packages/plugins/typescript/resolvers/CHANGELOG.md @@ -1,5 +1,27 @@ # @graphql-codegen/typescript-resolvers +## 6.0.2 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.1`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/typescript@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/typescript@6.0.2 + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.1 ### Patch Changes diff --git a/packages/plugins/typescript/resolvers/package.json b/packages/plugins/typescript/resolvers/package.json index 807deedf686..c0528b2e719 100644 --- a/packages/plugins/typescript/resolvers/package.json +++ b/packages/plugins/typescript/resolvers/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-resolvers", - "version": "6.0.1", + "version": "6.0.2", "type": "module", "description": "GraphQL Code Generator plugin for generating TypeScript types for resolvers signature", "repository": { diff --git a/packages/plugins/typescript/typed-document-node/CHANGELOG.md b/packages/plugins/typescript/typed-document-node/CHANGELOG.md index 43c0f6edc0e..8d4d37e8843 100644 --- a/packages/plugins/typescript/typed-document-node/CHANGELOG.md +++ b/packages/plugins/typescript/typed-document-node/CHANGELOG.md @@ -1,5 +1,35 @@ # @graphql-codegen/typed-document-node +## 7.0.2 + +### Patch Changes + +- [#10554](https://github.com/dotansimha/graphql-code-generator/pull/10554) + [`446aef4`](https://github.com/dotansimha/graphql-code-generator/commit/446aef48b53f80d39b4a8d661eb5f028c35c784c) + Thanks [@eddeee888](https://github.com/eddeee888)! - Fix fragments not getting deduped when + documentMode=graphQLTag + +- Updated dependencies + [[`446aef4`](https://github.com/dotansimha/graphql-code-generator/commit/446aef48b53f80d39b4a8d661eb5f028c35c784c)]: + - @graphql-codegen/visitor-plugin-common@7.0.4 + +## 7.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 7.0.0 ### Major Changes diff --git a/packages/plugins/typescript/typed-document-node/package.json b/packages/plugins/typescript/typed-document-node/package.json index 942ee693719..4219ad4330b 100644 --- a/packages/plugins/typescript/typed-document-node/package.json +++ b/packages/plugins/typescript/typed-document-node/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typed-document-node", - "version": "7.0.0", + "version": "7.0.2", "type": "module", "description": "GraphQL Code Generator plugin for generating ready-to-use TypedDocumentNode based on GraphQL operations", "repository": { diff --git a/packages/plugins/typescript/typed-document-node/tests/typed-document-node.spec.ts b/packages/plugins/typescript/typed-document-node/tests/typed-document-node.spec.ts index 3a64800a44e..53a8698865f 100644 --- a/packages/plugins/typescript/typed-document-node/tests/typed-document-node.spec.ts +++ b/packages/plugins/typescript/typed-document-node/tests/typed-document-node.spec.ts @@ -1,5 +1,6 @@ import { buildSchema, parse } from 'graphql'; -import { Types } from '@graphql-codegen/plugin-helpers'; +import { mergeOutputs, Types } from '@graphql-codegen/plugin-helpers'; +import { DocumentMode } from '@graphql-codegen/visitor-plugin-common'; import { plugin } from '../src/index.js'; describe('TypedDocumentNode', () => { @@ -9,6 +10,77 @@ describe('TypedDocumentNode', () => { expect(result.prepend.length).toBe(0); }); + it('dedupes fragments automatically when documentMode=graphQLTag', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + person(id: ID!): Person! + } + type Person { + id: ID! + name: String! + children: [Person!] + } + `); + + const document = parse(/* GraphQL */ ` + query Person { + person(id: 1) { + ...PersonDetails + children { + ...BasePersonDetails + } + } + } + + fragment PersonDetails on Person { + ...BasePersonDetails + name + } + + fragment BasePersonDetails on Person { + id + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + documentMode: DocumentMode.graphQLTag, + }, + { outputFile: '' }, + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + import gql from 'graphql-tag'; + export const BasePersonDetailsFragmentDoc = gql\` + fragment BasePersonDetails on Person { + id + } + \` as unknown as DocumentNode; + export const PersonDetailsFragmentDoc = gql\` + fragment PersonDetails on Person { + ...BasePersonDetails + name + } + \` as unknown as DocumentNode; + export const PersonDocument = gql\` + query Person { + person(id: 1) { + ...PersonDetails + children { + ...BasePersonDetails + } + } + } + \${PersonDetailsFragmentDoc} + \${BasePersonDetailsFragmentDoc}\` as unknown as DocumentNode;" + `); + }); + describe('addTypenameToSelectionSets', () => { it('Check is add __typename to typed document', async () => { const schema = buildSchema(/* GraphQL */ ` diff --git a/packages/plugins/typescript/typescript/CHANGELOG.md b/packages/plugins/typescript/typescript/CHANGELOG.md index ba245e6c7ee..730617b2570 100644 --- a/packages/plugins/typescript/typescript/CHANGELOG.md +++ b/packages/plugins/typescript/typescript/CHANGELOG.md @@ -1,5 +1,27 @@ # @graphql-codegen/typescript +## 6.0.2 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/schema-ast@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/schema-ast/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.1`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/schema-ast@6.0.1 + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.1 ### Patch Changes diff --git a/packages/plugins/typescript/typescript/package.json b/packages/plugins/typescript/typescript/package.json index ae72df0557f..ee8937c1b34 100644 --- a/packages/plugins/typescript/typescript/package.json +++ b/packages/plugins/typescript/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript", - "version": "6.0.1", + "version": "6.0.2", "type": "module", "description": "GraphQL Code Generator plugin for generating TypeScript types", "repository": { diff --git a/packages/presets/client/CHANGELOG.md b/packages/presets/client/CHANGELOG.md index 2cec84c2bc1..bed44affb3a 100644 --- a/packages/presets/client/CHANGELOG.md +++ b/packages/presets/client/CHANGELOG.md @@ -1,5 +1,59 @@ # @graphql-codegen/client-preset +## 6.0.1 + +### Patch Changes + +- [#10848](https://github.com/dotansimha/graphql-code-generator/pull/10848) + [`f3ce427`](https://github.com/dotansimha/graphql-code-generator/commit/f3ce427e251c45b87f462a4584381a76989c628d) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/gql-tag-operations@^6.0.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/gql-tag-operations/v/6.0.0) + (from `6.0.0`, in `dependencies`) + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/add@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/add/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/gql-tag-operations@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/gql-tag-operations/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/typed-document-node@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typed-document-node/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/typescript@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/typescript-operations@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript-operations/v/workspace:^) + (from `^6.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + +- [#10848](https://github.com/dotansimha/graphql-code-generator/pull/10848) + [`f3ce427`](https://github.com/dotansimha/graphql-code-generator/commit/f3ce427e251c45b87f462a4584381a76989c628d) + Thanks [@eddeee888](https://github.com/eddeee888)! - Fix package pinning + +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb), + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/add@7.0.1 + - @graphql-codegen/gql-tag-operations@6.0.1 + - @graphql-codegen/typed-document-node@7.0.1 + - @graphql-codegen/typescript@6.0.2 + - @graphql-codegen/typescript-operations@6.0.3 + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.0 ### Major Changes diff --git a/packages/presets/client/package.json b/packages/presets/client/package.json index 79aa041cfcb..2cf5203357d 100644 --- a/packages/presets/client/package.json +++ b/packages/presets/client/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/client-preset", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator preset for client.", "repository": { diff --git a/packages/presets/graphql-modules/CHANGELOG.md b/packages/presets/graphql-modules/CHANGELOG.md index dfc7fc937dc..de864f43f87 100644 --- a/packages/presets/graphql-modules/CHANGELOG.md +++ b/packages/presets/graphql-modules/CHANGELOG.md @@ -1,5 +1,22 @@ # @graphql-codegen/graphql-modules-preset +## 6.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + - Updated dependency + [`@graphql-codegen/visitor-plugin-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/workspace:^) + (from `^7.0.0`, in `dependencies`) +- Updated dependencies + [[`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb)]: + - @graphql-codegen/visitor-plugin-common@7.0.3 + ## 6.0.0 ### Major Changes diff --git a/packages/presets/graphql-modules/package.json b/packages/presets/graphql-modules/package.json index 4f3f3acf2cb..a1b751a5ca4 100644 --- a/packages/presets/graphql-modules/package.json +++ b/packages/presets/graphql-modules/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/graphql-modules-preset", - "version": "6.0.0", + "version": "6.0.1", "type": "module", "description": "GraphQL Code Generator preset for modularized schema", "repository": { diff --git a/packages/utils/graphql-codegen-testing/CHANGELOG.md b/packages/utils/graphql-codegen-testing/CHANGELOG.md index 3180e4a6a4f..7b0cf268b86 100644 --- a/packages/utils/graphql-codegen-testing/CHANGELOG.md +++ b/packages/utils/graphql-codegen-testing/CHANGELOG.md @@ -1,5 +1,16 @@ # @graphql-codegen/testing +## 5.0.1 + +### Patch Changes + +- [#10849](https://github.com/dotansimha/graphql-code-generator/pull/10849) + [`55a4742`](https://github.com/dotansimha/graphql-code-generator/commit/55a47421273ac795c516a011c257c5af159880cb) + Thanks [@eddeee888](https://github.com/eddeee888)! - dependencies updates: + - Updated dependency + [`@graphql-codegen/plugin-helpers@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/workspace:^) + (from `^7.0.0`, in `dependencies`) + ## 5.0.0 ### Major Changes diff --git a/packages/utils/graphql-codegen-testing/package.json b/packages/utils/graphql-codegen-testing/package.json index 89ccf9b9933..b9ec091f27d 100644 --- a/packages/utils/graphql-codegen-testing/package.json +++ b/packages/utils/graphql-codegen-testing/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/testing", - "version": "5.0.0", + "version": "5.0.1", "type": "module", "description": "GraphQL Codegen Testing Utils", "repository": "git@github.com:dotansimha/graphql-code-generator.git", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13399141332..adc8f861e0c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,39 +40,6 @@ importers: '@eslint/js': specifier: 10.0.1 version: 10.0.1(eslint@10.4.0(jiti@2.7.0)) - '@graphql-codegen/add': - specifier: workspace:* - version: link:packages/plugins/other/add/dist - '@graphql-codegen/cli': - specifier: workspace:* - version: link:packages/graphql-codegen-cli/dist - '@graphql-codegen/client-preset': - specifier: workspace:* - version: link:packages/presets/client/dist - '@graphql-codegen/flow': - specifier: 3.0.1 - version: 3.0.1(graphql@16.14.0) - '@graphql-codegen/flow-resolvers': - specifier: 3.0.2 - version: 3.0.2(graphql@16.14.0) - '@graphql-codegen/graphql-modules-preset': - specifier: workspace:* - version: link:packages/presets/graphql-modules/dist - '@graphql-codegen/typed-document-node': - specifier: workspace:* - version: link:packages/plugins/typescript/typed-document-node/dist - '@graphql-codegen/typescript': - specifier: workspace:* - version: link:packages/plugins/typescript/typescript/dist - '@graphql-codegen/typescript-graphql-files-modules': - specifier: 4.0.1 - version: 4.0.1(graphql@16.14.0) - '@graphql-codegen/typescript-operations': - specifier: workspace:* - version: link:packages/plugins/typescript/operations/dist - '@graphql-codegen/typescript-resolvers': - specifier: workspace:* - version: link:packages/plugins/typescript/resolvers/dist '@ianvs/prettier-plugin-sort-imports': specifier: 4.7.1 version: 4.7.1(@vue/compiler-sfc@3.5.34)(prettier@3.8.3) @@ -96,7 +63,7 @@ importers: version: 10.4.0(jiti@2.7.0) eslint-plugin-import: specifier: 2.32.0 - version: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@10.4.0(jiti@2.7.0)) + version: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)) eslint-plugin-tailwindcss: specifier: npm:@hasparus/eslint-plugin-tailwindcss@3.17.5 version: '@hasparus/eslint-plugin-tailwindcss@3.17.5(tailwindcss@3.4.19(tsx@4.22.0)(yaml@2.9.0))' @@ -189,6 +156,39 @@ importers: specifier: 4.1.6 version: 4.1.6(@types/node@24.12.4)(msw@2.14.6(@types/node@24.12.4)(typescript@6.0.3))(vite@8.0.13(@types/node@24.12.4)(esbuild@0.28.0)(jiti@2.7.0)(tsx@4.22.0)(yaml@2.9.0)) + dev-test/general: + devDependencies: + '@graphql-codegen/add': + specifier: workspace:* + version: link:../../packages/plugins/other/add/dist + '@graphql-codegen/cli': + specifier: workspace:* + version: link:../../packages/graphql-codegen-cli/dist + '@graphql-codegen/flow': + specifier: 3.0.1 + version: 3.0.1(graphql@16.14.0) + '@graphql-codegen/flow-resolvers': + specifier: 3.0.1 + version: 3.0.1(graphql@16.14.0) + '@graphql-codegen/graphql-modules-preset': + specifier: workspace:* + version: link:../../packages/presets/graphql-modules/dist + '@graphql-codegen/typed-document-node': + specifier: workspace:* + version: link:../../packages/plugins/typescript/typed-document-node/dist + '@graphql-codegen/typescript': + specifier: workspace:* + version: link:../../packages/plugins/typescript/typescript/dist + '@graphql-codegen/typescript-graphql-files-modules': + specifier: 4.0.1 + version: 4.0.1(graphql@16.14.0) + '@graphql-codegen/typescript-operations': + specifier: workspace:* + version: link:../../packages/plugins/typescript/operations/dist + '@graphql-codegen/typescript-resolvers': + specifier: workspace:* + version: link:../../packages/plugins/typescript/resolvers/dist + examples/persisted-documents: dependencies: '@graphql-yoga/plugin-persisted-operations': @@ -210,6 +210,9 @@ importers: '@graphql-codegen/cli': specifier: workspace:* version: link:../../packages/graphql-codegen-cli/dist + '@graphql-codegen/client-preset': + specifier: workspace:* + version: link:../../packages/presets/client/dist '@graphql-typed-document-node/core': specifier: 3.2.0 version: 3.2.0(graphql@16.14.0) @@ -1022,6 +1025,33 @@ importers: specifier: ^18.0.0 version: 18.0.0 devDependencies: + '@graphql-codegen/add': + specifier: workspace:* + version: link:../plugins/other/add/dist + '@graphql-codegen/flow': + specifier: 3.0.1 + version: 3.0.1(graphql@16.14.0) + '@graphql-codegen/flow-resolvers': + specifier: 3.0.1 + version: 3.0.1(graphql@16.14.0) + '@graphql-codegen/graphql-modules-preset': + specifier: workspace:* + version: link:../presets/graphql-modules/dist + '@graphql-codegen/typed-document-node': + specifier: workspace:* + version: link:../plugins/typescript/typed-document-node/dist + '@graphql-codegen/typescript': + specifier: workspace:* + version: link:../plugins/typescript/typescript/dist + '@graphql-codegen/typescript-graphql-files-modules': + specifier: 4.0.1 + version: 4.0.1(graphql@16.14.0) + '@graphql-codegen/typescript-operations': + specifier: workspace:* + version: link:../plugins/typescript/operations/dist + '@graphql-codegen/typescript-resolvers': + specifier: workspace:* + version: link:../plugins/typescript/resolvers/dist '@inquirer/testing': specifier: 3.3.6 version: 3.3.6(@inquirer/checkbox@5.1.5(@types/node@24.12.4))(@inquirer/confirm@6.0.13(@types/node@24.12.4))(@inquirer/editor@5.1.2(@types/node@24.12.4))(@inquirer/expand@5.0.14(@types/node@24.12.4))(@inquirer/external-editor@3.0.0(@types/node@24.12.4))(@inquirer/input@5.0.13(@types/node@24.12.4))(@inquirer/number@4.0.13(@types/node@24.12.4))(@inquirer/password@5.0.13(@types/node@24.12.4))(@inquirer/prompts@8.4.3(@types/node@24.12.4))(@inquirer/rawlist@5.2.9(@types/node@24.12.4))(@inquirer/search@4.1.9(@types/node@24.12.4))(@inquirer/select@5.1.5(@types/node@24.12.4))(@types/node@24.12.4)(vitest@4.1.6(@types/node@24.12.4)(msw@2.14.6(@types/node@24.12.4)(typescript@6.0.3))(vite@8.0.13(@types/node@24.12.4)(esbuild@0.28.0)(jiti@2.7.0)(tsx@4.22.0)(yaml@2.9.0))) @@ -3129,6 +3159,12 @@ packages: peerDependencies: graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 + '@graphql-codegen/flow-resolvers@3.0.1': + resolution: {integrity: sha512-3Ea2vdZh7nbdlntAvd/rgOSZV/XVpO6824mA0MUg8leWI3BI893oY/+O9Rq7HgAxszUThbQfTci7qN5Xd9yYVA==} + engines: {node: '>= 16.0.0'} + peerDependencies: + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 + '@graphql-codegen/flow-resolvers@3.0.2': resolution: {integrity: sha512-+tPU+ye4MQWAmppicYSwc7xJ8mONc1ItO4jskpF/dSeLjfymBdNDsXuzzaNMJ7FrJp0PGi/CFWcrLXJQp/odnQ==} engines: {node: '>= 16.0.0'} @@ -13847,6 +13883,19 @@ snapshots: - encoding - supports-color + '@graphql-codegen/flow-resolvers@3.0.1(graphql@16.14.0)': + dependencies: + '@graphql-codegen/flow': 3.0.1(graphql@16.14.0) + '@graphql-codegen/plugin-helpers': 3.1.2(graphql@16.14.0) + '@graphql-codegen/visitor-plugin-common': 2.13.8(graphql@16.14.0) + '@graphql-tools/utils': 10.11.0(graphql@16.14.0) + auto-bind: 4.0.0 + graphql: 16.14.0 + tslib: 2.8.1 + transitivePeerDependencies: + - encoding + - supports-color + '@graphql-codegen/flow-resolvers@3.0.2(graphql@16.14.0)': dependencies: '@graphql-codegen/flow': 3.0.1(graphql@16.14.0) @@ -18639,7 +18688,7 @@ snapshots: eslint: 10.4.0(jiti@2.7.0) eslint-import-resolver-node: 0.3.10 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@10.4.0(jiti@2.7.0)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)) eslint-plugin-jsx-a11y: 6.10.2(eslint@10.4.0(jiti@2.7.0)) eslint-plugin-react: 7.37.5(eslint@10.4.0(jiti@2.7.0)) eslint-plugin-react-hooks: 5.0.0-canary-7118f5dd7-20230705(eslint@10.4.0(jiti@2.7.0)) @@ -18673,7 +18722,7 @@ snapshots: tinyglobby: 0.2.16 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@10.4.0(jiti@2.7.0)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)) transitivePeerDependencies: - supports-color @@ -18774,7 +18823,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@10.4.0(jiti@2.7.0)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.3(eslint@10.4.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)))(eslint@10.4.0(jiti@2.7.0)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2087cc5259d..00e115f409c 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -8,6 +8,7 @@ packages: - packages/utils/* - website - examples/**/* + - dev-test/* - dev-test-apollo-tooling allowBuilds: diff --git a/website/src/pages/docs/integrations/federation.mdx b/website/src/pages/docs/integrations/federation.mdx index 6a3ff59a4c5..cb863ca6528 100644 --- a/website/src/pages/docs/integrations/federation.mdx +++ b/website/src/pages/docs/integrations/federation.mdx @@ -26,3 +26,27 @@ export default config It will add the required GraphQL directives to your codegen schema and generate a compatible resolvers signature for [Apollo Federation](https://the-guild.dev/graphql/hive/federation). + +For schemas using Apollo Federation v2, the automatic injection of legacy Federation v1 definitions +(such as `scalar _FieldSet`) can cause duplicate definition errors during validation. + +To resolve this, set `disableFederationDirectiveAndScalarInjection` to true in your configuration. +This suppresses the automatic injection of legacy directives and scalars, ensuring full +compatibility with Federation v2 schemas and preventing validation failures. + +```ts +import { CodegenConfig } from '@graphql-codegen/cli' + +const config: CodegenConfig = { + schema: '', + config: { + federation: true, + disableFederationDirectiveAndScalarInjection: true + }, + generates: { + // ... + } +} + +export default config +```