Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Usage with the batch loader #12

@DamirSvrtan

Description

@DamirSvrtan

Hi @exAspArk! Thank you for your great work regarding the GraphQL stuff!

I've been trying to add this gem in combination with your other gem https://github.com/exAspArk/batch-loader but don't have much luck. The errors that are supposed to be rescued just get propagated.

It works well with fields that don't have batch loaders, the ones that have just propagate the error and it never gets rescued.

Looking at this code:

    def instrument(_type, field)
      old_resolve_proc = field.resolve_proc
      new_resolve_proc = ->(object, arguments, context) do
        begin
          old_resolve_proc.call(object, arguments, context)
        rescue => exception
          if handler = find_handler(exception)
            handler.call(exception, object, arguments, context)
          else
            raise exception
          end
        end
      end

      field.redefine { resolve(new_resolve_proc) }
    end

In the begin rescue block, without the batch loader, the error gets raised and it gets rescued perfectly fine.

With the batch loader, the old_resolve_proc.call(object, arguments, context) just returns an instance of the batch loader and that is it (the error gets raised elsewhere later on).

Have you encountered this error so far?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions