Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[resolvers] Ensure __isTypeof is only generated for implementing types (of Interfaces) or Union members #10283

Open
wants to merge 6 commits into
base: federation-fixes
Choose a base branch
from

Conversation

eddeee888
Copy link
Collaborator

Description

Only implementing types (of Interfaces) or Union members need __isTypeOf to help pick the right type name for the responses. This PR implements this behaviour by only generating __isTypeOf for said object types.

This PR also introduces _parsedSchemaMeta to hold metadata about the schema. This can help with performance and reduces complexity because we only parse through the schema once to collect meta about the types, and use the collected meta for subsequent generation.


Note: This is an re-implementation for #10138, because this will be released as a breaking change instead of a new config.

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

  • Unit Test

Copy link

changeset-bot bot commented Feb 8, 2025

🦋 Changeset detected

Latest commit: 61e6158

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

This PR includes changesets to release 18 packages
Name Type
@graphql-codegen/visitor-plugin-common Major
@graphql-codegen/typescript-resolvers Major
@graphql-codegen/plugin-helpers Major
@graphql-codegen/typescript-document-nodes Patch
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/typescript-operations Patch
@graphql-codegen/typed-document-node Patch
@graphql-codegen/typescript Patch
@graphql-codegen/introspection Patch
@graphql-codegen/client-preset Patch
@graphql-codegen/graphql-modules-preset Patch
@graphql-codegen/cli Patch
@graphql-codegen/core Patch
@graphql-codegen/testing Patch
@graphql-codegen/add Patch
@graphql-codegen/fragment-matcher Patch
@graphql-codegen/schema-ast Patch
@graphql-codegen/time 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

@eddeee888 eddeee888 changed the title Ensure __isTypeof is only generated for implementing types (of Interfaces) or Union members [resolvers] Ensure __isTypeof is only generated for implementing types (of Interfaces) or Union members Feb 8, 2025
@@ -679,7 +694,6 @@ export class BaseResolversVisitor<
protected _hasReferencedResolversUnionTypes = false;
protected _hasReferencedResolversInterfaceTypes = false;
protected _resolversUnionTypes: Record<string, string> = {};
protected _resolversUnionParentTypes: Record<string, string> = {};
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 is no longer used, so we can remove it now.

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.

1 participant