Skip to content

Instantly share code, notes, and snippets.

@olivermt olivermt/error.ex
Created Feb 1, 2019

Embed
What would you like to do?
ႋ窝ᬀ退Request: POST /api/v2/graphql
** (exit) an exception was raised:
** (KeyError) key :parent_name not found
(ecto) lib/ecto/repo/queryable.ex:249: anonymous fn/2 in Ecto.Repo.Queryable.process/4
(stdlib) maps.erl:257: :maps.fold_1/3
(ecto) lib/ecto/repo/queryable.ex:249: Ecto.Repo.Queryable.process/4
(ecto) lib/ecto/repo/queryable.ex:219: anonymous fn/3 in Ecto.Repo.Queryable.postprocessor/4
(elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/ecto/repo/queryable.ex:153: Ecto.Repo.Queryable.execute/4
(ecto) lib/ecto/repo/queryable.ex:18: Ecto.Repo.Queryable.all/3
(safari) lib/safari_web/resolvers/common_resolver.ex:92: SafariWeb.Resolvers.CommonResolver.review_comment_list/3
(absinthe) lib/absinthe/resolution.ex:209: Absinthe.Resolution.call/2
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:209: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:168: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/4
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:153: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:72: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:53: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
(absinthe) lib/absinthe/pipeline.ex:274: Absinthe.Pipeline.run_phase/3
(absinthe_plug) lib/absinthe/plug.ex:414: Absinthe.Plug.run_query/4
(absinthe_plug) lib/absinthe/plug.ex:240: Absinthe.Plug.call/2
(phoenix) lib/phoenix/router/route.ex:163: Phoenix.Router.Route.forward/4
(phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
def base_query() do
from(rc in ReviewComment,
order_by: [asc: rc.inserted_at],
select_merge: %{
id: rc.id,
parent_id: rc.parent_id,
parent_type: rc.parent_type,
comment: rc.comment,
author_id: rc.author_id,
inserted_at: rc.inserted_at,
updated_at: rc.updated_at
}
)
end
def list(%{is_admin: true}, _) do
base_query()
|> join(:left, [rc], s in Study, on: rc.parent_id == s.id)
|> join(:left, [rc], o in Outcrop, on: rc.parent_id == o.id)
|> join(:left, [rc], dw in Depositional, on: rc.parent_id == dw.id)
|> join(:left, [rc], lg in LithostratGroup, on: rc.parent_id == lg.id)
|> join(:left, [rc], lf in LithostratFormation, on: rc.parent_id == lf.id)
|> join(:left, [rc], lm in LithostratMember, on: rc.parent_id == lm.id)
|> join(:left, [rc], ow in Other, on: rc.parent_id == ow.id)
|> select_merge([_rc, s, o, dw, lg, lf, lm, ow], %{
parent_name:
fragment(
"coalesce(?,?,?,?,?,?,?) as parent_name",
s.name,
o.name,
dw.title,
lg.name,
lf.name,
lm.name,
ow.title
)
})
|> Repo.all()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.