New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@envelop/graphql-middleware

Package Overview
Dependencies
Maintainers
1
Versions
1268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@envelop/graphql-middleware

This plugins wraps [`graphql-middleware`](https://github.com/maticzav/graphql-middleware) and allow you to apply schema middlewares that uses the standard defined by `graphql-middleware`.

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@envelop/graphql-middleware

This plugins wraps graphql-middleware and allow you to apply schema middlewares that uses the standard defined by graphql-middleware.

You can find an awesome list of middlewares here

Getting Started

yarn add graphql-middleware @envelop/graphql-middleware

Usage Example

You can use any type of middleware defined for graphql-middleware, here's an example for doing that with graphql-shield:

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { and, not, or, rule, shield } from 'graphql-shield'
import { envelop, useEngine } from '@envelop/core'
import { useGraphQLMiddleware } from '@envelop/graphql-middleware'

// ...
// You can find a complete example here: https://github.com/maticzav/graphql-shield#graphql-yoga
// ...

const permissions = shield({
  Query: {
    fruits: and(isAuthenticated, or(isAdmin, isEditor))
  },
  Mutation: {
    addFruitToBasket: isAuthenticated
  },
  Fruit: isAuthenticated,
  Customer: isAdmin
})

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useSchema(mySchema),
    useGraphQLMiddleware([permissions])
  ]
})

FAQs

Package last updated on 16 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc