-
-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix definitions, interfaces, types and tests isssues
- Loading branch information
1 parent
ac65c7a
commit a4b2289
Showing
13 changed files
with
89 additions
and
60 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,7 @@ | ||
import { Complexity } from "graphql-query-complexity"; | ||
|
||
declare module "graphql/type/definition" { | ||
export interface GraphQLFieldConfig<TSource, TContext, TArgs = { [argName: string]: any }> { | ||
complexity?: Complexity; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,35 +1,55 @@ | ||
|
||
declare module "graphql-query-complexity" { | ||
import {QueryComplexityOptions} from 'graphql-query-complexity/dist/QueryComplexity'; | ||
import QueryComplexity from 'graphql-query-complexity/dist/QueryComplexity'; | ||
import { ValidationContext } from 'graphql'; | ||
type returnType = (context: ValidationContext) => QueryComplexity ; | ||
export default function createQueryComplexityValidator(options: QueryComplexityOptions): returnType; | ||
import { ValidationContext } from "graphql"; | ||
import QueryComplexity, { | ||
QueryComplexityOptions, | ||
} from "graphql-query-complexity/dist/QueryComplexity"; | ||
|
||
export type ComplexityResolver = (args: any, complexity: number) => number; | ||
|
||
export type Complexity = number | ComplexityResolver; | ||
|
||
export default function createQueryComplexityValidator( | ||
options: QueryComplexityOptions, | ||
): (context: ValidationContext) => QueryComplexity; | ||
} | ||
|
||
declare module "graphql-query-complexity/dist/QueryComplexity" { | ||
import { ValidationContext, FragmentDefinitionNode, OperationDefinitionNode, FieldNode, InlineFragmentNode } from 'graphql'; | ||
import { 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; | ||
} | ||
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; | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
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
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