Skip to content

GraphQL Pagination skips first element, when there is parameter after set and it's left as empty or set as zero. #3355

@NikoGrano

Description

@NikoGrano

API Platform version(s) affected: 2.5.4

Description
GraphQL Pagination skips first element, when there is parameter after set and it's left as empty or set as zero.

How to reproduce

query listAll {
  products(name: "", after: "") {
    pageInfo {
      hasNextPage,
      hasPreviousPage,
    }
    totalCount,
    edges {
      cursor,
      node {
        id,
        name,
        ean,
        price,
        expiring, 
      }
    }
  }
}

or

query listAll {
  products(name: "", after: "MA==") {
    pageInfo {
      hasNextPage,
      hasPreviousPage,
    }
    totalCount,
    edges {
      cursor,
      node {
        id,
        name,
        ean,
        price,
        expiring, 
      }
    }
  }
}

Possible Solution
If parameter empty, return also first (MA==) entry also. Do not return one "after" it. If it is set to 0 (MA==), return 1 (MQ==) as first entry.
Posting a PR soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions