Skip to content

Conversation

@eddeee888
Copy link
Collaborator

@eddeee888 eddeee888 commented Dec 30, 2025

Description

ts-selection-set-processor.ts is an old selection set processor that picks from typescript plugin types.
Since we no longer have this dependency, it should be safe to clean this up in this PR.

We can also update and remove relevant tests

Related #10496

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit test
  • Integration test

@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2025

⚠️ No Changeset found

Latest commit: db5e004

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 6.0.3-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 5.0.1-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 5.0.5-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 5.0.6-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 5.1.3-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 6.1.3-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 5.0.6-alpha-20260101134152-db5e004a3d2c64200376026e73d4a178cd47367f npm ↗︎ unpkg ↗︎

@eddeee888 eddeee888 force-pushed the master-next-clean-up-preResolveTypes-false branch from 20e7671 to 5609723 Compare January 1, 2026 11:26
Comment on lines -159 to -209
it('Should handle "namespacedImportName" and "preResolveTypes" together', async () => {
const testSchema = buildSchema(/* GraphQL */ `
type Query {
f: E
user: User!
}

enum E {
A
B
}

scalar JSON

type User {
id: ID!
f: E
j: JSON
}
`);
const ast = parse(/* GraphQL */ `
query test {
f
user {
id
f
j
}
}
`);
const config = { namespacedImportName: 'Types', preResolveTypes: true };
const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, {
outputFile: '',
});

expect(content).toMatchInlineSnapshot(
`
"export type E =
| 'A'
| 'B';

export type TestQueryVariables = Exact<{ [key: string]: never; }>;


export type TestQuery = { f: Types.E | null, user: { id: string, f: Types.E | null, j: any | null } };
"
`
);

await validate(content, '', [`Cannot find namespace 'Types'.`]);
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -46 to -92
it('Should handle "namespacedImportName" and add it when specified', async () => {
const ast = parse(/* GraphQL */ `
query notifications {
notifications {
id

... on TextNotification {
text
textAlias: text
}

... on TextNotification {
text
}

... on ImageNotification {
imageUrl
metadata {
created: createdBy
}
}
}
}
`);
const config = { preResolveTypes: false, namespacedImportName: 'Types' };
const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, {
outputFile: '',
});

expect(content).toMatchInlineSnapshot(`
"export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>;


export type NotificationsQuery = { notifications: Array<
| (
Pick<Types.TextNotification, 'text' | 'id'>
& { textAlias: Types.TextNotification['text'] }
)
| (
Pick<Types.ImageNotification, 'imageUrl' | 'id'>
& { metadata: { created: Types.ImageMetadata['createdBy'] } }
)
> };
"
`);
await validate(content, '', [`Cannot find namespace 'Types'.`]);
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -368 to -396
describe('Scalars', () => {
it('Should include scalars when doing pick', async () => {
const testSchema = buildSchema(/* GraphQL */ `
scalar Date
type Query {
me: User
}
type User {
id: ID!
joinDate: Date!
}
`);

const doc = parse(/* GraphQL */ `
query {
me {
id
joinDate
}
}
`);
const config = { preResolveTypes: false };
const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: doc }], config, {
outputFile: '',
});
expect(content).toContain(`Pick<User, 'id' | 'joinDate'>`);
await validate(content);
});
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entirely tests the preResolveTypes: false approach, so it's ok to remove.

@eddeee888 eddeee888 force-pushed the master-next-clean-up-preResolveTypes-false branch from a0436f5 to f271167 Compare January 1, 2026 12:25
Comment on lines -1237 to -1246
it('Should add __typename as optional when its not specified', async () => {
const ast = parse(/* GraphQL */ `
query {
dummy
}
`);
const config = { preResolveTypes: false };
const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, {
outputFile: '',
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is no longer the expected behaviour. So it can be removed.

"
`);
await validate(content);
});

it('Should add __typename correctly when unions are in use', async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this test to test correct __typename generation instead.

Previously, __typename would be optional so it'd appear in the generated template

"
`);
await validate(content);
});

it('Should add __typename correctly when interfaces are in use', async () => {
it('Should add __typename correctly when interfaces are in use and nonOptionalTypename=true', async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddeee888 eddeee888 force-pushed the master-next-clean-up-preResolveTypes-false branch 2 times, most recently from ccdcfbe to 97ba058 Compare January 1, 2026 13:24
@eddeee888 eddeee888 force-pushed the master-next-clean-up-preResolveTypes-false branch from 97ba058 to 2a616db Compare January 1, 2026 13:26
@eddeee888 eddeee888 changed the title [typescript-operations] Clean up selection set processor that depends on typescript plugin [typescript-operations] Clean up selection set processor that depends on typescript plugin (preResolveTypes: false) Jan 1, 2026
@eddeee888 eddeee888 marked this pull request as ready for review January 1, 2026 13:42
@eddeee888 eddeee888 merged commit 99ab3a8 into master-next Jan 1, 2026
19 checks passed
@eddeee888 eddeee888 deleted the master-next-clean-up-preResolveTypes-false branch January 1, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants