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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql keeps pending #4

Closed
viiiprock opened this issue Aug 1, 2021 · 7 comments
Closed

Graphql keeps pending #4

viiiprock opened this issue Aug 1, 2021 · 7 comments

Comments

@viiiprock
Copy link

viiiprock commented Aug 1, 2021

I tried to setup http-middleware with graphql as both createServer or createMiddleware as the document, but it only works with rest

  • graphql handlers is pending with createMiddleware (sometimes 404, I'm not sure) 馃
  • 404 with createServer

I don't know if I'm missing something or it's an issue. Can I have an example with graphql?

Note: I used msw for my nextjs, but since I had /pages/[...slug].tsx, it had issue with graphql endpoint, so I have to find another solution, seems http-middleware is what I'm looking for.

@viiiprock viiiprock changed the title Graphql doesn't work Graphql keep pending Aug 1, 2021
@viiiprock viiiprock changed the title Graphql keep pending Graphql keeps pending Aug 1, 2021
@viiiprock
Copy link
Author

nvm, I don't much time, hardcode to skip catching graphql endpoint, use msw an removed http-middleware anyway.

@kettanaito
Copy link
Member

Hey, @viiiprock.

You should be using MSW for API mocking. As the readme of this repository states, it's designed primarily for introspection and complex scenarios, like dockerized applications. Your case, based on the info you've provided, is neither and should use MSW directly. It can intercept and mock GraphQL operations without issues.

@viiiprock
Copy link
Author

@kettanaito the truth is I still need a graphql mock server using MSW since my project is in NX mono-repo with separate admin site and web site.
Hopefully this html-middleware can resolve this
Thanks for your answer!

@kettanaito
Copy link
Member

@viiiprock, I'd be happy to look into your issue if you provide a reproduction repository.

@viiiprock
Copy link
Author

@kettanaito here is my demo https://github.com/viiiprock/nx-msw
For the mock api I use msw and html-middleware. You can see at the web which consumes mockapi, it works well with rest API, but for graphql it's 404 on request /graphql endpoint.

@rsimp
Copy link

rsimp commented Mar 25, 2022

Is their any update on this? If the middleware doesn't respect graphql mockiing, then it should really be taken out of the docs, or a footnote saying it can only be used in a standalone server, which is not what express middleware implies

@andrzej-woof
Copy link

See mswjs/msw-storybook-addon#55 (comment)
For me the problem was lack of body-parser middleware on server, which in result made mocks skip GQL requests as they had no body

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

No branches or pull requests

4 participants