apollographql / apollographql/graphql-testing-library
How to test subscriptions?
- Dominant language
- TypeScript
- Stars
- 61
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting "socket closed" with or without config with `import { ws } from 'msw'`.
Piece of my `.storybook/preview.tsx`:
```
parameters: {
msw: {
handlers: {
graphql: createHandlerFromSchema(...)
}
},
```
Looks like `createHandlerFromSchema` already integrates with MSW but not for subscriptions, is that a bug? And somehow even if I try to configure `msw.ws.link(...)` it still has no effect. Either way please add an example to this repo
storybook params come from https://github.com/mswjs/msw-storybook-addon
I set up resolver for subscription query via `rxjs.Subject` that gets kicked off by calling a mutation (couldn't use `PubSub` from your demo because it has no built-in impl for browser and I already have rxjs). But I don't think that matters.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the `.storybook/preview.tsx` configuration and the repository's existing subscription demo, then reproduce the `socket closed` behavior with `createHandlerFromSchema` and compare it with `msw.ws.link(...)`. Done means the repository includes a working browser subscription example using the described setup and demonstrates how a mutation-triggered `rxjs.Subject` update is handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100