relayPagination and network-only
See original GitHub issueHi All
I have the following query
query FriendsQuery($after: String!) {
me {
id
friends(after: $after) {
edges {
node {
...FriendshipFragment
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
And the following hook
export const useFriends = () => {
const client = useClient();
const [{ fetching, error, data }] = useQuery<
FriendsQueryQuery,
FriendsQueryQueryVariables
>({
query: FRIENDS_QUERY,
requestPolicy: "network-only",
variables: {
after: "",
},
});
const friends =
data === undefined ? undefined : data?.me?.friends ?? undefined;
const fetchMore = React.useCallback(
(cursor: string) => {
return client
.query<FriendsQueryQuery, FriendsQueryQueryVariables>(
FRIENDS_QUERY,
{ after: cursor },
{ requestPolicy: "network-only" }
)
.toPromise();
},
[client]
);
return React.useMemo(
() => ({
fetching,
error,
friends,
fetchMore,
}),
[fetching, error, friends, fetchMore]
);
Results are merged using relayPagination
resolvers: {
User: {
friends: relayPagination()
}
}
I have a component that does an infinite scrolling and shows all my friends.
When the component is unmounted and afterwards remounted i would like to fetch again the lists of friends (hence the network-only)
The problem is that due to the relay pagination the friends variable contains all the friends fetched from the previous mount with pageInfo.hasNextPage === false.
The only request that is requested again is the initial with after === “”
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (7 by maintainers)
Top Results From Across the Web
Pagination Container
hasMore is a function available on the relay prop. This function indicates whether there are more pages to fetch from the server or...
Read more >Understanding pagination: REST, GraphQL, and Relay
A connection is a paginated field on an object — for example, the friends field on a user or the comments field on...
Read more >relayPagination and network-only · Issue #672 · urql- ...
The problem is that due to the relay pagination the friends variable contains all the friends fetched from the previous mount with pageInfo....
Read more >Pagination with minimal effort in Relay
This article will focus on simple pagination, without filters, and only paginating forward. But, Relay can paginate backwards just as easily ...
Read more >Effortless Pagination with GraphQL and Relay? Really!
You start to realize that the cursor-based setup of a connection, along with a Relay pagination container, does not lend itself to this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As for the very specific, I dont think i am the only person who want to use relayPagination with cache-and-network || network-only
Nope i did the merging manually without using relayPagination
On Wed, Jan 20, 2021 at 12:14 PM Vinícius Lemes notifications@github.com wrote: