Closed cmeeren closed 1 week ago
There is a related issue for mutation but would be really nice if it worked for both: #6795
We wont support that as unions do not work with scalars. I also do not want to introduce some wrapping here as this would result in a bad schema design. I am closing.
There is a related issue for mutation but would be really nice if it worked for both: https://github.com/ChilliCream/graphql-platform/issues/6795
For mutations this should work fine. I will have a look at the other issue.
@michaelstaib Would you mind elaborating on the bad schema design you mention? I'm currently wrapping my types manually. I have fields that return a list of objects, and this field has error conditions I want to return as part of the schema, too.
Product
Hot Chocolate
Is your feature request related to a problem?
I need to use query conventions (e.g.,
[Error]
) with fields that return non-object types such asList
or primitives such asString
.The solution you'd like
I realize that unions do not support lists or primitives as one of their cases. When a field using query conventions returns a non-object type, I would like HotChocolate to automatically wrap the OK result for me, similar (though not identical) to mutation conventions.
For example, the list/primitive could be wrapped in a type called
...ResultValue
which has a single memberValue
that is the returned list/primitive. The...ResultValue
type will then be the success case of the of the...Result
union.