Skip to content

Conversation

@TomasBayer
Copy link

@TomasBayer TomasBayer commented Feb 6, 2026

Fields, input fields, and arguments already support lazy type references via strings and lambdas to avoid circular imports. This PR adds the same support to member types of Unions. See this issue for details: #1600

Example:

  class SomeUnion(Union):
      class Meta:
          types = ("package.Type", lambda: AnotherType) 

This change is non-breaking.

This change allows union member types to be defined using string references
or functions, similar to how field, input field, or argument types can be
declared. The actual type classes will be resolved only during schema
construction.
Copy link

@ahter ahter left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements @TomasBayer. This looks good to me.

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