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

Setting amount of products in pagination not working #827

Open
YishaqG opened this issue Dec 19, 2023 · 8 comments
Open

Setting amount of products in pagination not working #827

YishaqG opened this issue Dec 19, 2023 · 8 comments
Milestone

Comments

@YishaqG
Copy link

YishaqG commented Dec 19, 2023

Describe the bug
Using query products setting first misbehaves not always returns the requested amount of elements.

To Reproduce

  1. Query products with first > 10

Expected behavior
Returns the set amount

Plugin Versions
WooGraphQL Version: 0.18.3
WPGraphQL Version: 1.19.0
WordPress Version: 6.4.2
WooCommerce Version: 8.3.1

@YishaqG
Copy link
Author

YishaqG commented Jan 5, 2024

Just tested with v0.19.0 and having the same issue with pagination

Query:

  products(first: 19) {
    nodes {
      databaseId
    }
  }
}

Response:

  "data": {
    "products": {
      "nodes": [
        {
          "databaseId": 34738
        },
        {
          "databaseId": 34732
        },
        {
          "databaseId": 34731
        },
        {
          "databaseId": 34727
        },
        {
          "databaseId": 34711
        },
        {
          "databaseId": 34710
        },
        {
          "databaseId": 34709
        },
        {
          "databaseId": 34708
        },
        {
          "databaseId": 34707
        },
        {
          "databaseId": 34696
        },
        {
          "databaseId": 34695
        },
        {
          "databaseId": 34694
        },
        {
          "databaseId": 34693
        },
        {
          "databaseId": 34692
        },
        {
          "databaseId": 34687
        },
        {
          "databaseId": 34686
        },
        {
          "databaseId": 34684
        }
      ]
    }
  },
  "extensions": {
    "debug": [],
    "queryAnalyzer": {
      "keys": "82302315334ebe38740cc222092d11bc4494c3b877822def18dc0fe76841bcac graphql:Query operation:NewQuery list:variableproduct list:externalproduct list:groupproduct list:simpleproduct list:simpleproductvariation",
      "keysLength": 204,
      "keysCount": 8,
      "skippedKeys": "",
      "skippedKeysSize": 0,
      "skippedKeysCount": 0,
      "skippedTypes": []
    }
  }
}

@claudio-uey
Copy link

Same issue here

@kidunot89 kidunot89 added this to the v0.19.1 milestone Jan 15, 2024
@claudio-uey
Copy link

Any update on this issue?

@kpoelhekke
Copy link
Contributor

kpoelhekke commented Mar 7, 2024

I've been able to track this down to these lines of code:

$model = $this->get_node_by_id( $id );
            
if ( true === $this->is_valid_model( $model ) ) {
	$nodes[ $id ] = $model;
}

here: \WPGraphQL\Data\Connection\AbstractConnectionResolver::get_nodes

Somehow some products aren't a valid model and those get filtered out. Unfortunately I haven't been able to figure out why. Hope this helps on finding a solution, I'm currently blocked from updating from 0.12.1 because of this.

@MonPetitUd
Copy link

I encountered something similar and found that unpublished products i.e. draft products were consuming the "first" limit but not actually being returned, adding where: { status: "PUBLISHED" } to the query seemed to do the trick for me.

@kidunot89
Copy link
Member

kidunot89 commented May 17, 2024

@MonPetitUd @kpoelhekke @claudio-uey @YishaqG Do you guys have Enable Unsupported Types setting activated? Does it make a difference in the result count?

@kidunot89 kidunot89 modified the milestones: v0.19.1, 0.20.1 May 21, 2024
@MonPetitUd
Copy link

@kidunot89 I don't be that setting was enabled when I encountered this issue.

@kpoelhekke
Copy link
Contributor

@kidunot89 here toggling that setting doesn't have any effect. The query:

query NewQuery {
  products(first: 48, where: {typeIn: [GROUPED]}) {
    edges {
      node {
        id
        name
      }
    }
    pageInfo {
      offsetPagination {
        total
      }
    }
  }
}

returns 47 items with the setting on and off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants