gpbaculio
gpbaculio

Reputation: 5968

I cannot do loadMore because hasMore() returns false always even if hasNextPage is true?

I don't know why my loadMore doesn't work, this is my code in my pagination:

   todos(first: $count # count is default to 2
        ) @connection(key: "TodoList_todos") { #
          edges {
            cursor
            node {
              id,
              complete,
              ...Todo_todo,
            }
          }
           pageInfo {
              endCursor
              hasNextPage
              hasPreviousPage
              startCursor
           }

Why would my hasMore() return false when hasNextPage returns true? how do I fix this?

Upvotes: 0

Views: 621

Answers (1)

yoneapp
yoneapp

Reputation: 29

Are you setting getConnectionFromProps?
Probably need to be like props.todos.

module.exports = createPaginationContainer(
  Todos,
  {
    todos: graphql`
      todos(first: $count # count is default to 2
          ) @connection(key: "TodoList_todos") { #
            edges {
              cursor
              node {
                id,
                complete,
                ...Todo_todo,
          }
            }
             pageInfo {
                endCursor
                hasNextPage
                hasPreviousPage
                startCursor
             }
    `
  },
  {
    direction: 'forward',
    getConnectionFromProps: props => props.todos,
    getFragmentVariables: (vars, totalCount) => ({
      ...vars,
      count: totalCount,
    }),
    getVariables: (props, {count, cursor}) => ({
      count,
      cursor
    }),
    environment: environment,
    query: graphql`
      query TodosPaginationQuery($count: Int!, $cursor: String) {
        ...ShopList_shops
      }
    `
  }
);

Upvotes: 1

Related Questions