1

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.

asked Sep 3, 2024 at 15:03
1

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.