mattkrick / cashay

:moneybag: Relay for the rest of us :moneybag:
MIT License
453 stars 28 forks source link

Fix pagination bug #113

Closed mattkrick closed 7 years ago

mattkrick commented 8 years ago

as reported by @rogchap

Hey... just trying out cashay and always get this error when trying pagination: Supplying pagination cursors to cashay is not supported
I'm using first and after as my pagination words
my query is simple:
 query($count: Int) {
    users(first: $count) {
      name
      cursor
    }
  }
 const mapStateToProps = () => ({ response: cashay.query(query, { variables: {count: 2}, component: 'HousekeeperList' }) });
I get the first two users, but as soon as I use:
setVariables(currentVariables => {
      return {
        count: currentVariables.count + 2
      }
    })
I get the error

Roger Chapman @rogchap Aug 23 08:16
Not quite sure what the error means as the after arg is added by cashay and then complains that is called after
https://github.com/mattkrick/cashay/blob/master/src/normalize/separateArgs.js#L36

Roger Chapman @rogchap Aug 23 08:21
This loops through the reqASTArgs which is always first and after, so even if i comment out the line that throws here:
if (paginationMeaning === BEFORE || paginationMeaning === AFTER) {
        throw new Error(`Supplying pagination cursors to cashay is not supported. ${variables}`)
      }
it then throws here:
if (hasPagination === true) {
        throw new Error(`Only one pagination argument can be supplied at a time. ${variables}`)
      }
If I comment both out, then it all works as intended!! What are these checks doing?... and what am I doing wrong?
I've tried following the cashay-playground as much as possible.