graphql-api
graphql-api copied to clipboard
Recursion doesn't play nicely with unions
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
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...