-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.py
47 lines (41 loc) · 1.34 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import strawberry
import strawberry.tools
from graphql_sync_dataloaders import DeferredExecutionContext
from strawberry.extensions import MaxAliasesLimiter, MaxTokensLimiter, QueryDepthLimiter
from strawberry_django.optimizer import DjangoOptimizerExtension
from server.app.authentication.graph import mutations as auth_mutations
from server.app.authentication.graph import queries as auth_queries
from server.app.blog.graph import mutations as blog_mutations
from server.app.blog.graph import queries as blog_queries
from server.app.blog.graph import subscriptions as blog_subscriptions
__all__ = ("schema",)
query = strawberry.tools.merge_types(
"Query",
(
blog_queries.Query,
auth_queries.Query,
),
)
mutation = strawberry.tools.merge_types(
"Mutation",
(
blog_mutations.Mutation,
auth_mutations.Mutation,
),
)
subscription = strawberry.tools.merge_types(
"Subscription",
(blog_subscriptions.Subscription,),
)
schema = strawberry.Schema(
query=query,
mutation=mutation,
execution_context_class=DeferredExecutionContext,
extensions=[
DjangoOptimizerExtension(),
QueryDepthLimiter(max_depth=10),
MaxTokensLimiter(max_token_count=1000),
MaxAliasesLimiter(max_alias_count=5),
],
)
ws_schema = strawberry.Schema(query=query, subscription=subscription)