I have a problem understanding, why there can't be numeric fields with the name id in the nodes in GraphQL schema when using Relay, specificaly React Relay. I didn't find any useful information in the Relay docs, nor the GraphQL docs on this topic.
I'm working on a project where there is GraphQL API that has identifier of type UUID for main objects and numeric IDs for not-so-important objects like this:
query userGet($userUid: UUID!) {
userGet(userUid: $userUid) {
userUid // This is string UUID
name
.....
userRoles {
id // This is numeric
name
}
}
}
When I run the query in client app I get error Expected id of elements of field 'userRoles' to be strings.
Well, that's nice, but what to do when I can't modify the API? I found that a workaround for this is aliasing the field to something other than id, ie _id, which works, but is it really the solution? Won't it cause problems in use cases that I just didn't encounter yet? Why does Relay need it to be of type string in the first place?
Thank you for any help or direction where to look at.
-
You might want to check these docs: relay.dev/docs/debugging/disallowed-id-types-errorlmtaq– lmtaq2025年01月20日 23:52:34 +00:00Commented Jan 20, 2025 at 23:52