Skip to main content

Generate GraphQL Schemas from your SQLAlchemy models

Project description

graphql-sqlalchemy

PyPI version Build Status codecov Code Style

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphql-sqlalchemy-0.6.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

graphql_sqlalchemy-0.6.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file graphql-sqlalchemy-0.6.1.tar.gz.

File metadata

  • Download URL: graphql-sqlalchemy-0.6.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.7 Darwin/20.3.0

File hashes

Hashes for graphql-sqlalchemy-0.6.1.tar.gz
Algorithm Hash digest
SHA256 364a873a94285d136aaf0c4e8b48cc3de9f50cb45cbfa107df6e01ab28a26abc
MD5 315e9ee1e3fcf79adf1f7aae0efc8c3a
BLAKE2b-256 1f2ecde85d2a9fffdf4b2a88527a3887a0ab90f00ef72442871d1db186eb31f3

See more details on using hashes here.

File details

Details for the file graphql_sqlalchemy-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for graphql_sqlalchemy-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec77fa884ddc186d99eb6a8fe849acce4a3c8b4d99780553073fcf6360a3cf47
MD5 3d78e067af6adf3c37bccf825c38e416
BLAKE2b-256 0fe74c4a75c26c7e7ea84c0151438deee25a306b744edf9371e550702e4eefeb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page