BryanJBryce
AshGraphql error when resolving Aggregate
OrderItem defines the following:
calculations do
calculate :subtotal,
:decimal,
expr(
type(price, :decimal) * type(quantity, :decimal) + type(modifiers_total, :decimal)
),
public?: true
end
aggregates do
sum :modifiers_total, :modifiers, :total, public?: true, default: 0
end
Ash.read!(OrderItem, load: [:modifiers_total, :subtotal]) works as expected
query OrderItem($orderItemId: ID!) {
orderItem(id: $orderItemId) {
id
# subtotal
# modifiersTotal
modifiers {
id
total
}
}
}
This GraphQL query works when modifiersTotal/subtotal are not included, but gives the following error on the server when they are:
[error] edd194bb-a06b-42ab-acbd-92e08c25876d: Exception raised while resolving query.
** (KeyError) key :arguments not found in: %{tracer: nil, tenant: nil, authorize?: false, actor: nil}
(ash 3.0.0-rc.45) lib/ash/resource/calculation/expression.ex:10: Ash.Resource.Calculation.Expression.expression/2 (ash_sql 0.1.1-rc.17) lib/aggregate.ex:718: anonymous fn/5 in AshSql.Aggregate.maybe_filter_subquery/6 (elixir 1.16.1) lib/enum.ex:4842: Enumerable.List.reduce/3 (elixir 1.16.1) lib/enum.ex:2582: Enum.reduce_while/3 (ash_sql 0.1.1-rc.17) lib/aggregate.ex:312: anonymous fn/10 in AshSql.Aggregate.add_aggregates/6 (ash_sql 0.1.1-rc.17) lib/join.ex:250: AshSql.Join.related_subquery/3 (ash_sql 0.1.1-rc.17) lib/aggregate.ex:159: anonymous fn/7 in AshSql.Aggregate.add_aggregates/6 (elixir 1.16.1) lib/enum.ex:4842: Enumerable.List.reduce/3 (elixir 1.16.1) lib/enum.ex:2582: Enum.reduce_while/3 (ash_sql 0.1.1-rc.17) lib/aggregate.ex:88: AshSql.Aggregate.add_aggregates/6 (ash 3.0.0-rc.45) lib/ash/query/query.ex:2858: Ash.Query.data_layer_query/2 (ash 3.0.0-rc.45) lib/ash/actions/read/read.ex:436: anonymous fn/5 in Ash.Actions.Read.do_read/4 (ash 3.0.0-rc.45) lib/ash/process_helpers.ex:38: anonymous fn/4 in Ash.ProcessHelpers.async/2 (elixir 1.16.1) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2 (elixir 1.16.1) lib/task/supervised.ex:36: Task.Supervised.reply/4 (ash 3.0.0-rc.45) lib/ash/process_helpers.ex:32: Ash.ProcessHelpers.async/2 (ash 3.0.0-rc.45) lib/ash/process_helpers.ex:66: Ash.ProcessHelpers.task_with_timeout/5 (ash 3.0.0-rc.45) lib/ash/actions/read/read.ex:571: Ash.Actions.Read.maybe_in_transaction/3 (ash 3.0.0-rc.45) lib/ash/actions/read/read.ex:251: Ash.Actions.Read.do_run/3 (ash 3.0.0-rc.45) lib/ash/actions/read/read.ex:66: anonymous fn/3 in Ash.Actions.Read.run/3
Full code here: GitHub - BryceLabs/ash_issues_examples at arguments-not-found-query · GitHub
Marked As Solved
zachdaniel
Creator of Ash
Can you include specific steps to reproduce, or ideally a test in the reproduction repo? This looks like a bug on our end, will look into it when I have a chance, but may be a day or two.
1
Also Liked
BryanJBryce
Last Post!
BryanJBryce
Popular in Questions
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Other popular topics
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
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,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Latest Ash Threads
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









