mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Added Types for Graphql Query Complexity
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Created by Ivo Meißner on 28.07.17.
|
||||
*/
|
||||
import { ValidationContext, FragmentDefinitionNode, OperationDefinitionNode, FieldNode, InlineFragmentNode, GraphQLUnionType, GraphQLObjectType, GraphQLInterfaceType, GraphQLError } from 'graphql';
|
||||
export interface QueryComplexityOptions {
|
||||
maximumComplexity: number;
|
||||
variables?: object;
|
||||
onComplete?: (complexity: number) => void;
|
||||
createError?: (max: number, actual: number) => GraphQLError;
|
||||
}
|
||||
export default class QueryComplexity {
|
||||
context: ValidationContext;
|
||||
complexity: number;
|
||||
options: QueryComplexityOptions;
|
||||
fragments: {
|
||||
[name: string]: FragmentDefinitionNode;
|
||||
};
|
||||
OperationDefinition: object;
|
||||
constructor(context: ValidationContext, options: QueryComplexityOptions);
|
||||
onOperationDefinitionEnter(operation: OperationDefinitionNode): void;
|
||||
onOperationDefinitionLeave(): GraphQLError | undefined;
|
||||
nodeComplexity(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode |
|
||||
OperationDefinitionNode, typeDef: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, complexity?: number): number;
|
||||
createError(): GraphQLError;
|
||||
getDefaultComplexity(args: object, childScore: number): number;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { QueryComplexityOptions } from './QueryComplexity';
|
||||
export default function createQueryComplexityValidator(options: QueryComplexityOptions): () => void;
|
||||
@@ -0,0 +1,4 @@
|
||||
import QueryComplexity from "graphql-query-complexity/dist/QueryComplexity";
|
||||
|
||||
const complexity = new QueryComplexity(null as any, null as any);
|
||||
complexity.createError().message; // $ExpectType string
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for graphql-query-complexity 0.1
|
||||
// Project: https://github.com/ivome/graphql-query-complexity
|
||||
// Definitions by: Abhik Mitra <https://github.com/abhikmitra>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
import createQueryComplexityValidator from "./dist";
|
||||
export default createQueryComplexityValidator;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"dist/index.d.ts",
|
||||
"dist/QueryComplexity.d.ts",
|
||||
"graphql-query-complexity-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user