Skip to content

Breaking issue with pagination cursors #226

Description

@tomusiaka

In 2.4 I was able to pass a pagination cursor to client, which would get serialized to JSON format using result[:after] and then I had to use a bit more manual process to convert the same JSON object back to a pagination cursor:

    json_array.map {|element|
      if element.respond_to?('key?') && element.key?('@ref')
        Fauna::Query.method(:ref).call(element['@ref'])
      else
        element
      end
    }

Now, in 3.0 it seems like that conversion process no longer works and it results with invalid expression - Ref expected, Object provided error.

As a workaround, I managed to get it to work with:

    json_array.map {|element|
      if element.respond_to?('key?') && element.key?('@ref')
         Fauna::Query::ref(Fauna::Query::class_(element['@ref']['class']['@ref']['id']), element['@ref']['id'])  
      else
        element
      end
    }

But that requires updating the old code that worked just fine, so it looks like a regression.

Also, is there an easier/more recommended way to convert a pagination cursor to/from JSON?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions