https://github.com/capaj/graphql-vcr
a recorder for graphql-can record and "replay" requests coming to your API
https://github.com/capaj/graphql-vcr
Last synced: 5 months ago
JSON representation
a recorder for graphql-can record and "replay" requests coming to your API
- Host: GitHub
- URL: https://github.com/capaj/graphql-vcr
- Owner: capaj
- License: mit
- Created: 2018-04-29T23:08:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T00:48:12.000Z (about 8 years ago)
- Last Synced: 2025-07-09T13:08:04.017Z (12 months ago)
- Language: TypeScript
- Size: 60.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-vcr
## Usage with koa
```javascript
import graphqlVcr from 'graphql-vcr'
import { graphql } from 'graphql'
const vcr = graphqlVcr({
schema,
graphql
enable: true /* put false to disable recording without having to remove any code*/
})
graphQLRouter.post('/graphql', koaBody(), (context, next) => {
const reqRec = vcr.recordRequest()
reqRec.query(context.req.body)
return graphqlKoa({
schema,
context: context.req.session
})(context, next).then(() => {
reqRec.result(context.response.body)
})
})
// then to replay:
vcr.playFile('./vcr-sessions/2018-04-30T00:24:24.317Z.json', false) // pass true as second argument to check the result of queries
// helper method
vcr.playLastSession(false) // pass true as second argument to check the result of queries
```