@graphql-inspector/core 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/index.d.ts +7 -2
- package/index.js +248 -94
- package/index.mjs +245 -96
- package/package.json +1 -1
- package/validate/alias-count.d.ts +10 -0
- package/validate/complexity.d.ts +16 -0
- package/validate/directive-count.d.ts +10 -0
- package/validate/index.d.ts +17 -2
- package/validate/query-depth.d.ts +2 -1
- package/validate/token-count.d.ts +12 -0
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }: {
|
|
5
|
+
source: Source;
|
|
6
|
+
doc: DocumentNode;
|
|
7
|
+
maxAliasCount: number;
|
|
8
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
9
|
+
}): GraphQLError | void;
|
|
10
|
+
export declare function countAliases(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare type CalculateOperationComplexityConfig = {
|
|
5
|
+
scalarCost: number;
|
|
6
|
+
objectCost: number;
|
|
7
|
+
depthCostFactor: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function validateComplexity({ source, doc, maxComplexityScore, config, fragmentGraph, }: {
|
|
10
|
+
source: Source;
|
|
11
|
+
doc: DocumentNode;
|
|
12
|
+
maxComplexityScore: number;
|
|
13
|
+
config: CalculateOperationComplexityConfig;
|
|
14
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
15
|
+
}): GraphQLError | void;
|
|
16
|
+
export declare function calculateOperationComplexity(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, config: CalculateOperationComplexityConfig, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined, depth?: number): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph, }: {
|
|
5
|
+
source: Source;
|
|
6
|
+
doc: DocumentNode;
|
|
7
|
+
maxDirectiveCount: number;
|
|
8
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
9
|
+
}): GraphQLError | void;
|
|
10
|
+
export declare function countDirectives(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined): number;
|
package/validate/index.d.ts
CHANGED
|
@@ -26,9 +26,24 @@ export interface ValidateOptions {
|
|
|
26
26
|
*/
|
|
27
27
|
apollo?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
* Fails when operation depth exceeds maximum depth
|
|
30
|
-
* @default
|
|
29
|
+
* Fails when operation depth exceeds maximum depth (including the referenced fragments).
|
|
30
|
+
* @default Infinity
|
|
31
31
|
*/
|
|
32
32
|
maxDepth?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Fails when alias count exceeds maximum count (including the referenced fragments).
|
|
35
|
+
* @default Infinity
|
|
36
|
+
*/
|
|
37
|
+
maxAliasCount?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Fails when the directive count exceeds maximum count for a single operation (including the referenced fragments).
|
|
40
|
+
* @default Infinity
|
|
41
|
+
*/
|
|
42
|
+
maxDirectiveCount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Fails when the token count exceeds maximum count for a single operation (including the referenced fragments).
|
|
45
|
+
* @default Infinity
|
|
46
|
+
*/
|
|
47
|
+
maxTokenCount?: number;
|
|
33
48
|
}
|
|
34
49
|
export declare function validate(schema: GraphQLSchema, sources: Source[], options?: ValidateOptions): InvalidDocument[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DepGraph } from 'dependency-graph';
|
|
2
|
-
import { DocumentNode, GraphQLError, ASTNode, FragmentDefinitionNode, Source } from 'graphql';
|
|
2
|
+
import { DocumentNode, GraphQLError, ASTNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
3
|
export declare function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }: {
|
|
4
4
|
source: Source;
|
|
5
5
|
doc: DocumentNode;
|
|
@@ -12,3 +12,4 @@ export declare function calculateDepth({ node, currentDepth, maxDepth, getFragme
|
|
|
12
12
|
maxDepth?: number;
|
|
13
13
|
getFragment: (fragmentName: string) => FragmentDefinitionNode;
|
|
14
14
|
}): number | never;
|
|
15
|
+
export declare function countDepth(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, parentDepth: number, getFragmentReference: (name: string) => FragmentDefinitionNode | undefined): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
+
import type { Source } from 'graphql';
|
|
3
|
+
export declare function calculateTokenCount(args: {
|
|
4
|
+
source: Source | string;
|
|
5
|
+
getReferencedFragmentSource: (fragmentName: string) => Source | string | undefined;
|
|
6
|
+
}): number;
|
|
7
|
+
export declare function validateTokenCount(args: {
|
|
8
|
+
source: Source;
|
|
9
|
+
document: DocumentNode;
|
|
10
|
+
getReferencedFragmentSource: (fragmentName: string) => Source | string | undefined;
|
|
11
|
+
maxTokenCount: number;
|
|
12
|
+
}): GraphQLError | void;
|