graphql-api icon indicating copy to clipboard operation
graphql-api copied to clipboard

Recursion doesn't play nicely with unions

Open teh opened this issue 8 years ago • 1 comments

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 avatar Mar 19 '17 22:03 teh

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...

teh avatar Mar 19 '17 23:03 teh