mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add types for graphql-depth-limit (#25568)
* add types for graphql-depth-limit * improve type declaration * remove "strict-export-declare-modifiers" rule disable
This commit is contained in:
29
types/graphql-depth-limit/graphql-depth-limit-tests.ts
Normal file
29
types/graphql-depth-limit/graphql-depth-limit-tests.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import graphqlDepthLimit = require('graphql-depth-limit');
|
||||
import {
|
||||
GraphQLSchema,
|
||||
DocumentNode,
|
||||
buildSchema,
|
||||
Source,
|
||||
parse,
|
||||
validate,
|
||||
specifiedRules
|
||||
} from 'graphql';
|
||||
|
||||
const schema: GraphQLSchema = buildSchema(`
|
||||
# graphql schema goes here...
|
||||
`);
|
||||
const document: DocumentNode = parse(new Source(`
|
||||
# graphql query goes here...
|
||||
`, 'GraphQL request'));
|
||||
|
||||
validate(schema, document, [ graphqlDepthLimit(5) ]);
|
||||
|
||||
validate(schema, document, [ ...specifiedRules, graphqlDepthLimit(10) ]);
|
||||
|
||||
validate(schema, document, [ graphqlDepthLimit(
|
||||
10,
|
||||
{ ignore: [ /_trusted$/, 'idontcare' ] },
|
||||
(depths: any) => {
|
||||
// do something....
|
||||
},
|
||||
)]);
|
||||
14
types/graphql-depth-limit/index.d.ts
vendored
Normal file
14
types/graphql-depth-limit/index.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Type definitions for graphql-depth-limit 1.1
|
||||
// Project: https://github.com/stems/graphql-depth-limit#readme
|
||||
// Definitions by: Siim Tiilen <https://github.com/eritikass>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
declare function depthLimit(depthLimit: number, options?: depthLimit.Options, callback?: (obj: any) => void): any;
|
||||
export = depthLimit;
|
||||
|
||||
declare namespace depthLimit {
|
||||
interface Options {
|
||||
ignore: Array<string | RegExp | ((queryDepths: any[]) => boolean)>;
|
||||
}
|
||||
}
|
||||
23
types/graphql-depth-limit/tsconfig.json
Normal file
23
types/graphql-depth-limit/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"graphql-depth-limit-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/graphql-depth-limit/tslint.json
Normal file
1
types/graphql-depth-limit/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user