Jan Ulbrich
Jan Ulbrich
AEAsh Elixir
Created by Jan Ulbrich on 8/27/2023 in #support
Ash.Resource.ManualRead And Filters
So that’s a manual prepare instead of a manual read. Will try!
3 replies
AEAsh Elixir
Created by Jan Ulbrich on 8/12/2023 in #support
JSON-API And Calculations
@Zach Daniel, @skander: Hey guys, sorry that I didn’t get back earlier — too much work in my main job… 😇 I now tested with the HEAD and it works nicely this way: I don’t get the calculation by default and I get the calculation with the fields[resource] parameter. Thank you so much! 🎉
18 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/28/2023 in #support
JSON-API Related() Seems Broken
Sure, will do! Thanks!
4 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/28/2023 in #support
JSON-API Related() Seems Broken
Here are the packages I’m using (I tried it with the newest release of ash_json_api as well as the head):
defp deps do
[
{:absinthe_plug, "~> 1.5.8"},
{:ash, "~> 2.10.2"},
{:ash_authentication, "~> 3.11.6"},
{:ash_graphql, "~> 0.25.10"},
# {:ash_json_api, "~> 0.32.0"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.30"},
{:cors_plug, "~> 3.0.3"},
{:elixir_sense, ">= 1.0.0", only: [:dev, :test]},
{:ecto_sql, "~> 3.10.1"},
{:ecto_sqlite3, ">= 0.10.3"},
{:ex_phone_number, "== 0.3.0"},
{:guardian, "~> 2.3.1"},
{:haversine, "~> 0.1.0"},
{:jason, "~> 1.2"},
{:jose, "~> 1.11"},
{:open_api_spex, "~> 3.17.3"},
{:picosat_elixir, "~> 0.2.3"},
{:phoenix, "~> 1.6.16"},
{:phoenix_ecto, "~> 4.4.2"},
{:phoenix_html, "~> 3.3.1"},
{:plug_cowboy, "~> 2.6.1"},
{:postgrex, "~> 0.16.5"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:tesla, "~> 1.6.0"}
]
end
defp deps do
[
{:absinthe_plug, "~> 1.5.8"},
{:ash, "~> 2.10.2"},
{:ash_authentication, "~> 3.11.6"},
{:ash_graphql, "~> 0.25.10"},
# {:ash_json_api, "~> 0.32.0"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.30"},
{:cors_plug, "~> 3.0.3"},
{:elixir_sense, ">= 1.0.0", only: [:dev, :test]},
{:ecto_sql, "~> 3.10.1"},
{:ecto_sqlite3, ">= 0.10.3"},
{:ex_phone_number, "== 0.3.0"},
{:guardian, "~> 2.3.1"},
{:haversine, "~> 0.1.0"},
{:jason, "~> 1.2"},
{:jose, "~> 1.11"},
{:open_api_spex, "~> 3.17.3"},
{:picosat_elixir, "~> 0.2.3"},
{:phoenix, "~> 1.6.16"},
{:phoenix_ecto, "~> 4.4.2"},
{:phoenix_html, "~> 3.3.1"},
{:plug_cowboy, "~> 2.6.1"},
{:postgrex, "~> 0.16.5"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:tesla, "~> 1.6.0"}
]
end
4 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Yes, that works: I can confirm that I now get the same context and my filters show the right data. Pew… 😌 As always: Thanks again for your fast help! 🚀
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Wow, you’re wild! 😀
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Which is at least conservative and wouldn’t compromise date.
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Yes, it’s 0.25.5 and installed as that version and not directly from master.
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
I thought, that I may have added some query as a precondition, but that’s not the case: If I remove the relation in the query, there’s no query to the events table at all.
[debug] Processing with Absinthe.Plug
Parameters: %{"query" => "{\n alarm(filter: { id: {eq: 4711}}) {\n originatedAt\n extid\n longitude\n latitude\n day\n month\n year\n payload\n kind\n subkind\n }\n}", "variables" => nil}
Pipelines: [:graphql]
[debug] ABSINTHE schema=TickerWeb.Schema variables=%{}
---
{
alarm(filter: { id: {eq: 4711}}) {
originatedAt
extid
longitude
latitude
day
month
year
payload
kind
subkind
}
}
---
[debug] QUERY OK source="alarms" db=9.0ms idle=117.1ms
SELECT a0."id", a0."created_at", a0."updated_at", a0."year", a0."month", a0."day", a0."originated_at", a0."message", a0."extid", a0."operations_center", a0."kind", a0."subkind", a0."longitude", a0."latitude", a0."payload" FROM "alarms" AS a0 WHERE (a0."id" = $1) [4811]
[debug] Processing with Absinthe.Plug
Parameters: %{"query" => "{\n alarm(filter: { id: {eq: 4711}}) {\n originatedAt\n extid\n longitude\n latitude\n day\n month\n year\n payload\n kind\n subkind\n }\n}", "variables" => nil}
Pipelines: [:graphql]
[debug] ABSINTHE schema=TickerWeb.Schema variables=%{}
---
{
alarm(filter: { id: {eq: 4711}}) {
originatedAt
extid
longitude
latitude
day
month
year
payload
kind
subkind
}
}
---
[debug] QUERY OK source="alarms" db=9.0ms idle=117.1ms
SELECT a0."id", a0."created_at", a0."updated_at", a0."year", a0."month", a0."day", a0."originated_at", a0."message", a0."extid", a0."operations_center", a0."kind", a0."subkind", a0."longitude", a0."latitude", a0."payload" FROM "alarms" AS a0 WHERE (a0."id" = $1) [4811]
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
It’s weird: The inner query is kind of executed first
[info] POST /graphql
[debug] Processing with Absinthe.Plug
Parameters: %{"query" => "{\n alarm(filter: { id: {eq: 4711}}) {\n originatedAt\n extid\n longitude\n latitude\n day\n month\n year\n payload\n kind\n subkind\n events(sort: {field: ORIGINATED_AT}) {\n originatedAt\n payload\n }\n }\n}", "variables" => nil}
Pipelines: [:graphql]
[debug] ABSINTHE schema=TickerWeb.Schema variables=%{}
---
{
alarm(filter: { id: {eq: 4711}}) {
originatedAt
extid
longitude
latitude
day
month
year
payload
kind
subkind
events(sort: {field: ORIGINATED_AT}) {
originatedAt
payload
}
}
}
---
[debug] QUERY OK source="alarms" db=9.9ms queue=0.1ms idle=1777.5ms
SELECT a0."id", a0."created_at", a0."updated_at", a0."year", a0."month", a0."day", a0."originated_at", a0."message", a0."extid", a0."operations_center", a0."kind", a0."subkind", a0."longitude", a0."latitude", a0."payload" FROM "alarms" AS a0 WHERE (a0."id" = $1) [4711]
Inner context: %{tracer: nil, actor: nil, authorize?: nil}
Outer context: %{
tracer: nil,
actor: %{
id: "bwb-102290",
[...]
},
authorize?: true
}
[debug] QUERY OK source="alarms" db=3.7ms idle=1788.8ms
SELECT a0."created_at", a0."updated_at", a0."message", a0."operations_center", a0."id" FROM "alarms" AS a0 WHERE (a0."id"::bigint = $1::bigint) [4711]
[debug] QUERY OK source="events" db=201.7ms idle=1793.6ms
SELECT e0."id", e0."originated_at", e0."extid", e0."payload" FROM "events" AS e0 WHERE (e0."id"::bigint = $1::bigint) ORDER BY e0."originated_at" [4711]
[info] POST /graphql
[debug] Processing with Absinthe.Plug
Parameters: %{"query" => "{\n alarm(filter: { id: {eq: 4711}}) {\n originatedAt\n extid\n longitude\n latitude\n day\n month\n year\n payload\n kind\n subkind\n events(sort: {field: ORIGINATED_AT}) {\n originatedAt\n payload\n }\n }\n}", "variables" => nil}
Pipelines: [:graphql]
[debug] ABSINTHE schema=TickerWeb.Schema variables=%{}
---
{
alarm(filter: { id: {eq: 4711}}) {
originatedAt
extid
longitude
latitude
day
month
year
payload
kind
subkind
events(sort: {field: ORIGINATED_AT}) {
originatedAt
payload
}
}
}
---
[debug] QUERY OK source="alarms" db=9.9ms queue=0.1ms idle=1777.5ms
SELECT a0."id", a0."created_at", a0."updated_at", a0."year", a0."month", a0."day", a0."originated_at", a0."message", a0."extid", a0."operations_center", a0."kind", a0."subkind", a0."longitude", a0."latitude", a0."payload" FROM "alarms" AS a0 WHERE (a0."id" = $1) [4711]
Inner context: %{tracer: nil, actor: nil, authorize?: nil}
Outer context: %{
tracer: nil,
actor: %{
id: "bwb-102290",
[...]
},
authorize?: true
}
[debug] QUERY OK source="alarms" db=3.7ms idle=1788.8ms
SELECT a0."created_at", a0."updated_at", a0."message", a0."operations_center", a0."id" FROM "alarms" AS a0 WHERE (a0."id"::bigint = $1::bigint) [4711]
[debug] QUERY OK source="events" db=201.7ms idle=1793.6ms
SELECT e0."id", e0."originated_at", e0."extid", e0."payload" FROM "events" AS e0 WHERE (e0."id"::bigint = $1::bigint) ORDER BY e0."originated_at" [4711]
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Yes, I’ll add the same debug statement. Gimme a minute.
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
Sorry, I missed your question earlier! Here you go:
actions do
read :read do
primary?(true)

