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

Add example for cursor based pagination #45

Merged
merged 4 commits into from
Jun 12, 2024
Merged

Conversation

royderks
Copy link
Contributor

On request by Timil, who couldn't find example source code for cursor based pagination. I noticed we do have an example in this repo under /rest but it doesn't show how to implement for DBs. The testing turned out to be more of an integration test because of the database. I could also move this example to the examples repo if you think that's a better fit.

@royderks royderks requested a review from ddebrunner May 14, 2024 10:01
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ddebrunner ddebrunner left a comment

Choose a reason for hiding this comment

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

I think needs some refactoring to bring into line with the existing rest/pagination examples.

pagination/cursor/README.md Outdated Show resolved Hide resolved
pagination/cursor/README.md Outdated Show resolved Hide resolved
pagination/cursor/operations.graphql Outdated Show resolved Hide resolved
pagination/cursor/README.md Outdated Show resolved Hide resolved
pagination/cursor/api.graphql Outdated Show resolved Hide resolved
pagination/cursor/api.graphql Outdated Show resolved Hide resolved
pagination/cursor/README.md Outdated Show resolved Hide resolved
pagination/cursor/README.md Outdated Show resolved Hide resolved
tests/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ddebrunner ddebrunner left a comment

Choose a reason for hiding this comment

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

Changes can be follow on


StepZen supports pagination through the standard [GraphQL Cursor Connection Specification](https://relay.dev/graphql/connections.htm).

This allows clients consuming a StepZen GraphQL endpoint to page through resultsmregardless of the originating backend type (e.g. GraphQL endpoint, database, REST API).
Copy link
Contributor

Choose a reason for hiding this comment

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

typo:"resultsmregardless"


To retrieve the first page of a result, the operation is called with `after` omitted or set to the empty string (`""`), and `first` is set to the number of results to return in a page.

Subsequent pages can then be retrieved by setting `after` to the value of `endCursor` from `pageInfo` from the previous request. `first` should be set to the value used in the first request.
Copy link
Contributor

Choose a reason for hiding this comment

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

As an FYI - this is not true:
first should be set to the value used in the first request

Typically it is, but there's no requirement for that to be true.

@@ -83,6 +83,14 @@ These are available in `/sequence`:
- `/transformsInMaterializer` shows how connecting two subgraphs can invoke transformations in between. For example, the `city` of a customer can be fed into a `weather` that takes `lat,lon` by calling some geocoding in the sequence
- `/useOfJSON` shows how, in long sequences, a new type does not have to created for every step--treat everything as JSON up to the last step, and your type system stays clean.

## @dbquery

View the documentation for the [`@dbquery` custom directive](https://www.ibm.com/docs/en/api-connect/ace/saas?topic=directives-directive-dbquery) in the documentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Love the link to the newly generated documentation.

@ddebrunner ddebrunner merged commit bd388a8 into main Jun 12, 2024
1 check passed
@ddebrunner ddebrunner deleted the roy/cursor-pagination branch June 12, 2024 11:25
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.

2 participants