haskell-graphql / graphql-api

Write type-safe GraphQL services in Haskell
BSD 3-Clause "New" or "Revised" License
406 stars 35 forks source link

Recursion doesn't play nicely with unions #115

Open teh opened 7 years ago

teh commented 7 years ago

I tried modelling a tree with recursive entries, but if try to model this:

type TreeEntryQ = Union "TreeEntryQ" '[FileQ, RecTreeQ, SymlinkQ]

I get:

    • Invalid TypeIndex. Must be Object but got: RecTreeQ

because RecTreeQ is a newtype

teh commented 7 years ago

Code in question: https://github.com/jml/graphql-api/blob/master/src/GraphQL/Resolver.hs#L433-L444

One solution would be to relax the constraint for what types we allow in unions. We can resolve anything that has a HasResolver instance, but OTOH the current error messages are quite nice...