prepare(fn query, context ->
IO.inspect(context, label: "Context") # <- actor nil
Ash.Query.after_action(query, fn _query, events ->
{:ok, patch_results_applying_actor_filters(events, context)}
end)
end)
end
actions do
read :read do
primary?(true)

prepare(fn query, context ->
IO.inspect(context, label: "Context") # <- actor nil
Ash.Query.after_action(query, fn _query, events ->
{:ok, patch_results_applying_actor_filters(events, context)}
end)
end)
end
In that function:
def patch_results_applying_actor_filters(events, context) do
with actor when actor != nil <- Map.get(context, :actor) do
...
end
end
def patch_results_applying_actor_filters(events, context) do
with actor when actor != nil <- Map.get(context, :actor) do
...
end
end
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 6/3/2023 in #support
GraphQL Relationship Resolved w/o Context
These are the Ash-related dependencies I’m using:
{:ash, "~> 2.9.19"},
{:ash_authentication, "~> 3.11.3"},
{:ash_graphql, "~> 0.25.5"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.28"},
{:ash, "~> 2.9.19"},
{:ash_authentication, "~> 3.11.3"},
{:ash_graphql, "~> 0.25.5"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.28"},
29 replies
AEAsh Elixir
Created by Jan Ulbrich on 5/17/2023 in #support
Compile Error with JsonApi using related()
Hi Daniel, that works nicely now! 🎉 Thank you so much! 👏
5 replies
AEAsh Elixir
Created by Jan Ulbrich on 5/17/2023 in #support
Compile Error with JsonApi using related()
Thank you! 🙂
5 replies
AEAsh Elixir
Created by Jan Ulbrich on 2/17/2023 in #support
Found read action while expecting an action of type relationship...
Perfect! As always: Big kudos to you. Ash is amazing! 👏
23 replies
AEAsh Elixir
Created by Jan Ulbrich on 2/17/2023 in #support
Found read action while expecting an action of type relationship...
Yes, exactly. And I can confirm that it continues, now! 🎉
23 replies
AEAsh Elixir
Created by Jan Ulbrich on 2/17/2023 in #support
Found read action while expecting an action of type relationship...
"Problem" is my middle name! 😄
23 replies
AEAsh Elixir
Created by Jan Ulbrich on 2/17/2023 in #support
Found read action while expecting an action of type relationship...
Huh, so fast?!
23 replies
AEAsh Elixir
Created by Jan Ulbrich on 2/17/2023 in #support
Found read action while expecting an action of type relationship...
Yes, here you go:
** (ArgumentError) Found an action of type read while looking for an action of type relationship

Perhaps you passed a changeset with the incorrect action type into your Api?

(ash 2.6.8) lib/ash/resource/info.ex:534: Ash.Resource.Info.action/3
lib/ticker_web/eventhub/router.ex:2: anonymous fn/5 in :elixir_compiler_0.__MODULE__/1
(elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
lib/ticker_web/eventhub/router.ex:2: anonymous fn/3 in :elixir_compiler_0.__MODULE__/1
(elixir 1.13.1) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
lib/ticker_web/eventhub/router.ex:2: (module)
(elixir 1.13.1) lib/kernel/parallel_compiler.ex:346: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/7
** (ArgumentError) Found an action of type read while looking for an action of type relationship

Perhaps you passed a changeset with the incorrect action type into your Api?

(ash 2.6.8) lib/ash/resource/info.ex:534: Ash.Resource.Info.action/3
lib/ticker_web/eventhub/router.ex:2: anonymous fn/5 in :elixir_compiler_0.__MODULE__/1
(elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
lib/ticker_web/eventhub/router.ex:2: anonymous fn/3 in :elixir_compiler_0.__MODULE__/1
(elixir 1.13.1) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
lib/ticker_web/eventhub/router.ex:2: (module)
(elixir 1.13.1) lib/kernel/parallel_compiler.ex:346: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/7
23 replies