-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add @envelop/disable-introspection package (#130)
* feat: add @envelop/disable-introspection package * updated readme Co-authored-by: Dotan Simha <dotansimha@gmail.com>
- Loading branch information
1 parent
6ca4211
commit d1c0ce0
Showing
5 changed files
with
95 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@envelop/disable-introspection': patch | ||
--- | ||
|
||
Initial implementation of the plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## `@envelop/disable-introspection` | ||
|
||
This plugin injects the `NoSchemaIntrospectionCustomRule` validation rule exported from the `graphql` module to the validation phase for disabling introspection. | ||
|
||
## Getting Started | ||
|
||
``` | ||
yarn add @envelop/disable-introspection | ||
``` | ||
|
||
## Usage Example | ||
|
||
```ts | ||
import { envelop } from '@envelop/core'; | ||
import { useDisableIntrospection } from '@envelop/disable-introspection'; | ||
|
||
const getEnveloped = envelop({ | ||
plugins: [useDisableIntrospection()], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@envelop/disable-introspection", | ||
"version": "0.0.0", | ||
"author": "Dotan Simha <dotansimha@gmail.com>", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dotansimha/envelop.git", | ||
"directory": "packages/plugins/disable-introspection" | ||
}, | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"typescript": { | ||
"definition": "dist/index.d.ts" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"prepack": "bob prepack" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"bob-the-bundler": "1.2.0", | ||
"graphql": "15.5.0", | ||
"typescript": "4.2.4" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "^14.0.0 || ^15.0.0" | ||
}, | ||
"buildOptions": { | ||
"input": "./src/index.ts" | ||
}, | ||
"publishConfig": { | ||
"directory": "dist", | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { NoSchemaIntrospectionCustomRule } from 'graphql'; | ||
import { Plugin } from '@envelop/types'; | ||
|
||
export const useDisableIntrospection = (): Plugin => { | ||
return { | ||
onValidate: ({ addValidationRule }) => { | ||
addValidationRule(NoSchemaIntrospectionCustomRule); | ||
}, | ||
}; | ||
}; |