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-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0580f77d262114f2ef4b42d1109c5520db786411441dd2c07fe872d55f9fa9fc |
|
MD5 | 836bf760250a83b071e69791c0e10ea7 |
|
BLAKE2b-256 | 5f6be45f75f045a0b1f3b2f966503063a7bb2b5def8afda682b996577761c0ef |
Close
Hashes for graphene_sqlalchemy_auto-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 297682c13eb1cbbd48c26238b987ae9d568d704f99921282dfbb7d40ed7e7979 |
|
MD5 | 6caa8a1a4fd21effd3a4ca939acf3ffe |
|
BLAKE2b-256 | 33fb9d70c4ad4d1f7f274bb5f91891c3feb082c03b1983e73d088f7f2654be14 |