Modelresolvers structures your GraphQL project by feature instead of operation type such as query and mutation to manage it easier
Project description
modelresolvers
modelresolvers is a python grapqhl package(inspired by type-graphql) on top of strawberry to structure your project by feature(model) instead of operation type(mutation and query) to manage it easier.
Requirement
python3.10 and above
Install by the following command
pip install modelresolvers
Documentation: https://cikay.github.io/modelresolvers/
Examples
Put the following example to main.py
import strawberry
from modelresolvers import ModelResolvers, Schema
user_resolvers = ModelResolvers()
@strawberry.type
class User:
firstname: str
lastname: str
users = [
User(firstname="John", lastname="Doe"),
User(firstname="Jahe", lastname="Doe"),
]
@user_resolvers.query(name="user")
def user() -> User:
return users[0]
@user_resolvers.mutation(name="add_user")
def add_user(firstname: str, lastname: str) -> User:
user = User(firstname=firstname, lastname=lastname)
users.append(user)
return user
schema = Schema(models_resolvers=[user_resolvers]).strawberry_schema
Run strawberry server main
Go to http://0.0.0.0:8000/graphql and try your mutations and queries.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelresolvers-0.2.2.tar.gz.
File metadata
- Download URL: modelresolvers-0.2.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.2 Linux/6.2.0-1012-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d914b8db09af9fe6dd7fe22cac817fb655e8e92bfab5bc4c5330f644005c5594
|
|
| MD5 |
1e908ebbbfd257d11243e815ba1e3c56
|
|
| BLAKE2b-256 |
a37c49b523a8510aa35178e27bec4ed0ca88194470a543564e315c4812fff47d
|
File details
Details for the file modelresolvers-0.2.2-py3-none-any.whl.
File metadata
- Download URL: modelresolvers-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.2 Linux/6.2.0-1012-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
563d14cc751c51cb01cab6b90db30ab1a0541d79ad04841bcb9309cca9ded8af
|
|
| MD5 |
f6ce5e1c4bb738ea8602bed653fc29da
|
|
| BLAKE2b-256 |
208d8ddc71fcbca24da072254f8e433672caf98bf909c43523ac2671ef4a7c72
|