Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchMoreResult shouldn't have data property #1384

Closed
helfer opened this issue Mar 8, 2017 · 2 comments
Closed

fetchMoreResult shouldn't have data property #1384

helfer opened this issue Mar 8, 2017 · 2 comments
Labels
📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted

Comments

@helfer
Copy link
Contributor

helfer commented Mar 8, 2017

In the updateQueries function of fetchMore, fetchMoreResults has a data property, but previousResult doesn't. We should hoist the properties in fetchMoreResults.

@helfer helfer added 📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted labels Mar 8, 2017
@nandito
Copy link
Contributor

nandito commented Mar 9, 2017

I'm not sure if I understand it properly, but it seems to me that the updateQuery's previousResult is basically the same as fetchMoreResult.data. The additional elements in the fetchMoreResult object are the loading and the networkStatus.

Here is an example from an implemented pagination:

const paginationOption = {
  options: { /* ... */ },
  props({ data }) {
    return {
      data,
      changePage(page) {
        return data.fetchMore({
          variables: { /* ... */ },
          updateQuery: (previousResult, { fetchMoreResult }) => {
            console.log('previousResult: ', previousResult)
            console.log('fetchMoreResult: ', fetchMoreResult)
            if (fetchMoreResult.data) {
              /* ... */
              return fetchMoreResult.data
            }
            else {
              return previousResult
            }
          }
        })
      }
    }
  }
}

This shows the following log:

previousResult:

{
  user_list: {
    __typeName: "UserList",
    users: Array[100],
    metadata: Object
  }
}

fetchMoreResult:

{
  data: {
    user_list: {
      __typeName: "UserList",
      users: Array[100],
      metadata: Object
    }
  },
  loading: false,
  networkStatus: 7
}

So the goal here is to wrap the previousResult object's current content with data?

@helfer
Copy link
Contributor Author

helfer commented Mar 15, 2017

So the goal here is to wrap the previousResult object's current content with data?

@nandito Yes, I think that would be best.

If you (or someone else) want to make a quick PR, it would be very much appreciated! :)

@helfer helfer closed this as completed in e4527a3 Mar 17, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted
Projects
None yet
Development

No branches or pull requests

2 participants