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

Add a flag to disable the fieldsCanMerge validation on disjoint types #4320

Closed
martinbonnin opened this issue Aug 4, 2022 · 3 comments
Closed

Comments

@martinbonnin
Copy link
Contributor

martinbonnin commented Aug 4, 2022

Given this schema:

  type Query {
    foo: PropertyValue
  }
  union PropertyValue = PropertyValueBoolean | PropertyValueInt

  type PropertyValueBoolean {
    name: String!
    value: Boolean
  }
  type PropertyValueInt {
    name: String!
    value: Int
  }

and this query:

  query GetFoo {
    foo {
      ...PropertyValue
    }
  }
  fragment PropertyValue on PropertyValue {
    __typename
    ... on PropertyValueBoolean {
        value
    }
    ... on PropertyValueInt {
        value
    }
  }

Validation fails with:

`value` cannot be merged with `value`: they have different shapes. 

This is expected from reading the spec although it's not clear what the benefit of this validation is on completely disjoint types and it makes the generated models more akward to use.

Other users have bumped into the same issue in other projects like here

We could have a Gradle flag that specifically disables this validation:

apollo {
  fieldOnDisjointTypesMustMerge = false
}

More context:

@pt2121
Copy link
Contributor

pt2121 commented Aug 14, 2022

Can I give this a try?

pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 17, 2022
pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 17, 2022
pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 18, 2022
pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 18, 2022
pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 18, 2022
pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 18, 2022
@martinbonnin
Copy link
Contributor Author

Very sorry for the delay @pt2121 ! Thanks for looking into this. I'm reviewing the PR now, I'll follow up there.

pt2121 added a commit to pt2121/apollo-kotlin that referenced this issue Aug 27, 2022
martinbonnin pushed a commit that referenced this issue Aug 27, 2022
)

* Add a flag to disable fieldsCanMerge validation on disjoint types (#4320)

* Fix fieldsOnDisjointTypesMustMerge flag (#4320)

* Fix comment for fieldsOnDisjointTypesMustMerge (#4320)

* Add unit tests for fieldsOnDisjointTypesMustMerge

* Update test for fieldsOnDisjointTypesMustMerge #4320

Co-authored-by: Prat T <[email protected]>
@martinbonnin
Copy link
Contributor Author

This is now available in 3.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants