# relay-commit-mutation-promise

> Promise wrapper for Relay Modern's commit mutation

Latest version **1.2.0** (published 2023-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install relay-commit-mutation-promise
pnpm add relay-commit-mutation-promise
yarn add relay-commit-mutation-promise
bun add relay-commit-mutation-promise
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2023-04-14 |
| First published | 2017-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | rob@robrichard.net |
| Maintainers | robrichard |

## Links

- npm: https://www.npmjs.com/package/relay-commit-mutation-promise
- Repository: https://github.com/robrichard/relay-commit-mutation-promise
- Homepage: https://github.com/robrichard/relay-commit-mutation-promise#readme
- Issues: https://github.com/robrichard/relay-commit-mutation-promise/issues
- npm.io page: https://npm.io/package/relay-commit-mutation-promise

## Recent versions

- 1.2.0 (latest) — 2023-04-14
- 1.1.4 — 2021-03-22
- 1.1.3 — 2019-10-09
- 1.1.2 — 2019-09-18
- 1.1.1 — 2019-09-18
- 1.1.0 — 2019-09-18
- 1.0.1 — 2017-11-21
- 1.0.0 — 2017-07-10

## README

# relay-commit-mutation-promise
Promise wrapper for Relay Modern's commit mutation

## Installation
```
npm install relay-commit-mutation-promise
```

## Usage with Relay Modern
```js
const commitMutation = require('relay-commit-mutation-promise');
const {graphql} = require('react-relay');

const mutation = graphql`
  mutation MarkReadNotificationMutation(
    $input: MarkReadNotificationData!
  ) {
    markReadNotification(data: $input) {
      notification {
        seenState
      }
    }
  }
`;
const variables = {
  input: {
    source,
    storyID,
  },
};

commitMutation(environment, {mutation, variables})
  .then(response => {
    // handle successful response
  })
  .catch(error => {
    const graphqlErrors = error.source.errors;
    // handle error
  });
```

Usage with Relay Modern compat layer
```js
const commitMutation = require('relay-commit-mutation-promise/compat');
```
## Accessing GraphQL errors
The error object returned in the rejected promise contains a `source` property which contains an array of the errors returned by the GraphQL server.

---
_Source: https://npm.io/package/relay-commit-mutation-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
