Relay: ID becomes way too long when using MongoDB and Relay together

Created on 4 Oct 2016  路  2Comments  路  Source: facebook/relay

I also posted the same question on stackoverflow.

Here's one example of how long one global ID can be:
UHJvZmlsZUluZm9Tb2NpYWxMaW5rOjU3ZThmMjczODUwYTc5ZDM1ZDA1MDkxMA==

Its length is proportional to type name's length, so for some types with long names it becomes too wasteful...

Note that these IDs will be added to URLs like /user/:userId/posts/:postId.

Any strategies to shorten length of IDs?
How does Facebook tackle this problem?

Is there a way to use some kind of enum mapping for type names when forging global ids?
For example,
const typeEnum = {User: 1, Post: 2, ...};
And use the enum when encoding global ids instead of original type names?

Most helpful comment

It is not really "Relay"'s problem. It is a graphql-relay's issue. Or strictly speaking, it is not an issue at all.
You can override this function if you need something specific this https://github.com/graphql/graphql-relay-js/blob/v0.4.3/src/node/node.js#L87

All 2 comments

It is not really "Relay"'s problem. It is a graphql-relay's issue. Or strictly speaking, it is not an issue at all.
You can override this function if you need something specific this https://github.com/graphql/graphql-relay-js/blob/v0.4.3/src/node/node.js#L87

@chungwong Thank you for the clarification!

Was this page helpful?
0 / 5 - 0 ratings