Skip to content

fix(client): improve support of deepObject query serialization method#517

Merged
ardatan merged 6 commits into
ardatan:masterfrom
mezannic:master
Sep 1, 2023
Merged

fix(client): improve support of deepObject query serialization method#517
ardatan merged 6 commits into
ardatan:masterfrom
mezannic:master

Conversation

@mezannic

Copy link
Copy Markdown
Contributor

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.

Description

Client - Deep objects are sent as empty string in query parameters.
This makes the client unsuitable for use with JSON:API sparse fieldsets

Related #516

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can
reproduce. Please also list any relevant details for your test configuration

  • yarn test packages/fets/tests/client-query-serialization.spec.ts

Running the test will perform a query to https://postman-echo.com/ to assert that the request sent by the client contains the expected query parameters.

Test Environment:

  • OS: macOS
  • package-name: fets
  • NodeJS: no

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
    -> No changeset generated yet
  • My changes generate no new warnings
    -> GitHub Codespaces shows a linting error in my test file, I don't now why
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
    -> I am not aware of any downstream module which would be affected by this

Further comments

This change, albeit small, is a breaking change: people who would expect objects to be stripped from the query parameters sent by the client will now see them sent to the server. I won't probably cause any issue, but…

@ardatan ardatan marked this pull request as ready for review September 1, 2023 12:50
@ardatan

ardatan commented Sep 1, 2023

Copy link
Copy Markdown
Owner

Thanks @mezannic !

@ardatan ardatan merged commit 0b5278f into ardatan:master Sep 1, 2023
@github-actions github-actions Bot mentioned this pull request Sep 1, 2023
@mezannic

mezannic commented Sep 1, 2023

Copy link
Copy Markdown
Contributor Author

@ardatan Thank you for the fix!

I see you had to update the OpenApiDocument type to fix linter errors. You may want to revert that.
It appears that the OAS schema I included in the merge request is invalid (copy-pasted from here without check), which was what caused the error.
Its server field value should be [{url: 'https://postman-echo.com'}] instead of ['https://postman-echo.com']. Sorry.

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