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

fix(core): Allow path-only URLs to be used with GET requests #3514

Merged
merged 2 commits into from
Mar 2, 2024

Conversation

akrantz01
Copy link
Contributor

Summary

Changes query parameter handling to allow path-only URLs (i.e. /api/graphql) passed to fetch to be used with GET requests. This was previously broken as URL would throw a TypeError: Invalid URL as it only works with fully formed URLs.

Extracting the unparsed query parameters is now done manually, so as to not depend on URL. Important to note is that the current method will not handle URLs with fragments (i.e. /api/graphql#fragment) in them, but it is easy to add if desired.

Copy link

changeset-bot bot commented Mar 2, 2024

🦋 Changeset detected

Latest commit: 1a0015d

The changes in this PR will be included in the next version bump.

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

Copy link
Member

@kitten kitten left a comment

Choose a reason for hiding this comment

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

Great work! I only have some nits here.

We indeed previously assumed that a full URL will be passed, but of course, this doesn't give a user the most options, so I appreciate the suggestion! The test is great too ❤️

I've left the nits mostly for code style / byte savings, so that's why they're nits

packages/core/src/internal/fetchOptions.ts Outdated Show resolved Hide resolved
packages/core/src/internal/fetchOptions.ts Outdated Show resolved Hide resolved
packages/core/src/internal/fetchOptions.ts Outdated Show resolved Hide resolved
@kitten kitten merged commit eb1286c into urql-graphql:main Mar 2, 2024
13 checks passed
@github-actions github-actions bot mentioned this pull request Mar 2, 2024
@akrantz01 akrantz01 deleted the path-only-urls branch March 2, 2024 19:28
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