You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,7 +113,7 @@ app.use(
113
113
114
114
## <aname="lists"></a> Notes on Lists
115
115
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.
117
117
118
118
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.
119
119
@@ -124,31 +124,32 @@ The complexity for list types is not determined by the schema, but by the variba
124
124
125
125
Rate-limiting is done by IP address.
126
126
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.
128
128
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.
130
130
131
131
If a user sends two request simustaneously, the trailing request will wait for the first one to complete any asyncronous work before being processed.
1. Blocked Requests: blocked requests recieve a response with,
@@ -162,7 +163,7 @@ query { // 1
162
163
```javascript
163
164
{
164
165
graphglGate: {
165
-
success: boolean, // true
166
+
success: boolean, // true when successful
166
167
tokens: number, // tokens available after request
167
168
compexity: number, // complexity of the query
168
169
depth: number, // depth of the query
@@ -173,15 +174,15 @@ query { // 1
173
174
174
175
## <aname="error-handling"></a> Error Handling
175
176
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.
177
178
- 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.
178
179
179
180
## <aname="future-development"></a> Future Development
180
181
181
182
- the ability to use this package with other caching technologies or libraries
182
183
- implement "resolve complexity analysis" for queries
183
184
- implement leaky bucket algorithm for rate-limiting
184
-
-experimint with performance improvments
185
+
-experiment with performance improvements
185
186
- caching optimization
186
187
- ensure connection pagination conventions can be accuratly acconuted for in comprlexity analysis
0 commit comments