Skip to content

why my fetchNextPage is not work #149

Description

@action-hong

here is my code

// search product by title
export const searchProduct = (query, first = 5) => {
  return graphQLClient.send(gql(graphQLClient)`
    query ($query: String){
      products(query: $query, first: 5) {
        edges {
          cursor
          node {
            id
            title
            images (first: 1) {
              edges {
                node {
                  id
                  src
                }
              }
              pageInfo { hasNextPage, hasPreviousPage }
            }
            description
          }
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
        }
      }
    }
  `, { query })

const query = `title:*${this.keyword}*`
searchProduct(query)
        .then(res => {
          const products = res.model.products
          this.products.push(...products)
          this.hasMore = products[products.length - 1].hasNextPage
          nextPageProduct = products
        })

it is works, but when i use fetchNextPage, it's not work, get error "undefined isn't a defined input type (on $query)"

graphQLClient.fetchNextPage(nextPageProduct)

and here is the fetchNextPage Request

{"query":"query ($query:undefined,$first:Int = 5)  { products (query: $query first: $first after: \"eyJsYXN0X2lkIjo1MzY1OTY3MDk0NDIsImxhc3RfdmFsdWUiOjUzNjU5NjcwOTQ0Mn0=\") { pageInfo { hasNextPage,hasPreviousPage },edges { cursor,node { id,title,images (first: 1) { edges { node { id,src } },pageInfo { hasNextPage,hasPreviousPage } },description } } } }","variables":{"query":"title:*Hydro*"}}

can someone tell me how to fix it ?

// package.json
"dependencies": {
    "babel-plugin-graphql-js-client-transform": "^1.1.1",
    "graphql-js-client": "^0.12.0"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions