Closed bringking closed 7 years ago
Derp, I was passing the Module and not the "type". I fixed this by just changing ->
def banner_types do
GraphQL.Type.Union.new %{
name: "BannerTypes",
types: [Product],
resolver: fn
(product) -> Product
end
}
end
to
def banner_types do
GraphQL.Type.Union.new %{
name: "BannerTypes",
types: [Product.type],
resolver: fn
(product) -> Product.type
end
}
end
Thanks for the awesome library, I am loving creating a GraphQL service in Elixir. I am running into an issue I hope you can shed some light on. I have a field on a value that is a string "type". This field is a string from the backing API, but I want expose it as a Union Type. I setup the "Banner" type as shown -
and the "banner_types" union type as follows -
I can see the initial resolver in the Banner make the API call, then pass the result to the the Union resolver, which resolves the Type
Product
. This correctly resolves the__typename
in the query, but it fails on any fragments forProduct
I get something like -
Any idea how to make this work with fragments? Thank you again!