Skip to content

Change the form of our NextLink used for pagination cursors#1851

Merged
aaronburtle merged 24 commits intomainfrom
dev/aaronburtle/ChangeNextLinkAndUpdateTests
Nov 11, 2023
Merged

Change the form of our NextLink used for pagination cursors#1851
aaronburtle merged 24 commits intomainfrom
dev/aaronburtle/ChangeNextLinkAndUpdateTests

Conversation

@aaronburtle
Copy link
Copy Markdown
Contributor

@aaronburtle aaronburtle commented Oct 30, 2023

Why make this change?

Updates the form of our NextLink cursor used for pagination. This only updates the part used for the response, which is then used to continue the paginated requests. Matches the desired form.

What is this change?

Rather than using part of the SqlQueryStructures to form the cursor, we create an object that is only used specifically for the NextLink with respect to the response/request. This means we don't need all of the fields that are included in the pagination columns, and that the information contained in this object is really unrelated to the query structure.

We therefore introduce a new class in our pagination utilities which can be used to facilitate the serialization and deserialization of the NextLink cursor in the response/request. Using an anonymous object was considered, but we re-use this object in enough places, and it holds complex enough data, that it will be easier to understand and be more reusable if we define a new class here inside of our pagination utilities.

The Json structure that is contained within the response/request that we (de)serialize with this new class is therefore modified.

Previous

[{"Value":0,"Direction":0,"TableSchema":"foo","TableName":"bar","ColumnName":"baz"}]")

Updated

[{"EntityName":"foobar","FieldName":"qux","Value":0,"Direction":0}]

Complete NextLink without being decoded

"nextLink": "https://localhost:5001/rest/Book?$first=1&$after=W3siVmFsdWUiOjEsIkRpcmVjdGlvbiI6MCwiVGFibGVTY2hlbWEiOiJkYm8iLCJUYWJsZU5hbWUiOiJib29rcyIsIkNvbHVtbk5hbWUiOiJpZCJ9XQ%3D%3D"

How was this tested?

Modified our current test suite to match the new format.

Sample Request(s)

and paginated request should work as long as it uses or generated a cursor for pagination.

one such example for when REST has a path of /rest against the Book entity.

https://localhost:5001/rest/Book?$first=1

Comment thread src/Core/Resolvers/SqlPaginationUtil.cs
Copy link
Copy Markdown
Contributor

@severussundar severussundar left a comment

Choose a reason for hiding this comment

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

Need to fix failing test related to after token - RequestAfterTokenOnly

Copy link
Copy Markdown
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

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

I appreciate your efforts to update the nextLink. I like the new format. To be in a good state to merge, please add more comments for new classes, more descriptive variable names.

Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Comment thread src/Service.Tests/SqlTests/GraphQLPaginationTests/GraphQLPaginationTestBase.cs Outdated
Comment thread src/Service.Tests/SqlTests/RestApiTests/Find/FindApiTestBase.cs Outdated
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Copy link
Copy Markdown
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

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

a few suggestions about naming consistency and what var names we should attribute with data received from request versus DAB internal datastructures mapping to database metadata.

Comment thread src/Core/Resolvers/SqlPaginationUtil.cs
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs Outdated
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs
Comment thread src/Core/Resolvers/SqlPaginationUtil.cs
Copy link
Copy Markdown
Contributor

@severussundar severussundar left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for fixing this and incorporating the suggestions!

@seantleonard seantleonard self-requested a review November 10, 2023 17:28
@aaronburtle
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Copy Markdown
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

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

Thank you for addressing feedback! lgtm!

@aaronburtle
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle aaronburtle enabled auto-merge (squash) November 10, 2023 23:22
@aaronburtle
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle aaronburtle merged commit d1fa539 into main Nov 11, 2023
@aaronburtle aaronburtle deleted the dev/aaronburtle/ChangeNextLinkAndUpdateTests branch November 11, 2023 00:57
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

Updates the form of our NextLink cursor used for pagination. This only
updates the part used for the response, which is then used to continue
the paginated requests. Matches the desired form.

## What is this change?

Rather than using part of the `SqlQueryStructures` to form the cursor,
we create an object that is only used specifically for the NextLink with
respect to the response/request. This means we don't need all of the
fields that are included in the pagination columns, and that the
information contained in this object is really unrelated to the query
structure.

We therefore introduce a new class in our pagination utilities which can
be used to facilitate the serialization and deserialization of the
NextLink cursor in the response/request. Using an anonymous object was
considered, but we re-use this object in enough places, and it holds
complex enough data, that it will be easier to understand and be more
reusable if we define a new class here inside of our pagination
utilities.


The Json structure that is contained within the response/request that we
(de)serialize with this new class is therefore modified.

Previous

```
[{"Value":0,"Direction":0,"TableSchema":"foo","TableName":"bar","ColumnName":"baz"}]")
```

Updated

```
[{"EntityName":"foobar","FieldName":"qux","Value":0,"Direction":0}]
```

Complete NextLink without being decoded

```
"nextLink": "https://localhost:5001/rest/Book?$first=1&$after=W3siVmFsdWUiOjEsIkRpcmVjdGlvbiI6MCwiVGFibGVTY2hlbWEiOiJkYm8iLCJUYWJsZU5hbWUiOiJib29rcyIsIkNvbHVtbk5hbWUiOiJpZCJ9XQ%3D%3D"
```
## How was this tested?

Modified our current test suite to match the new format.

## Sample Request(s)

and paginated request should work as long as it uses or generated a
cursor for pagination.

one such example for when REST has a path of /rest against the Book
entity.

https://localhost:5001/rest/Book?$first=1

---------

Co-authored-by: Aniruddh Munde <[email protected]>
@Aniruddh25 Aniruddh25 added the port needed Describes if port to release branch is required label Nov 13, 2023
Aniruddh25 added a commit that referenced this pull request Nov 13, 2023
## Why make this change?

This is simply cherry-picking the following PRs before creating the next
stable 0.9 version:

- #1876
- #1821 
- #1854 
- #1851 
- #1872 
- #1868

---------

Co-authored-by: Sean Leonard <[email protected]>
Co-authored-by: Abhishek  Kumar <[email protected]>
Co-authored-by: neeraj-sharma2592 <[email protected]>
Co-authored-by: Neeraj Sharma (from Dev Box) <[email protected]>
Co-authored-by: aaronburtle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port needed Describes if port to release branch is required

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants