-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Change the default behavior of the encoder to use urlsafe
versions
#1698
Conversation
🤔 Hmm, this issue has come up a few times, but I was always opposed because of compatibility issues. But, it sounds like this decoder would be backwards-compatible, is that right? I mean, let's say someone updates their gem version. Would any of their API clients have trouble with outstanding cursors? |
I think there's no trouble on updating a new gem that includes this PR. This is because there are only |
Thanks for your response, I want to include this change in GraphQL-Ruby soon, maybe 1.9, let me think about it a bit more! (Actually I'm trying to migrate GitHub to urlsafe_encode64 right now!) |
I noticed an interesting issue when I deployed a similar change in github.com. We got some encoding issues, but here's what happened:
Of course, those requests succeded on retry, because by that time, the server had properly restarted. So, there's still a small compatibility issue here, but probably not worth worrying about. Just thought I'd share! |
That is an interesting report! Thanks for sharing it. It means that before this PR, graphql-ruby must be able to decode url-safe base64 cursors for forward compatibilities. |
I pushed a merge commit and changed the base to 1.9-dev, assuming the tests pass, I'll get this improvement to into 1.9.0 😄 |
Change the default behavior of the encoder to use `urlsafe` versions
I believe this is the better default because it is safely used as a pagination parameter of web apps (maybe like single-page applications).
Anyway, I define a custom encoder to use
urlsafe
versions in my project, but it's my pleasure if it is useful for your projects. What do you think of it?In addition, I think
lib/graphql/schema/unique_within_type.rb
should use G::S::Base64Encoder, although the PR does not include this idea. How about it?compatibility
.encode
- The string changes.decode
- it can decodes what is encoded byBase64.strict_encode64