Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6616585
integration test
Jan 7, 2026
7e204c1
cleanups
ikusakov Jan 7, 2026
2fc4571
cleanups2
ikusakov Jan 7, 2026
056dbd0
Merge remote-tracking branch 'upstream/master-next' into feature/add-…
ikusakov Jan 7, 2026
ba85977
fixed a bug with external fragments
ikusakov Jan 7, 2026
6fd5428
cleanup
ikusakov Jan 7, 2026
790b876
keep generated files, refactored visitorwq
ikusakov Jan 8, 2026
e73b9ba
cleanup
ikusakov Jan 8, 2026
1f54f42
changeset
ikusakov Jan 9, 2026
900aa10
adding missing dependency
ikusakov Jan 9, 2026
10a2774
delete temporary files
ikusakov Jan 12, 2026
10d3b85
cleanup
ikusakov Jan 12, 2026
9b3dbf8
cleanups
ikusakov Jan 12, 2026
64b7834
Adding back the integration tests + fix them
ikusakov Jan 12, 2026
17c9614
Merge remote-tracking branch 'upstream/master-next' into feature/add-…
ikusakov Jan 12, 2026
ab0ab18
merged + fixes
ikusakov Jan 12, 2026
1498d8f
cleanup
ikusakov Jan 12, 2026
3839b02
cleanup
ikusakov Jan 12, 2026
ad44930
patching near-operation-file preset
ikusakov Jan 15, 2026
c2c6ea0
cleanup
ikusakov Jan 15, 2026
4d86e60
adding duplicates case to integration tests
ikusakov Jan 15, 2026
85fd378
Fixing bug with duplicates generated when using extractAllFieldsToTyp…
ikusakov Jan 15, 2026
d7e75e3
cleanup
ikusakov Jan 15, 2026
28e61b0
Merge remote-tracking branch 'upstream/master-next' into feature/add-…
ikusakov Jan 15, 2026
b474a3f
prevent running prettier on generated code
ikusakov Jan 16, 2026
5f4666c
cleanups
ikusakov Jan 16, 2026
da8f02a
cleanup
ikusakov Jan 16, 2026
899fd58
adding unit tests
ikusakov Jan 16, 2026
4789809
update changeset
ikusakov Jan 16, 2026
15b4278
cleanups
ikusakov Jan 18, 2026
24f7aec
try resolving graphql 16 error
ikusakov Jan 18, 2026
ed99011
remove unused deps
ikusakov Jan 18, 2026
2740719
remove unused deps
ikusakov Jan 18, 2026
65d158a
cleanups
ikusakov Jan 18, 2026
fca2536
Revert and apply minimal yarn.lock changes
eddeee888 Jan 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/upset-bars-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-codegen/typescript-operations': minor
'@graphql-codegen/visitor-plugin-common': minor
---

Fixing 2 bugs: 1) including enums from external fragments; 2) extractAllFieldsToTypesCompact does not create duplicates
20 changes: 20 additions & 0 deletions dev-test-apollo-tooling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The `dev-test-apollo-tooling` package is an example of migrating from Apollo tooling to GraphQL Codegen. It attempts to generate output as close as possible to Apollo tooling’s output. Note: **this package is a work in progress** and currently requires a patch to `near-operation-file`. We will fix this package soon.

How to run this package:

1. Make sure you have the correct Yarn version installed (check the root package.json, `packageManager` entry). Otherwise, you might run into unexplained bugs.
2. In the monorepo root, run:

yarn clean && yarn install && yarn build

3. Patch `near-operation-file` manually (the automatic patch doesn’t always work). In the monorepo root, run:

yarn postinstall

4. Go to the `dev-test-apollo-tooling` directory and run:

cd dev-test-apollo-tooling
yarn install
yarn start

This will generate type files in `dev-test-apollo-tooling/src/__generated__/*`.
91 changes: 91 additions & 0 deletions dev-test-apollo-tooling/cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env ts-node

