Skip to content

Commit 52ce7ec

Browse files
authored
Update README.md
updated graphql complexity example
1 parent d347630 commit 52ce7ec

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ For queries that return a list, the complexity can be determined by providing a
117117

118118
1. Slicing arguments: lists must be bounded by one integer slicing argument in order to calculate the complexity for the field. This package supports the slicing arguments `first`, `last` and `limit`. The complexity of the list will be the value passed as the argument to the field.
119119

120-
2. Directives: First, `@listCost` must be defined in your schema with `directive @listCost(cost: Int!) on FIELD_DEFINITION`. Then, on any unbounded list field, add `@listCost(cost: Int)` and replace `Int` with the complexity you want applied whenever the list is queried.
120+
2. Directives: To use directives, `@listCost` must be defined in your schema with `directive @listCost(cost: Int!) on FIELD_DEFINITION`. Then, on any unbounded list field, add `@listCost(cost: <Int>)` where `<Int>` is the complexity you want applied to the list when queried.
121121

122122
(Note: Slicing arguments are preferred! `@listCost` is in place for any reason slicing arguments cannot be used.)
123123

@@ -133,22 +133,21 @@ Requests for each user are processed sequentially by the rate limiter.
133133

134134
Example (with default weights):
135135

136-
```javascript
137-
query { // 1 (complexity)
138-
hero (episode: EMPIRE) { // 1
139-
name // 0
140-
id // 0
141-
friends (first: 3) { // 3
142-
name // 0
143-
id // 0
136+
```graphql
137+
query { # 1 query
138+
hero (episode: EMPIRE) { # 1 object
139+
name # 0 scalar
140+
id # 0 scalar
141+
friends (first: 3) { # 3 objects
142+
name # 0 scalar
143+
id # 0 scalar
144144
}
145145
}
146-
reviews(episode: EMPIRE, limit: 5) { // 5
147-
stars // stars 0
148-
commentary // commentary 0
146+
reviews (episode: EMPIRE, limit: 5) { # 5 objects
147+
stars # 0 scalar
148+
commentary # 0 scalar
149149
}
150-
}
151-
// total complexity of 10
150+
} # total complexity of 10
152151
```
153152

154153
## <a name="response"></a> Response

0 commit comments

Comments
 (0)