使用 RDBMS 查询节点(id:ID!)实现的最佳方式是什么

What is the best way of Query node(id: ID!) implementation with RDBMS

GraphQL 和 Relay 规范要求具有节点(id:ID!)字段的查询类型描述和实现如下:

type Query {
  node(id: ID!): Node
}

中继要通过 id 重新获取任何对象。这意味着服务器应该以某种方式了解它应该寻找哪种类型的对象。要扫描数据库中的哪个table。 很明显,id 不能只是 serial id 或 uuid,因为在这种情况下它必须扫描所有 tables。这是不好的做法。

我想解决方案来编码对象 ID 及其类型,以便能够理解 table 要查询的内容。以 base64 编码的“24|User”之类的东西将提供唯一标识符,如“MjR8VXNlcg==”。我很确定这种方法会奏效,但我想知道有没有更好的方法来处理这种情况?有哪些替代方案?

https://relay.dev/docs/en/graphql-server-specification.html#object-identification给出答案

A system without globally unique IDs can usually synthesize them by combining the type with the type-specific ID...

所以我在问题中做了什么。但是他们使用了另一种格式:“TypeName:id”。