# graphql-middleware-handler

> Handle GraphQL Middlewares with simplicity.

Latest version **1.0.2** (published 2020-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphql-middleware-handler
pnpm add graphql-middleware-handler
yarn add graphql-middleware-handler
bun add graphql-middleware-handler
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-12-08 |
| First published | 2020-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fouad Hanani |
| Maintainers | fouad-hanani |
| Keywords | graphql, GraphQL, middleware, apollo-server |

## Links

- npm: https://www.npmjs.com/package/graphql-middleware-handler
- Repository: https://github.com/Fouad-Hanani/GraphQLMiddlewareHandler
- Homepage: https://github.com/Fouad-Hanani/GraphQLMiddlewareHandler#readme
- Issues: https://github.com/Fouad-Hanani/GraphQLMiddlewareHandler/issues
- npm.io page: https://npm.io/package/graphql-middleware-handler

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-12-08
- 1.0.1 — 2020-12-08
- 1.0.0 — 2020-12-08

## README

# GraphQLMiddlewareHandler

A much simpler handling of **GraphQL Middlewares**.

# Installation

## via NPM

`npm i graphql-middleware-handler`

## via Yarn

`yarn add graphql-middleware-handler`

# Usage

## graphqlmiddleware(validationFuntion, errorMessage, resolverFunction)

validationFunction
: A function that has access to the context, returns a `boolean` and used to control the flow of execution.

errorMessage
: A string passed as a param when throwing an error if `validationFunction` return `false`

resolverFunction
: A function that is executed if `validationFunction` return `true`

```
const graphqlmiddleware = require('graphql-middleware-handler');

const validationFunction = (context) => {...};
const errorMessage = "...";
const resolverFunction = (parent, args, context, info) => {...}

const QueryResolver = {
	login: graphqlmiddleware(validationFunction, errorMessage, resolverFunction),
}

module.exports = QueryResolver;
```

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