generate default graphene schema from sqlalchemy model base on graphene-sqlalchemy
Project description
generate default graphene schema from sqlalchemy model base on graphene-sqlalchemy
Installation
just run
pip install graphene_sqlalchemy_auto
Features
- auto add
offset
limit
totalCount
to pagination - auto add
dbId
for model's database id - mutation auto return ok for success,message for more information and output for model data
How To Use
example :
from graphene_sqlalchemy_auto import QueryObjectType,MutationObjectType
from sqlalchemy.ext.declarative import declarative_base
import graphene
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
Session = sessionmaker()
class Query(QueryObjectType):
class Meta:
declarative_base = Base
exclude_models = ["User"] # exclude models
class Mutation(MutationObjectType):
class Meta:
declarative_base = Base
session=Session() # mutate used
include_object = []# you can use yourself mutation UserCreateMutation, UserUpdateMutation
schema = graphene.Schema(query=Query, mutation=Mutation)
Query example
just equal
query{
userList(filters:{name: "a"}){
edges{
node{
name
id
dbId
}
}
}
}
OR support more expr
query{
userList(filters:[{key: "name",op: "==", val: "a"}]){
edges{
node{
name
id
dbId
}
}
}
}
op supports:
- ==
- !=
- >=
- <=
- >
- <
- starts
- ends
- contains
- in
- notin
- any
Mutation example
createUser(input:{name: "cc",password: "dd"}){
ok
output{
id
dbId
name
}
message
}
about Schema names
- model.class.name.lower : query a data by id
- model.class.name.decapitalize[first lower]+"List": query list
- create|update|delete+model.class.name : mutation data
about many-to-many mutation
now you can use schema everywhere.some like flask,fastapi
also more example you can find in example
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for graphene-sqlalchemy-auto-0.11.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c82df5d3c0e1ad701eed9ff839905255f4d147a1f53b1b715e082aece56938c8 |
|
MD5 | 234c003e252125c75a104732cf172d6e |
|
BLAKE2b-256 | 95d8300111cb5e8dbae984e96760574d055ac1e90df9955f5b0a42b95aead10f |
Close
Hashes for graphene_sqlalchemy_auto-0.11.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b391ca80a08b4f17492ca6cfceeef5408d47d39f9902fb209274c0f79d7f062 |
|
MD5 | d7bdf298d7fca68711db34eeb9ffc60b |
|
BLAKE2b-256 | 9622fc041061f75201b4c86dc4a6416e75259e2f172b5590c6b9e39ea3eb582a |