File tree Expand file tree Collapse file tree 4 files changed +153
-141
lines changed Expand file tree Collapse file tree 4 files changed +153
-141
lines changed Original file line number Diff line number Diff line change 20
20
"lodash.get" : " ^4.4.2"
21
21
},
22
22
"peerDependencies" : {
23
- "graphql" : " ^0.13.2 "
23
+ "graphql" : " ^14.0.0 "
24
24
},
25
25
"files" : [
26
26
" dist" ,
37
37
"devDependencies" : {
38
38
"@types/assert" : " ^0.0.31" ,
39
39
"@types/chai" : " ^4.1.4" ,
40
- "@types/graphql" : " ^0.13.4 " ,
40
+ "@types/graphql" : " ^14.0.0 " ,
41
41
"@types/lodash.get" : " ^4.4.4" ,
42
42
"@types/mocha" : " ^5.2.5" ,
43
43
"chai" : " ^4.1.0" ,
44
44
"eslint" : " ^5.4.0" ,
45
45
"eslint-plugin-typescript" : " ^0.12.0" ,
46
- "graphql" : " ^0.13.2 " ,
46
+ "graphql" : " ^14.0.0 " ,
47
47
"mocha" : " ^5.2.0" ,
48
48
"rimraf" : " ^2.6.1" ,
49
49
"ts-node" : " ^7.0.1" ,
Original file line number Diff line number Diff line change @@ -25,6 +25,15 @@ const rule = queryComplexity({
25
25
Define your schema and add the complexity directive:
26
26
27
27
``` graphql
28
+ directive @complexity (
29
+ # The complexity value for the field
30
+ value : Int ! ,
31
+
32
+ # Optional multipliers
33
+ multipliers : [String ! ]
34
+ ) on FIELD_DEFINITION
35
+
36
+
28
37
type Query {
29
38
# Fixed complexity of 5
30
39
someField : String @complexity (value : 5 )
Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ import {
7
7
} from 'graphql' ;
8
8
9
9
export default buildSchema ( `
10
+ directive @cost(
11
+ value: Int!,
12
+ multipliers: [String!]
13
+ ) on FIELD_DEFINITION
14
+
15
+ directive @complexity(
16
+ value: Int!,
17
+ multipliers: [String!]
18
+ ) on FIELD_DEFINITION
19
+
10
20
type Query {
11
21
scalar: String @complexity(value: 5)
12
22
negativeCostScalar: String @complexity(value: -20)
You can’t perform that action at this time.
0 commit comments