graphql-hooks
Version:
27 lines (26 loc) • 867 B
TypeScript
/**
* Generic Middleware function that
* will run object through all provided functions
*
*
* Minimal example:
* const MyMiddleware = ({ operation }, next) => {
* operation.variables.user = 'admin'
* next()
* }
*
* All parameters provided are written in run function JSDoc
*/
export default class Middleware {
constructor(fns: any);
/**
* Run middleware
* @param {opts.client} GraphQLClient instance
* @param {opts.operation} Operation object with properties such as query and variables
* @param {opts.resolve} Used to early resolve the request
* @param {opts.addResponseHook} Hook that accepts a function that will be run after response is fetched
* @param {opts.reject} User to early reject the request
* @param {function} next
*/
run(opts: any, next: Function): void;
}