Metadata-Version: 2.1
Name: graphql-sqlalchemy
Version: 0.6.1
Summary: Generate GraphQL Schemas from your SQLAlchemy models
Home-page: https://github.com/gzzo/graphql-sqlalchemy
License: MIT
Keywords: graphql,sqlalchemy
Author: Guido Rainuzzo
Author-email: hi@guido.nyc
Requires-Python: >=3.6.0,<4
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Provides-Extra: docs
Requires-Dist: SQLAlchemy (>=1.3.0,<2.0.0)
Requires-Dist: graphql-core (>=3.0.0,<4)
Requires-Dist: pygments-graphql (>=1.0.0,<2.0.0); extra == "docs"
Requires-Dist: pygments-style-solarized (>=0.1.1,<1.0.0); extra == "docs"
Requires-Dist: sphinx (>=3.5.3,<4.0.0); extra == "docs"
Requires-Dist: sphinx-rtd-theme (>=0.5.1,<1.0.0); extra == "docs"
Project-URL: Repository, https://github.com/gzzo/graphql-sqlalchemy
Description-Content-Type: text/markdown

# graphql-sqlalchemy

[![PyPI version](https://badge.fury.io/py/graphql-sqlalchemy.svg)](https://badge.fury.io/py/graphql-sqlalchemy)
[![Build Status](https://travis-ci.com/gzzo/graphql-sqlalchemy.svg?branch=master)](https://travis-ci.com/gzzo/graphql-sqlalchemy)
[![codecov](https://codecov.io/gh/gzzo/graphql-sqlalchemy/branch/master/graph/badge.svg)](https://codecov.io/gh/gzzo/graphql-sqlalchemy)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

Generate GraphQL Schemas from your SQLAlchemy models

# Install
```
pip install graphql-sqlalchemy
```

# Usage

```python
    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

```graphql
query {
    user(
        where: {
            _or: [
                { id: { _gte: 5 } },
                { name: { _like: "%bob%" } },
            ]
        }
    ) {
        id
        name
    }
    user_by_pk(id: 5) {
        createtime
    }
}
```

