ory / ory/sdk

Remove calls to querystring.queryParamsStringify

Open
#446 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
178
Forks
96
Avg merge
6d 23h
Merged PRs (30d)
3

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @ory/hydra-client-fetch@v2.4.0-alpha.1 for the project I'm working on.

I've run into queryParamStringify is not a function repeatedly. Mainly after creating a production bundle using rollupjs with a mimicked directory structure. From the documentation it seems that queryParamStringify had been removed when querystring was removed, yet it is still called in runtime.ts

  get queryParamsStringify(): (params: HTTPQuery) => string {
        return this.configuration.queryParamsStringify || querystring;
    }

This has not really solved my problem yet, but i plan on this being my next attempt. If there is a canonical way to handle this, please let me know. Thanks!!

Here is the diff that solved my problem:

diff --git a/node_modules/@ory/hydra-client-fetch/src/runtime.ts b/node_modules/@ory/hydra-client-fetch/src/runtime.ts
index c7f8543..70929e5 100644
--- a/node_modules/@ory/hydra-client-fetch/src/runtime.ts
+++ b/node_modules/@ory/hydra-client-fetch/src/runtime.ts
@@ -48,7 +48,18 @@ export class Configuration {
     }
 
     get queryParamsStringify(): (params: HTTPQuery) => string {
-        return this.configuration.queryParamsStringify || querystring;
+      const searchParams = new URLSearchParams();
+      for (const key in params) {
+        if (Object.prototype.hasOwnProperty.call(params, key)) {
+          const value = params[key];
+          if (Array.isArray(value)) {
+            value.forEach(item => searchParams.append(key, item));
+          } else {
+            searchParams.append(key, value);
+          }
+        }
+      }
+      return searchParams.toString();
     }
 
     get username(): string | undefined {

This issue body was partially generated by patch-package.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in runtime.ts by tracing the queryParamsStringify getter and the remaining querystring reference, then inspect how the generated client is bundled with Rollup. Done means the obsolete querystring.queryParamsStringify call is removed or replaced consistently and the production bundle no longer reports queryParamStringify is not a function.

Written by the indexing model from the issue text.

Assessment

Tech stack
rollup, typescript
Domain
api, build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.