Generate GraphQL Schemas from your SQLAlchemy models
Project description
graphql-sqlalchemy
Generate GraphQL Schemas from your SQLAlchemy models
Install
pip install graphql-sqlalchemy
Usage
from ariadne.asgi import GraphQL
from fastapi import FastAPI
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from graphql_sqlalchemy import build_schema
engine = create_engine('sqlite:///config.db')
Base = declarative_base()
Session = sessionmaker(bind=engine)
app = FastAPI()
session = Session()
schema = build_schema(Base)
app.mount("/graphql", GraphQL(schema, context_value=dict(session=session)))
Query
query {
user(
where: {
_or: [
{ id: { _gte: 5 } },
{ name: { _like: "%bob%" } },
]
}
) {
id
name
}
user_by_pk(id: 5) {
createtime
}
}
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 graphql_sqlalchemy-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec77fa884ddc186d99eb6a8fe849acce4a3c8b4d99780553073fcf6360a3cf47 |
|
MD5 | 3d78e067af6adf3c37bccf825c38e416 |
|
BLAKE2b-256 | 0fe74c4a75c26c7e7ea84c0151438deee25a306b744edf9371e550702e4eefeb |