Add include_typename configuration option for better GraphQL API compatibility#379
Merged
DamianCzajkowski merged 13 commits intomirumee:mainfrom Oct 20, 2025
Merged
Add include_typename configuration option for better GraphQL API compatibility#379DamianCzajkowski merged 13 commits intomirumee:mainfrom
include_typename configuration option for better GraphQL API compatibility#379DamianCzajkowski merged 13 commits intomirumee:mainfrom
Conversation
…tTypesGenerator Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
- Fix parsing error in test: change 'animals' to 'animal' to match schema - Always generate discriminator for union types (even when include_typename=False) - Make typename__ field Optional[Literal[...]] = None when include_typename=False - This allows models to work with APIs that don't return __typename while maintaining union discrimination capability Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
…name unavailable Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
…-374 Add `include_typename` configuration option for better GraphQL API compatibility
Contributor
Author
|
Hey @DamianCzajkowski @KarolJagodzinski can you take a look? |
Collaborator
|
Hi @jacksonpradolima your code looks really nice, are you able to fix those issues with linters? |
Co-authored-by: jacksonpradolima <7774063+jacksonpradolima@users.noreply.github.com>
…-43f1-b578-d34db1b5530c Fix linting errors: line length and import sorting
Contributor
Author
|
@DamianCzajkowski thanks! |
Collaborator
|
It looks like it's still failing. Try to run:
and then tests: |
Contributor
Author
|
@DamianCzajkowski |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #374
This pull request introduces a new
include_typenameoption throughout the code generation pipeline, allowing users to control whether__typenamefields and union discriminators are included in generated client code. The change is propagated through settings, generators, and helper functions, and the logic for handling unions and fragments is updated to respect this new flag.Settings and Configuration
include_typenameboolean option to theClientSettingsdataclass insettings.py, including messaging to indicate whether__typenamefields are included in generated queries. [1] [2] [3]Generator Initialization and Propagation
FragmentsGenerator,PackageGenerator,ResultTypesGenerator) to accept and store theinclude_typenameflag, and ensured it is passed through all relevant generator creation and function calls. [1] [2] [3] [4] [5] [6] [7] [8]Union Annotation and Typename Logic
result_fields.pyso that wheninclude_typename=False, union types are generated without the discriminator (i.e., without__typenameinAnnotated). [1] [2] [3] [4]Field and Fragment Handling
include_typenameflag, ensuring that__typenamefields are only added when requested. [1] [2] [3] [4]Pipeline Integration
include_typenamesetting is propagated through the package generator pipeline and all relevant function calls, so the behavior is consistent for all generated code.These changes give users fine-grained control over the inclusion of
__typenamefields and union discriminators in generated clients, improving flexibility and compatibility with various GraphQL server configurations.