How to use the graphql-middleware.middleware function in graphql-middleware

To help you get started, we’ve selected a few graphql-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Canner / graphql-i18n / src / index.ts View on Github external
: leafResult;
      } else if (!isNil(i18nObj)) {
        return {
          ...result,
          __i18n: i18nObj,
          __i18nLastPath: i18nLastPath,
        };
      }

      return result;
    };

    function generateMiddleware(): IMiddlewareFunction {
      return i18nMiddleware;
    }
    return middleware(generateMiddleware);
  }
github waitandseeagency / graphql-sword / src / index.ts View on Github external
export function permissions(
  permissionsRules: IPermission[],
  _options?: IOptions,
) {
  return middleware((schema: GraphQLSchema) => {
    const options = normalizeOptions(_options)
    return validatePermissions(schema, permissionsRules, options)
  })
}
github maticzav / graphql-shield / src / shield.ts View on Github external
export function shield(
  ruleTree: IRules,
  options: IOptionsConstructor = {},
): IMiddlewareGenerator {
  const normalizedOptions = normalizeOptions(options)
  const ruleTreeValidity = validateRuleTree(ruleTree)

  if (ruleTreeValidity.status === 'ok') {
    const generatorFunction = generateMiddlewareGeneratorFromRuleTree<
      TSource,
      TContext,
      TArgs
    >(ruleTree, normalizedOptions)

    return middleware(generatorFunction)
  } else {
    throw new ValidationError(ruleTreeValidity.message)
  }
}

graphql-middleware

GraphQL Middleware done right!

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis