knvjun
Absinthe union resolve_type list_of/1
Hi guys! I need help. I’m looking for a way to resolve a list_of(:object) in union.
Here’s what I did.
object :community_queries do
field :search, type: :search_result do
arg(:keyword, non_null(:string))
resolve(&CommunityResolver.search/3)
end
end
…
union :search_result do
description "A search result"
types [:person, :business]
resolve_type fn
%Person{}, _ -> list_of(:person)
%Business{}, _ -> list_of(:business)
end
end
In the code above. I tried to put a list_of(:person) in resolve_type and it returns error like this
invalid quoted expression: %Absinthe.Blueprint.TypeReference.List{errors: [], of_type: :person}
Then I tried this one
object :community_queries do
field :search, type: list_of(:search_result) do
arg(:keyword, non_null(:string))
resolve(&CommunityResolver.search/3)
end
end
…
union :search_result do
description "A search result"
types [:person, :business]
resolve_type fn
%Person{}, _ -> :person
%Business{}, _ -> :business
end
end
It returns
(BadMapError) expected a map, got: [%{name: "John"}, ...
I’ve also tried putting it in types like this but also got errors.
...
types [list_of(:person), list_of(:business)]
resolve_type fn
...
Is there a possible workaround for this?
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
Popular in Questions
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Other popular topics
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New







