Unable to find item [“4039624a-9b02-448d-8158-0db13da76efb”] in batch
why this error can produced? it happened when we use big graph query with connections?
Hi @MeterSoft as I mentioned in the issue you opened, this is happening because you are calling Dataloader.get
with a value that you did not call Dataloader.load
with. As with any error, please show example code that causes it.
@benwilson512 i think problem related when i use connection and dataloder. when i replace connection.from_query with custom pagination the problem gone. I can not provide original code because it is a lot…
but a short example
connection field(:announcements, node_type: :announcement) do
resolve allow_deleted_user_2 &AnnouncementResolver.all/2
end
defmodule AnnouncementResolver do
def all(args, %{context: %{current_user: user}}) do
Connection.from_query(Announcement.all_for_user(user, args), &Repo.all/1, args)
end
end
... on AnnouncementList {
announcements(first: 5) {
__typename
...announcementConnectionFragment
}
}
and it works for
connection field(:announcements, node_type: :announcement) do
resolve dataloader_many_paginated(DB, Announcement, :announcements_list)
end
def dataloader_many_paginated(source, queryable, type, alt_filter \\ nil) do
fn parent, args, %{context: %{loader: loader}} = _resolution ->
second_filter = if alt_filter != nil && args[:with_fallback] != true, do: %{}, else: alt_filter
args = args_with_pagination!(args, second_filter) # for lateral-join connection (paginated)
loader
|> Dataloader.load(source, {:many, queryable, args}, [{type, parent.id}])
|> on_load(fn loader ->
loader
|> Dataloader.get(source, {:many, queryable, args}, [{type, parent.id}])
|> from_paginated_records(args, [])
|> add_parent_id(parent.id)
end)
end
end