1
votes

The docs describe rangeBehaviors as:

A map of GraphQL calls to the behavior we want Relay to exhibit when adding the new edge to connections under the influence of those calls. Behaviors can be one of 'append', 'prepend', or 'remove'.

The example in the docs is:

rangeBehaviors: {
  // When the ships connection is not under the influence
  // of any call, append the ship to the end of the connection
  '': 'append',
  // Prepend the ship, wherever the connection is sorted by age
  'orderby(newest)': 'prepend',
}

and in another example in the todos example repo you have:

rangeBehaviors: {
  '': 'append',
  'status(any)': 'append',
  'status(active)': 'append',
  'status(completed)': null,
}

What is a "GraphQL call" in this case? What does it mean to be "under the influence of" such a call?

1

1 Answers

2
votes

When you query for a connection field in Relay, you can potentially specify arguments beyond just the standard pagination arguments of first, last, before, and after.

In the TodoMVC example above, we qualify the query by the current filter on status. The meaning of the TodoMVC code you've shown is that the mutation should append the new todo for queries that filter for statuses of "active" or "any" (or the default status), but not for queries that filter to only the status of "completed" (which makes sense in context, since the mutation adds a new, active todo).