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

fix: Selection set initializers for fragment type cases #3487

Open
calvincestari opened this issue Dec 11, 2024 · 0 comments
Open

fix: Selection set initializers for fragment type cases #3487

calvincestari opened this issue Dec 11, 2024 · 0 comments
Assignees
Labels
codegen Issues related to or arising from code generation planned-next Slated to be included in the next release

Comments

@calvincestari
Copy link
Member

Related to #3482.

When a fragment type case is declared on a union that does not matches the field type the selection set initializer parameters are missing. See sample below and take note of the size field types and the type case used on the BigOrSmallFragment declaration. In the generated Swift code you will also notice that the Animal.AsCat.Size.AsBigOrSmall initializer properties are missing.

There are two possible fixes (2 is preferred):

  1. Generate the missing properties into the initializer
  2. Generate a fragment initializer instead of the selection fields

Schema:

type Query {
  zoo: Zoo
}

type Zoo {
  description: String!
  animals: [Animal]
}

type Dog {
  size: BigOrSmall!
}

type Cat {
  size: BaseSize!
}

type Big {
  height: Int!
}

type Small {
  height: Int!
}

union Animal = Dog | Cat

union BigOrSmall = Big | Small

union BaseSize = Big | Small

Operation:

query Zoo {
  zoo {
    ...ZooFragment
  }
}

fragment ZooFragment on Zoo {
  description
  animals {
    ... on Dog {
      size {
        ...BigOrSmallFragment
      }
    }
    ... on Cat {
      size {
        ...BigOrSmallFragment
      }
    }
  }
}

fragment BigOrSmallFragment on BigOrSmall {
  ...BigFragment
  ...SmallFragment
}

fragment BigFragment on Big {
  height
}

fragment SmallFragment on Small {
  height
}
@calvincestari calvincestari added codegen Issues related to or arising from code generation planned-next Slated to be included in the next release labels Dec 11, 2024
@calvincestari calvincestari added this to the Minor Releases (1.x) milestone Dec 11, 2024
@calvincestari calvincestari self-assigned this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Issues related to or arising from code generation planned-next Slated to be included in the next release
Projects
None yet
Development

No branches or pull requests

1 participant