Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking issue with pagination cursors #226

Open
tomusiaka opened this issue May 8, 2019 · 0 comments
Open

Breaking issue with pagination cursors #226

tomusiaka opened this issue May 8, 2019 · 0 comments

Comments

@tomusiaka
Copy link

tomusiaka commented May 8, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant