-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
main.py
44 lines (37 loc) · 1.09 KB
/
main.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
from fastapi import Depends, FastAPI
from strawberry import Schema
from strawberry.fastapi import GraphQLRouter
from configs.Environment import get_environment_variables
from configs.GraphQL import get_graphql_context
from metadata.Tags import Tags
from models.BaseModel import init
from routers.v1.AuthorRouter import AuthorRouter
from routers.v1.BookRouter import BookRouter
from schemas.graphql.Query import Query
from schemas.graphql.Mutation import Mutation
# Application Environment Configuration
env = get_environment_variables()
# Core Application Instance
app = FastAPI(
title=env.APP_NAME,
version=env.API_VERSION,
openapi_tags=Tags,
)
# Add Routers
app.include_router(AuthorRouter)
app.include_router(BookRouter)
# GraphQL Schema and Application Instance
schema = Schema(query=Query, mutation=Mutation)
graphql = GraphQLRouter(
schema,
graphiql=env.DEBUG_MODE,
context_getter=get_graphql_context,
)
# Integrate GraphQL Application to the Core one
app.include_router(
graphql,
prefix="/graphql",
include_in_schema=False,
)
# Initialise Data Model Attributes
init()