graphile / crystal

🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
https://graphile.org/
Other
12.49k stars 568 forks source link

Polymorphic types offer mutations under some circumstances? #2083

Closed benjie closed 4 weeks ago

benjie commented 4 weeks ago

Polymorphic types shouldn't offer mutations currently, since they don't work.

Extracted from #2077


I can't find a way to create a Profile when creating an Individual

In my system, a Profile is always one of a few given types. It is unexpected that a Profile should be created without an associated e.g. Individual. Preferably, I would like to remove createProfile from my mutations altogether and expose only e.g. createIndividual. However, this means createIndividual needs to be able to create the base Profile, which it seems is not possible?

Current

mutation {
  createIndividual(input: {individual: {
    # This is the only property available in `individual`.
    profileByRowId {
      # There are no properties available here for creating a profile
    }
  }}) {
    id
  }
}

Expected

mutation {
  createIndividual(input: {individual: {
    profile: {
      name: "Felix"
    }
  }}) {
    id
  }
}
FelixZY commented 3 weeks ago

Ah 🤦‍♂️ I should have thought of that! Closing #2083; please re-open if it does turn out to be an issue.

https://github.com/graphile/crystal/issues/2077#issuecomment-2148422331

Confirmed. Polymorphic types do not appear to support polymorphism at this time. I'll have to expose my own createX function.