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

Support maximumLimit in pagination #515

Merged
merged 1 commit into from
Aug 17, 2023
Merged

Conversation

ec8or
Copy link
Contributor

@ec8or ec8or commented Feb 9, 2023

At the moment, you can only change the maximum limit in the overall settings. This enables support for the maximumLimit setting per model.

Issues

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test for this scenario?

@ec8or
Copy link
Contributor Author

ec8or commented Feb 10, 2023

I could try and have a look, but doesn't seem like there's any tests for setting it via the main config at the moment (or for defaultLimit)?

@flamerohr
Copy link
Contributor

@GuySartorelli looking into this for @ec8or, how would I test PaginationPlugin::apply?

I had found testBasicPaginator but that seems to use its own resolver with IntegrationTestResolver::testPaginate

@GuySartorelli
Copy link
Member

Probably the simplest way, without diving in too deep, would be to set up a new test schema folder, set up whatever schema you need in order to test a) without setting this and b) with setting this, and then write a test that executes a query on each of those scenarios.
I can't go into more detail than that without diving into the code myself though, and unfortunately I don't have time for that right now. Does this give you enough to work from?

@GuySartorelli
Copy link
Member

Ultimately though, if you can't get a test working with the time you have to look into this, then if you can give me a simple example of how to test it locally that would be okay for now.

@flamerohr
Copy link
Contributor

Thanks! I'm not sure if I'll have the time to build something new like that.

I can include test schema data that I had in mind for this.

The query I'd use for both scenarios:

query {
  readMyTypes(limit: 5) {
    nodes {
        field1
    }
    pageInfo {
      totalCount
    }
  }
}

For with the config schema:

SilverStripe\GraphQL\Tests\Fake\DataObjectFake:
  fields:
    myField: true
  operations:
    read:
      plugins:
        paginateList:
          maximumLimit: 3

and the query from above, which checks the size of nodes to be 3, and totalCount to be something greater than 5.

For without the config schema:

SilverStripe\GraphQL\Tests\Fake\DataObjectFake:
  fields:
    myField: true
  operations:
    read:
      plugins:
        paginateList: true

and the query from above, which checks the size of nodes to be 5, and totalCount to be something greater than 5.

At the moment, you can only change the maximum limit in the overall settings. This enables support for the maximumLimit setting per model.
@GuySartorelli
Copy link
Member

I've changed the target branch to 5 since we won't be releasing any new minor versions for the 4.x release line, and I've rebased the PR so it can merge into the 5 branch without issues. The actual code change in this PR hasn't changed.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Works exactly as advertised. Will merge when CI goes green.

@GuySartorelli GuySartorelli merged commit c7bb21b into silverstripe:5 Aug 17, 2023
12 checks passed
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

Successfully merging this pull request may close these issues.

3 participants