Closed damassi closed 7 years ago
Going to go ahead and close this -- After some internal discussion it's best to stay within the component model for accessing Relay-resolved data.
Looks like Relay automatically aliases field queries having arguments to avoid potential name conflicts for multiple queries of the same field but with different arguments: http://graphql.org/learn/queries/#aliases You can try to specify an alias yourself.
Also see a proper way to query data outside a Relay container: https://github.com/facebook/relay/issues/114#issuecomment-197003816 (the bottom part of the comment).
@denvned - Thank you so much for pointing me to that issue! Of course the api method is undocumented in Relay docs but such is life 🤕
Forgive me if this should be posted in the Relay repo, but since this has to do with data before its sent over to the client I figured I would post here first.
So I'm trying to get response information from a Relay request before its sent over to the client, but occasionally, when inspecting the response object, it looks like there's some kind of reconciliation going on where Relay prefixes my object keys with an
_
and a random string, e.g.,_user3fdg
.For example, given this dummy query:
Returns this response:
Notice the strange
_saleti0VC
key thats being passed back (I'm expecting justsale
), while thesales
key seems correct? This makes it impossible to deterministically grab data from a response to perform side-effects server-side before the data on the server is sent to the client.What I would expect is that once
IsomorphicRelay.prepareData
returns itsdata
response that it is the final representation that is rehydrated on the client, but unfortunately that's not so. It seems like the final tree is only resolved after it gets all the way to the client and injected as props into aRelay.Container
component.Thoughts?