Skip to content

Codegen: __mergedSources on asSomethingType intermittently repeats then removed. #3511

Open
@jimisaacs

Description

@jimisaacs

Summary

We have recently upgraded from 1.15.0 to 1.17.0, and I have seen the following behavior. I am calling this a bug report, but it might also be a request for confirmation that this behavior was identified and fixed already. I can't seem to repro right now so maybe it was 🤷.

If I have GraphQL schema like this:

type Query {
    something: MaybeSomething
}

interface MaybeSomething {
    darkside: Boolean
    complete: Boolean
}

type DefinitelySomething implements MaybeSomething {
    darkside: Boolean
    complete: Boolean
}

and a GraphQL operation like this:

query GetSomething {
    something {
        ...MaybeSomething
    }
}

fragment MaybeSomething on MaybeSomething {
    ...DefinitelySomethingFragment
    ...DefinitelySomethingSomethingFragment
}

fragment DefinitelySomethingFragment on DefinitelySomething {
    darkside
}

fragment DefinitelySomethingSomethingFragment on DefinitelySomething {
    complete
}

The codegen for GetSomethingQuery.graphql.swift will sometimes contain the following:

/* ... */
      public struct AsDefinitelySomething: MyMockSchema.InlineFragment, ApolloAPI.CompositeInlineFragment {
        /* ... */
        public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [
          GetSomethingQuery.Data.Something.self,
          MaybeSomething.AsDefinitelySomething.self,
          DefinitelySomethingFragment.self,
          DefinitelySomethingSomethingFragment.self
        ] }
        /* ... */
      }
/* ... */

and sometimes it will contain the following instead:

/* ... */
      public struct AsDefinitelySomething: MyMockSchema.InlineFragment, ApolloAPI.CompositeInlineFragment {
        /* ... */
        public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [
          GetSomethingQuery.Data.Something.self,
          MaybeSomething.AsDefinitelySomething.self,
          MaybeSomething.AsDefinitelySomething.self,
          DefinitelySomethingFragment.self,
          DefinitelySomethingSomethingFragment.self
        ] }
        /* ... */
      }
/* ... */

Notice the duplicate MaybeSomething.AsDefinitelySomething.self, versus it being absent. This is what happened intermittently after codegen, though I'm not sure if it was only for 1.15.0 and is potentially fixed now.

Version

Maybe 1.15.0, or maybe 1.17.0

Steps to reproduce the behavior

Run codegen repeatedly with the aforementioned GraphQL sources.

Logs

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