-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Modern] RelayResponseNormalizer: Expected id of elements of field nodes
to be strings.
#1682
Comments
Yeah we need to document this. Currently |
Maybe change the call sites to say |
Some context, as I understand it - Most GraphQL data at Facebook implements the Node interface. This means that whatever the data object is - person, page, location, hobby, or wub - it can be fetched from a single endpoint like |
Temporary workaround: alias |
You need an interface Node that takes an ID, something like interface Node { and then use the interface in your type Wub schema like this, type Wub implements Node { |
Just ran into the same problem. I provided a global unique id as nodeId while maintaining the objectPK as id. |
I had the same problem. My guess is that the graphql schema that I was connecting to was using |
I'm sorry this issue has sat here for so long. In an attempt to clean up our issue queue we're closing some aging or unclear-action issues. Sounds like there was some answers to this question. Relay contains this restriction on |
I'm gonna leave this in here in case anyone else is having trouble with this when using Relay Modern and can't control their QraphQL endpoint for some reason: My hacky solution to this problem was to rewrite the JSON response from the server before it gets passed through to the Relay layer. I did this by writing a (not pure I know) function to find all
This was used in the
|
As first sight, the workaround from @markymc look promising My solution: Use alias for id field
and use whateverId instead of id |
In Relay, `id` is [treated as a reserved word and must be a globally unique value](facebook/relay#1682 (comment)). That means when an `id` field is present on a type, it must be the type that Relay expects (a string type). This linter assumes that an `ID` scalar is present in the schema, and checks that if an `id` field is present, it is using that type.
In Relay, `id` is [treated as a reserved word and must be a globally unique value](facebook/relay#1682 (comment)). That means when an `id` field is present on a type, it must be the type that Relay expects (a string type). This linter assumes that an `ID` scalar is present in the schema, and checks that if an `id` field is present, it is using that type.
## [2.2.0](v2.1.0...v2.2.0) (2023-03-07) ### Features * **rule:** Add rule to check that `id` is only used for Relay IDs ([2f56901](2f56901)), closes [/github.com/facebook/relay/issues/1682#issuecomment-296393416](https://github.com/pinterest//github.com/facebook/relay/issues/1682/issues/issuecomment-296393416)
Getting the following error:
RelayResponseNormalizer: Expected id of elements of field 'nodes' to be strings.
Query:
Schema:
API Response:
The text was updated successfully, but these errors were encountered: