Skip to content

Commit 77d7db5

Browse files
authored
Update README.md
proof read and corrected mistakes
1 parent 095e276 commit 77d7db5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ app.use(
113113

114114
## <a name="lists"></a> Notes on Lists
115115

116-
The complexity for list types is not determined by the schema, but by the varibales passed to the field as slicing arguments or by directives
116+
The complexity for list types can be set in the schema with the use of directives, or in the query by the varibales passed to the field as slicing arguments.
117117

118118
1. Slicing arguments: lists must be bounded by one integer slicing argument in order to calculate the comlexity 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

@@ -124,31 +124,32 @@ The complexity for list types is not determined by the schema, but by the variba
124124

125125
Rate-limiting is done by IP address.
126126

127-
On server start, the GraphQL (GQL) schema is parsed to build an object that maps GQL types/feilds to values corresponding to the weights assigned to each GQL type/field. This object is used internally to cross refernce the fields queried by the user with the weight to apply that field when totaling the overall complexity of the query.
127+
On server start, the GraphQL (GQL) schema is parsed to build an object that maps GQL types/fields to values corresponding to the weights assigned to each GQL type/field. This object is used internally to cross reference the fields queried by the user with the weight to apply that field when totaling the overall complexity of the query.
128128

129-
For each request, the query is parsed and traversed to total the overall complexity of the query based on the type/field weights configured on setup. This is done statically, before any resolvers are fired, to estimate the upper bound of response size of the request (a proxy for the work done by the server to build the response). The total complexity is then used to allow/block the request based on popular rate-limiting algorithms.
129+
For each request, the query is parsed and traversed to total the overall complexity of the query based on the type/field weights configured on setup. This is done statically (before any resolvers are called) to estimate the upper bound of response size of the request - a proxy for the work done by the server to build the response. The total complexity is then used to allow/block the request based on popular rate-limiting algorithms.
130130

131131
If a user sends two request simustaneously, the trailing request will wait for the first one to complete any asyncronous work before being processed.
132132

133133
Example (with default weights):
134134

135135
```javascript
136136
query { // 1
137-
hero (episode: EMPIRE) { // 1, total complexity: 1 (hero) + 3 (friends) = 4
137+
hero (episode: EMPIRE) { // 1
138138
name // 0
139139
id // 0
140140
friends (first: 3) { // 3
141141
name // 0
142142
id // 0
143143
}
144144
}
145-
reviews(episode: EMPIRE, first: 5) { // 5
145+
reviews(episode: EMPIRE, limit: 5) { // 5
146146
stars // stars 0
147147
commentary // commentary 0
148148
}
149149
}
150-
// total complexity 10
150+
// total complexity of 10
151151
```
152+
152153
## <a name="response"></a> Response
153154

154155
1. Blocked Requests: blocked requests recieve a response with,
@@ -162,7 +163,7 @@ query { // 1
162163
```javascript
163164
{
164165
graphglGate: {
165-
success: boolean, // true
166+
success: boolean, // true when successful
166167
tokens: number, // tokens available after request
167168
compexity: number, // complexity of the query
168169
depth: number, // depth of the query
@@ -173,15 +174,15 @@ query { // 1
173174

174175
## <a name="error-handling"></a> Error Handling
175176

176-
- Incoming queries are validated against the GraphQL schema. If the query is invalid, a response with status code `400` is returned along with the array of GraphQL Validation Errors that were found.
177+
- Incoming queries are validated against the GraphQL schema. If the query is invalid, a response with status code `400` is returned along with an array of GraphQL Errors that were found.
177178
- To avoid disrupting server activity, errors thrown during the analysis and rate-limiting of the query are logged and the request is passed onto the next middleware function in the chain.
178179

179180
## <a name="future-development"></a> Future Development
180181

181182
- the ability to use this package with other caching technologies or libraries
182183
- implement "resolve complexity analysis" for queries
183184
- implement leaky bucket algorithm for rate-limiting
184-
- experimint with performance improvments
185+
- experiment with performance improvements
185186
- caching optimization
186187
- ensure connection pagination conventions can be accuratly acconuted for in comprlexity analysis
187188

0 commit comments

Comments
 (0)