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 do not intercept GraphQL requests at all #63
Comments
Hey, @avallonazevedo. Could you please share how do you call Also, make sure you don't use any fetch mocks. Using them means you replace
|
+1 been struggling to get mswjs to work for my project I noticed that with But don't see any docs on how to configure for graphql; |
@pelhage, if you wish to intercept GraphQL operations on a per-endpoint basis you can use graphql.link. See the usage example here. By default, MSW intercepts all matching GraphQL operations regardless of the origin. |
Please bear in mind that if you experience something not working, you'd have to share your setup and usage—the more the better. Ideally, a reproduction repository is something that helps to resolve the issue really fast. We always prioritize issues that come with reproduction repositories. |
Hi @kettanaito! Thank you for the fast response. As you asked, here is the configuration of how I use setup-server:
I'm not using any mock for "fetch". I just tried using some mock package, as exemplified in some internet responses with people with similar problems. I'm going to try to provide a more concrete example in some tool like Codesandbox, although I'm not allowed to show much code of the application I'm working on. Thanks again for your help. |
Could you double-check that you're providing those It should look something like this: setupServer(...handlers) Once you do, go to your graphqlServer.on('request:start', console.log) Run the affected test again. Do you see a console log in the output? If you don't, chances are MSW is not running in your test at all due to some setup issue. |
My
I also tried to use |
I also encounter the issue where in msw server seems to not intercept the graphql requests. in my case, it didn't intercept because the
and it worked! of course, there might be other factors but, maybe you can double check your |
That's a good point, @maurusrv. Always make sure you configure your Apollo Client properly. In Node.js you need to specify the |
Excellent my dears! With Perhaps we should make this more explicit in the documentation? Thank you both for your help! |
@avallonazevedo, that's a configuration to address on your GraphQL client's side (Apollo). I believe that point is written in their docs. I can also see an explicit error whenever I run Apollo in Node.js (test) without specifying the |
I've tried every possible solution described on the internet, but nothing seems to help.
I created a mock server and am trying to intercept a GraphQL call:
./setup/setup-server.ts
./graphql/use-get-operation.ts
The call is not intercepted.
I've already tried:
Nothing seems to work.
I tried to create both queries and mutations and it didn't work.
MSW version used: 0.33.0
The text was updated successfully, but these errors were encountered: