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
Welcome to GraphQL-Complexity! This Python library provides functionality to compute the complexity of a GraphQL operation, contributing to better understanding and optimization of your GraphQL APIs. This library is designed to be stable, robust, and highly useful for developers working with GraphQL.
| oneField |`5`| Complexity given by `@complexity(value: 5)`|
140
-
| otherField |`1`| Complexity given by `@complexity(value: 1)`|
141
-
| withoutDirective |`1`| The default complexity for fields without directive is `1`, this can be modified by parameters. |
142
-
143
-
And the total complexity is `7`.
144
-
145
110
### Custom estimator
146
-
This option allows to define a custom estimator to compute the complexity of a field using the `ComplexityEstimator` interface. For example:
111
+
Custom estimators can be defined to compute the complexity of a field using the `ComplexityEstimator` interface.
147
112
148
113
```python
149
114
from graphql_complexity import ComplexityEstimator
@@ -157,24 +122,24 @@ class CustomEstimator(ComplexityEstimator):
157
122
```
158
123
159
124
160
-
## Supported libraries (based on GraphQL-core)
125
+
## Supported libraries
161
126
This library is compatible with the following GraphQL libraries:
162
127
163
-
### Strawberry
128
+
### Strawberry GraphQL
164
129
165
130
The library is compatible with [strawberry-graphql](https://pypi.org/project/strawberry-graphql/).
166
-
To use the library with strawberry-graphql, you need to install the library with the `strawberry-graphql` extra.
131
+
Use the following command to install the library with Strawberry support:
132
+
167
133
```shell
168
134
poetry install --extras strawberry-graphql
169
135
```
170
136
171
-
To use the library with [strawberry-graphql](https://pypi.org/project/strawberry-graphql/), you need to use the `build_complexity_extension` method to build
172
-
the complexity extension and add it to the schema. This method receives an estimator and returns a complexity
173
-
extension that can be added to the schema.
137
+
To use the library with Strawberry GraphQL, use the `build_complexity_extension` method to build the complexity
138
+
extension and add it to the schema. This method receives an estimator and returns a complexity extension that can be added to the schema.
174
139
175
140
```python
176
141
import strawberry
177
-
from graphql_complexity.estimatorsimport SimpleEstimator
142
+
from graphql_complexity import SimpleEstimator
178
143
from graphql_complexity.extensions.strawberry_graphql import build_complexity_extension
0 commit comments