Gulliver
How to use nested arguments in Absinthe
Good morning ladies and gents,
I’d have a quick question regarding the Absinthe queries.
Is this following query possible at all:
{ users(order: DESC) { id email clients(order: ASC) { id email } } }
I couldn’t find any examples describing how to implement these nested queries. So far I’ve only managed to use arguments on the root level, like order: DESC, client_order: ASC, but that doesn’t look very clean.
I did this with my schema:
query do
field :users, list_of(:user) do
arg :order, :sorting
resolve &Resolvers.users/3
end
end
object :user do
field :id, :id
field :email, :string
field :clients, list_of(:user)
end
I then tried to create a query for “clients” like this:
query do
field :clients, list_of(:user) do
arg :order, :sorting
resolve &Resolvers.users/3
end
end
but that doesn’t seem to do anything at all.
The error message I get when trying to add the arguments in the query is "message": "Unknown argument "order" on field "clients" of type "User".
First Post!
benwilson512
Hey! Our guides need to go into this more, cause this comes up a fair bit.
You should check out How to write subqueries in absinthe? - #3 by astery which is basically the same question, and if you’ve for further questions afterward feel free to ping me!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









