File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,9 @@ import { GraphQLDirective } from 'graphql/type/directives';
4
4
import { DirectiveLocation } from 'graphql/language/directiveLocation' ;
5
5
import get from 'lodash.get' ;
6
6
7
- export default function ( options ?: { } ) : ComplexityEstimator {
8
- const mergedOptions = {
9
- name : 'complexity' ,
10
- ...( options || { } )
11
- } ;
12
-
13
- const directive = new GraphQLDirective ( {
14
- name : mergedOptions . name ,
7
+ export function complexityDirective ( name : string = 'complexity' ) {
8
+ return new GraphQLDirective ( {
9
+ name,
15
10
description : 'Define a relation between the field and other nodes' ,
16
11
locations : [
17
12
DirectiveLocation . FIELD ,
@@ -26,6 +21,10 @@ export default function (options?: {}): ComplexityEstimator {
26
21
}
27
22
} ,
28
23
} ) ;
24
+ }
25
+
26
+ export default function ( options : { name ?: string } = { } ) : ComplexityEstimator {
27
+ const directive = complexityDirective ( options . name ) ;
29
28
30
29
return ( args : ComplexityEstimatorArgs ) => {
31
30
// Ignore if astNode is undefined
Original file line number Diff line number Diff line change 1
1
export { default as simpleEstimator } from './simple' ;
2
- export { default as directiveEstimator } from './directive' ;
2
+ export { default as directiveEstimator , complexityDirective } from './directive' ;
3
3
export { default as fieldExtensionsEstimator } from './fieldExtensions' ;
You can’t perform that action at this time.
0 commit comments