-
Notifications
You must be signed in to change notification settings - Fork 181
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
toGlobalId/fromGlobalId not working inside React Native #152
Comments
Thanks for the report @vincentisambart.
This is a reasonable approach. Note that the use of base64 encoding is a convention but not a requirement. The main reason we have used base64 historically is to make it clear that the identifiers should be considered opaque, and the client should avoid doing any operations that depend on their internal structure; in many (most?) cases you can write a client without needing the functionality of |
I ran into exactly the same issue. Any ways to make this cross-platform? |
@vincentisambart how did you solved your problem? |
You can create a simple helper import { Buffer } from 'buffer';
export type Base64String = string;
export function base64(i: string): Base64String {
return new Buffer(i, 'utf8').toString('base64');
}
export const toGlobalId = (type: string, id: string): string => {
return base64([type, id].join(':'));
}; |
Previously we used Node's API for converting to/from base64 but it limits portability of this library to defirent enviroments include Deno Fixes graphql#152
Previously we used Node's API for converting to/from base64 but it limits portability of this library to defirent enviroments include Deno Fixes #152
I tried using this library's
toGlobalId
andfromGlobalId
from a React Native application, however I got an error thatBuffer
is not defined (it's used in src/utils/base64.js). It seems thatBuffer
is only available from NodeJS...If you consider that this library should also be available from React Native (or a browser), at least some changes need to be made to base64.js.
In the time being I'll probably just use join/split.
By the way, the reason I was trying to use this library from React Native is to do something similar to http://graphql.org/blog/rest-api-graphql-wrapper/.
The text was updated successfully, but these errors were encountered: