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

(core) - Shorten queries for hashing #911

Merged
merged 4 commits into from
Jul 21, 2020
Merged

(core) - Shorten queries for hashing #911

merged 4 commits into from
Jul 21, 2020

Conversation

JoviDeCroock
Copy link
Collaborator

Summary

This shortens the querystring by removing whitespaces and comments when a request is created with an unparsed query.

@JoviDeCroock JoviDeCroock requested a review from kitten July 17, 2020 10:38
@changeset-bot
Copy link

changeset-bot bot commented Jul 17, 2020

🦋 Changeset is good to go

Latest commit: 9521137

We got this.

This PR includes changesets to release 1 package
Name Type
@urql/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JoviDeCroock JoviDeCroock requested a review from wgolledge July 17, 2020 10:39
@@ -7,7 +7,8 @@ interface Documents {
[key: number]: DocumentNode;
}

const hashQuery = (q: string): number => hash(q.replace(/[\s,]+/g, ' ').trim());
const hashQuery = (q: string): number =>
hash(q.replace(/([\s,]|#[^\n\r]+)+/g, ' ').trim());
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. I wonder if we should confirm that hashes only ever occur after newline+whitespace (though I'm sure this should be okay)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wgolledge I've added a test

Copy link
Contributor

@wgolledge wgolledge left a comment

Choose a reason for hiding this comment

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

Nice 😁

@kitten kitten changed the title Shorter query strings (core) - Shorten queries for hashing Jul 21, 2020
@kitten kitten merged commit 873ba9d into main Jul 21, 2020
@kitten kitten deleted the shorter-query-strings branch July 21, 2020 21:30
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