Skip to content

Duplicate entries in __mergedSources #3321

Closed
@Iron-Ham

Description

@Iron-Ham

Summary

I've noticed that we occasionally get duplicate entries in merged sources of generated files. It often takes the form of:

public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [
  UserListItemFragment.self,
  AvatarFragment.self,
  FeedItemFragment.AsFollowRecommendationFeedItem.Followee.AsUser.self,
  FeedItemFragment.AsFollowRecommendationFeedItem.Followee.AsUser.self
] }

Note that this has been a bug in some form since at least 1.2.0. In previous versions, this was a rare event. In 1.7.1, it's a certainty.

Version

1.7.1

Steps to reproduce the behavior

I've been able to reliably reproduce this by having both an in-line fragment on a member of a union type and a named fragment that relies on the same underlying type within the same selection set:

# Within a query response selection set

... on MyUnionType { # I don't know if this has to be a union type, but this seems to be the case that this is occurring in.
  ... on User { 
    # Whatever selections are needed
  }
  ... UserListItemFragment
}

In this instance:

  • MyUnionType is a union type that includes User
  • UserListItemFragment is a named fragment on User

WORKAROUND:

Instead of structuring your selection as above, structure it like so:

...on MyUnionType {
  ... on User {
    ...UserListItemFragment
  }
}

Logs

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions