Fetching new data for an
OperationRequest in Ferry is easy. Just add a request of the same type and with the same
requestId to the
requestId is provided, Ferry will automatically assign a
uuid when the request is instantiated.
If you're using Flutter, make sure to either instantiate the request outside of the
build() method or explicitly provide a
requestId. Otherwise, a new request will be instantiated on every build with a new ID.
For example, if we are listening to the following request:
We can refetch the query by adding the request to the
Once the response is received, any
request() Streams that were listening to
reviewsReq will get updated with the new data.
Rather than just replacing the previous result with the refetched result, we may want to combine the results to enable pagination.
To do this, we need to create a copy of our original request that will fetch the next set of results and include an
updateResult calback that tells ferry how to combine the results.
For example, let's fetch the next 3 reviews.
The next event received by our
request() Stream will now include all six reviews.