-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
MSW doesn't seem to be working with URQL or Vite correctly #1593
Comments
Reproducible demo - this is just CRA with storybook, urql and msw/storybook-addon-msw.
+1 - we've noticed this since updating to urql's latest version (4.x.x). We've noticed it specifically in storybook, but it seems it's an issue for a handful of people across jest, storybook, vite so I'm posting the issue here. I've used storybook in my demo because it pertains to our issues. |
@mayteio I think it's related to URQL getting smarter and shipping some cool stuff such as multipart etc. support out of the box without special exchanges and whatnot. E.g this But it's not a BUG of URQL, not at all, I think it's just MSW isn't compatible with these things or so. I think this will be sorted with the next major release of MSW, unsure if addressable now which is a bit pity. |
Yep - makes total sense. Thanks for the info! I'd love to see continued support. |
Since version 4.0.0, urql started to support for Lines 91 to 94 in 670dda7
Actually it's not a technical issue of msw but an issue of Service Worker (#156 (comment)). As a solution for now to use both urql and msw together, I recommend you to add export const graphqlClient = createClient({
url: 'http://localhost/graphql',
exchanges: [fetchExchange],
fetchOptions: { headers: { accept: '*/*' } } // <- overwrite accept of the request header
}); |
Thanks @tnyo43! What are the implications of accepting /? Would a regular application/json suffice? |
|
This issue seems to affect all users of Urql v4 ... which seems like a pretty big deal. Around 2 months ago, URQL added these headers by default:
It seems to me like |
Hi, @scottrippey. As far as I understand the issue, URQL sends the |
@kettanaito You're correct, the presence of Unfortunately, MSW's logic says "if |
Hi, I've encountered a specific issue while using To gain further insights into the problem, I decided to experiment with REST mocks. Unfortunately, I found that the worker is not functioning as expected in this scenario either. Here are the details of my environment:
To reproduce the issue, I created an isolated environment using the command Despite these observations, I'm still encountering a 404 error. I kindly request your assistance and guidance in resolving this matter. Any help would be greatly appreciated. |
@naorz, I have some time to look into this. Please send me the link to that public reproduction repo. Thanks! |
I'm going to close this. All the references in this issue concern MSW 1.x, which has reached EOL. Please update to |
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
https://codesandbox.io/p/sandbox/brave-voice-5yd8ut
Reproduction steps
I have problems (it doesn't work no matter what I tried) with URQL + Vite. Probably due to some smart-ass preflight calls or so.
Will be glad to get help here or report a bug. A reproduction is a bit tricky on codesandbox, so I suppose downloading the archive and running it locally going to be the best way to test it.
Current behavior
Not a single request to
/graphql
works despite handlers being registered.Expected behavior
Everything works perfectly with all requests getting intercepted returning data.
The text was updated successfully, but these errors were encountered: