schema
api.schema.Query
Source code in api/schema.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
all_address(info, filter, page_size=10, page_number=1)
async
Query all addresses from database or all plugins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info |
Info
|
Strawberry default value to get context information in this case we use 'db' |
required |
filter |
AddressFilterInput
|
Strawberry input dataclass, everything can be None (based on sqlmodel model) |
required |
page_size |
PositiveInt
|
How many elements in each page. Defaults to 10. |
10
|
page_number |
PositiveInt
|
Number of the page. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
list[AddressType]
|
list[AddressType]: All addresses (db model converted to strawberry type) based on filter or empty list |
Source code in api/schema.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
api.schema.Mutation
Source code in api/schema.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
create_address(info, address)
async
Insert address and city if not exists on database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info |
Info
|
Strawberry default value to get context information in this case we use 'db' |
required |
address |
AddressInsertInput
|
Strict address class, almost all fields need to be passed |
required |
Returns:
Name | Type | Description |
---|---|---|
AddressType |
AddressType
|
Address (db model converted to strawberry dataclass) |
Source code in api/schema.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
api.schema.CustomContext
Bases: BaseContext
Source code in api/schema.py
103 104 105 106 |
|
__init__(session)
Generate context database session.
Source code in api/schema.py
104 105 106 |
|
api.schema.get_context(session)
async
Create database session to use when needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session |
Annotated[AsyncSession, Depends
|
get db session from get_session |
required |
Returns:
Name | Type | Description |
---|---|---|
CustomContext |
CustomContext
|
class that contains db session |
Source code in api/schema.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
api.schema.schema = Schema(query=Query, mutation=Mutation)
module-attribute
Create Graphql Router for fastapi and start graphql ide if env is DEV.