move move frontend to progress-test
This commit is contained in:
18
app/javascript/utils/graphql/NodeId.ts
Normal file
18
app/javascript/utils/graphql/NodeId.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Node } from "../../__generated__/graphql-schema";
|
||||
|
||||
const SEPARATOR_TOKEN = "-";
|
||||
|
||||
type Decoded = { typeName: string; id: string };
|
||||
|
||||
const decode = (id: Node["id"]): Decoded => {
|
||||
const raw = Buffer.from(id, "base64").toString("ascii");
|
||||
|
||||
const [nodeTypeName, nodeId] = raw.split(SEPARATOR_TOKEN);
|
||||
|
||||
return {
|
||||
id: nodeId,
|
||||
typeName: nodeTypeName,
|
||||
};
|
||||
};
|
||||
|
||||
export const NodeId = { decode };
|
||||
Reference in New Issue
Block a user