I have a question regarding ConnectionHandler used in updater. I am reading the example and found
import {ConnectionHandler} from 'relay-runtime';
// The `friends` connection record can be accessed with:
const user = store.get(userID);
const friends = RelayConnectionHandler.getConnection(
user, // parent record
'FriendsFragment_friends' // connection key
{orderby: 'firstname'} // 'filters' that is used to identify the connection
);
// Access fields on the connection:
const edges = friends.getLinkedRecords('edges');
So the connections could accept {orderby: 'firstname'}. What is my orderby field can take in either firstname or secondname or fullname? So if I am sorting by firstname, I should update the connection with orderby = firstname and when I am sorting by lastname, I should get connection by orderby = lastname ... How do I know which orderby I am under or could I just update the "current one"?
@Junchao, I see that you took this example from the relay docs right? This orderby
that is passed, you are not actually telling Relay to order the edges for you by firstname
, but this parameter is the filters
one, which is used to identify the connection like said on the comment.
If you specified a filter
on your query, you also must pass the filter on getConnection
, otherwise, you won't find it.
:)