Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Use UUID version 5 for node IDs in source/transformer plugins #1853
This was pointed out on Discord https://www.npmjs.com/package/uuid#version-5
Node IDs should be a) globally unique and b) meaningless so people don't rely on them for anything. Standardizing on UUID version 5 seems like a good way to accomplish this.
Hi, I am not sure if I am doing this wrong, but I found it quite useful to be able to specify my own id for a source plugin that used relational database tables. I could make the id based on the table name, row id and a name for my plugin (perhaps with an instance number if it was reusable). Then I don't need to create any hash maps to keep track of the ___NODE relations in the plugin and they can be generated based on the data.
It is also easier to debug the id with an error message something like:
@KyleAMathews The error already exists :) I was just showing how useful it became when I was able to specify a custom Gatsby id based on what should be unique information, rather than a new generated UUID id that would be harder to identify.
One option might be to build into the API a postfix for the Gatsby Id based on the plugin name and instance and maybe node type? When I first started trying to build a Gatsby plugin, I assumed I was meant to be passing in my own id and it would make it unique based on my plugin instance and the node
I think I found it confusing because what turned out to be the Gatsby id was called