# @mgansler/cypress-graphql

> Simplify intercepting GraphQL calls with cypress.

Latest version **0.0.3** (published 2021-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mgansler/cypress-graphql
pnpm add @mgansler/cypress-graphql
yarn add @mgansler/cypress-graphql
bun add @mgansler/cypress-graphql
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-12-21 |
| First published | 2021-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Martin Gansler |
| Maintainers | mgansler |
| Keywords | testing, cypress, graphql |

## Links

- npm: https://www.npmjs.com/package/@mgansler/cypress-graphql
- Repository: https://github.com/mgansler/plusone
- Homepage: https://github.com/mgansler/plusone#readme
- Issues: https://github.com/mgansler/plusone/issues
- npm.io page: https://npm.io/package/@mgansler/cypress-graphql

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-12-21
- 0.0.2 — 2021-11-08
- 0.0.1 — 2021-11-08

## README

# Cypress GraphQL

This library aims to simplify interception GraphQL calls with Cypress.

## Examples

A simple fetch:

```typescript jsx
cy.graphql('fixture.json').as('fetch')

// make the call
cy.findByRole('button', { name: 'Fetch it!' }).click()

cy.wait('@fetch')
```

Filter for some text in the GraphlQL query:

```typescript jsx
cy.graphql('user-info.json', { filter: 'User' }).as('fetch-user')
cy.graphql('something.json', { filter: 'Something' }).as('fetch-something')

// make the calls
cy.findByRole('button', { name: 'Load user info!' }).click()
cy.wait('@fetch-user')

cy.findByRole('button', { name: 'Load something' }).click()
cy.wait('@fetch-something')
```

Intercept mutations:

```typescript jsx
cy.graphql('mutation-response.json', { operationType: 'mutation' }).as('mutation')

// make the call
cy.findByRole('button', { name: 'Update data' }).click()

cy.wait('@mutation')
```

---
_Source: https://npm.io/package/@mgansler/cypress-graphql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
