I have a pseudo structure that looks/works a bit like this:
Organization <- OrganizationType
{
TopLevelEmployees <- EmployeeType
{
id,
Name,
Pay,
Subordinates <- EmployeeType
{
id,
Name,
Pay,
Subordinates.if(variables.expanded)
}
},
Departments <- DepartmentType
{
Name,
Organization, <- OrganizationType
Employees
}
}
I have a control that displays the Employee tree structure
<EmployeeTreeEditor Organization={organization} />
I then have a control that edits departments individually
<DepartmentEditor Department={department} />
The DepartmentEditor's Relay query looks like this:
fragments: {
Department: () => Relay.QL`
fragment on Department
{
Employees
{
id,
Name,
Pay
},
Organization
{
id,
}
}
`}
In the DepartmentEditor there is a button that raises the pay for all employees in that department by 10% with the RaiseDepartmentPayMutation.
The fatQuery for the RaiseDepartmentPayMutation looks like this:
fragments: {
Department: () => Relay.QL`
fragment on Department
{
Organization
}
`}
The RaiseDepartmentPayMutation returns an OrganizationPayload.
When the Raise Pay button is pressed in DepartmentEditor I'd like to completely reload the Organization's TopLevelEmployees because their Pay could have changed.
The problem is that the query thats generated is based on the Department::Organization query and only fetches the Organization id.
I guess that if I'd passed Organization to DepartmentEditor instead of Department then it might fetch the TopLevelEmployees, but I can't keep passing my Organization along to child controls.
The other solution I see might be to have a seperate fragment that I include in both the EmployeeTreeEditor and Mutation fatQuery
${Something.getFragment('Organization')}
But I'm not sure how fatQueries work with tree structures, which is also why I'd just like to reload the entire Organization.
Is this making any sense ?
Thanks!