Skip to content

Conversation

@ikusakov2
Copy link

@ikusakov2 ikusakov2 commented Nov 18, 2025

Description

We want to decoupe typescipt-operations from typescript plugin.

This PR removes InputMaybe and Scalars from generated variables.

Related #10496

Details

  • This PR overrides 3 functions in packages/plugins/typescript/operations/src/ts-operation-variables-to-object.ts
  • getScalar is an override to render normal typescript types instead of Scalars[...][...]. It takes into account config.scalars
  • wrapMaybe and clearOptional functions are complementary: one appends a suffix; the other strips it.
  • I had to broaden the clearOptional function visibility in packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts so it is possible to override it.
  • The fix affected lots of unit cases (which was expected), seemingly covering all possible scenarios (optional vs non-optional, Arrays). Writing more unit tests for this PR looks like a duplication of efforts.

Type of change

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

How Has This Been Tested?

  • Unit tests

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: bbaed46

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@graphql-codegen/typescript-operations Major
@graphql-codegen/typescript Minor
@graphql-codegen/client-preset Patch

Not sure what this means? Click here to learn what changesets are.

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

@ikusakov2 ikusakov2 changed the base branch from master to master-next November 18, 2025 20:03
@eddeee888
Copy link
Collaborator

eddeee888 commented Nov 19, 2025

Thank you! Looking like it's on the right track!

There are just a few minor missing things:

  • A changeset is required.
    • You can run yarn changeset to create a patch/minor/major release intention and commit it
  • There are a few "integration-style" tests that are failing
    • You can run the following to re-generate all those tests and commit the changes (if the changes match your expectation) yarn build && yarn generate:examples:cjs && EXAMPLE_TYPE=normal yarn examples:codegen

@ikusakov2
Copy link
Author

Thank you for your help!
Let me figure out these integration tests...

@ikusakov2
Copy link
Author

I have added the changes that we discussed. Could you please check?
Changes:

  • changelog
  • Scalars from config
  • integration tests

@ikusakov2 ikusakov2 requested a review from eddeee888 November 22, 2025 01:14
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.

3 participants