0

I still have some troubles understanding the concept of fat queries in Relay, especially about the part of the intersection logic to determine which data to re-fetch.

Up to now, I have build a simple hierarchical data structure with a UserType as root query (named viewer) which has a number of projects (of type ProjectConnectionType) associated with it. Each of this projects has another projects field (also of type ProjectConnectionType) to model an arbitrarily nested sub-project hierarchy.

I also have two higher order React components ProjectList and ProjectListItem to render this structure by conditionally expanding fragments (by using a Relay variable expanded within my list item component).

So far, this works fine and I am quite happy with it. The tricky part is now the AddProject mutation. I have created a mutation which takes a name and the parentProjectId as input (might be null for root projects) and creates a new node on the server side at the right location. After that, it should return the new projectEdges (which are appended using RANGE_ADD afterwards), as well as the parentProject or viewer so that I also can update the subprojectCount there.

In case of the viewer (unique global root query point) everything works fine as well. Relay correctly calculates the intersection and asks for the new data from the server. But when I try to add a sub-project, I keep getting a completely empty response without any output fields (besides the mutation id). My guess is that Relay seems to get the intersection wrong by not knowing how to map the parentProject field accordingly. I have already tried to add a FIELDS_CHANGE config for it as well as querying parentProject: node(id: "$parentProjectId") within my fat query (which wasn't working either).

What I am missing? I have read the documentation a couple of times now, but I still do not understand the concept of mutations and I feel already quite dumb.

tux21b
  • 75,045
  • 15
  • 108
  • 99
  • Can you inline the `getFatQuery` and `getConfigs` you're using now? – steveluscher Sep 28 '15 at 22:24
  • Ping! I'd love to help, if you're at liberty to post some code. – steveluscher Dec 05 '15 at 00:09
  • Hi, sorry I'm also interested in understanding this topic. I'v made another [question](http://stackoverflow.com/questions/34585808/relayjs-fatquery-not-generating-expected-query) to show my specific case. – Reyn Jan 06 '16 at 13:26

0 Answers0