i implemented the node interface for the user object with absinthe relay recently.
ran into an issue when wrapping my user object with the node
macro. As per the Absinthe.Relay.Node documentation,
An
:id
field is created for you automatically, and this field generates a global ID; an opaque string that’s built using a global ID translator (by default a Base64 implementation). All of this is handled for you automatically by prefixing your object type definition with"node "
.
While this is super convenient and great, it causes conflicts with my existing user.id
field, which maps to the id
column in my MySQL database.
As a workaround, I’ve changed my user schema to the following:
node object(:user) do
field :uuid, non_null(:id), resolve: fn user, _, _ -> {:ok, user.id} end
But i would much rather prefer if I could map the name of the field used for identifying nodes to be named something else like node_id
, and not have to rename my existing id field.
Took a look through the Absinthe.Relay.Node docs but I couldn’t find anything that supported this. Was wondering if this is possible? Appreciate any help!