import { generate } from '@graphql-codegen/cli';
import type { Types } from '@graphql-codegen/plugin-helpers';

export const GENERATED = '__generated__';
export const GLOBAL_TYPES_FILE = 'globalTypes.ts';
export const TS_GENERATED_FILE_HEADER = `\
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
`;

/**
* The following GraphQL Codegen config matches as closely as possible
* to the old apollo-tooling codegen
* @see https://github.com/apollographql/apollo-tooling/issues/2053
* */
const GRAPHQL_CODEGEN_CONFIG = {
useTypeImports: true,
namingConvention: 'keep', // Keeps naming as-is
avoidOptionals: false, // Allow '?' on variables fields
nonOptionalTypename: true, // Forces `__typename` on all selection sets
skipTypeNameForRoot: true, // Don't generate __typename for root types
omitOperationSuffix: true, // Don't add 'Query', 'Mutation' or 'Subscription' suffixes to operation result types
fragmentSuffix: '', // Don't add 'Fragment' suffix to fragment result types
extractAllFieldsToTypesCompact: true, // Extracts all fields to separate types (similar to apollo-codegen behavior)
printFieldsOnNewLines: true, // Prints each field on a new line (similar to apollo-codegen behavior)
importTypesNamespace: '', // Disable namespace prefix on imported types (preset config)
enumType: 'native',
generatesOperationTypes: true,
};

export const main = async () => {
const cwd = process.cwd();

const localSchemaFilePath = `${cwd}/schema.graphql`;

const includes = ['src'];

const generateFiles: { [scanPath: string]: Types.ConfiguredOutput } = {};

// Prepare the required structure for GraphQL Codegen
includes.forEach((include: string) => {
generateFiles[include] = {
preset: 'near-operation-file', // This preset tells the codegen to generate multiple files instead of one
presetConfig: {
extension: '.ts', // Matches the existing Apollo-Codegen file naming
// FIXME: The following config is required, but it is not needed with the recent version of typescript-operations.
// So - when the new version of near-operation-file' is available - fix this.
baseTypesPath: 'unused',
folder: GENERATED, // Output folder for generated files
importTypesNamespace: '', // Disable namespace prefix on imported types
},
plugins: [
'typescript-operations',
{
add: {
content: TS_GENERATED_FILE_HEADER,
},
},
],
};
});

await generate(
{
schema: localSchemaFilePath,
documents: [
// matching js extensins as well - there are cases where js files are not converted to typescript yet
// (but the package is typescript)
...includes.map((include: any) => `${include}/**/*.{js,jsx,ts,tsx}`),
`!**/${GENERATED}/**`,
],
config: GRAPHQL_CODEGEN_CONFIG,
generates: generateFiles,
silent: false,
debug: true,
verbose: true,
},
true // overwrite existing files
);
};

if (import.meta.url === process.argv[1] || import.meta.url === `file://${process.argv[1]}`) {
main().catch(e => {
console.error(e);
process.exit(1);
});
}
30 changes: 30 additions & 0 deletions dev-test-apollo-tooling/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "dev-test-apollo-tooling",
"description": "A setup which mimics Apollo tooling generation as close as possible",
"version": "0.0.1",
"type": "module",
"dependencies": {
"@apollo/client": "3.13.8",
"@graphql-codegen/cli": "*",
"@graphql-codegen/plugin-helpers": "*",
"@graphql-codegen/typescript-operations": "*",
"@graphql-codegen/visitor-plugin-common": "*",
"@graphql-codegen/typed-document-node": "*"
},
"devDependencies": {
"@types/node": "^25.0.3",
"tsx": "4.7.0",
"typescript": "^5.9.3",
"vitest": "4.0.4"
},
"files": [
"cli"
],
"scripts": {
"start": "tsx cli/index.ts",
"start:debug": "NODE_OPTIONS='--trace-warnings' tsx cli/index.ts",
"start:verbose": "DEBUG='*' tsx cli/index.ts",
"test": "vitest --no-watch"
},
"sideEffects": false
}
Loading
Loading