sqlalchemy-graphql-schemagen
Generate a full (query/mutation) GraphQL Schema from your defined classes in a declarative_meta() Model.
Example
#!/usr/bin/env python
from flask import Flask
from flask_graphql import GraphQLView
from sqlalchemy import create_engine
from medgraphqlapi import generate_custom_column_docstrings
from sqlalchemy_graphql_schemagen import SQLAlchemyGraphQLSchemaGenerator
from medgraphqlapi.database_schema import Base as sa_base_declarative
################################
# SQLAlchemy Stuff
################################
sa_connection_string = "mssql+pyodbc://XXXXXXXXXXXX"
# Create the Engine
sa_engine = create_engine(sa_connection_string)
# Generate more useful columns' docstrings (ex.: type length, collation, ...)
generate_custom_column_docstrings(sa_base_declarative)
################################
# Build a GraphQL Schema from the SQLAlchemy Schema, using sqlalchemy_graphql_schemagen!
################################
graphql_schema = SQLAlchemyGraphQLSchemaGenerator(
"ApiName",
sa_base_declarative,
sa_connection_string=sa_connection_string,
).get_graphene_schema()
################################
# Instantiate Flask App
################################
app = Flask(__name__)
# Plug GraphQLView
app.add_url_rule("/graphql",
view_func=GraphQLView.as_view("graphql",
schema=graphql_schema,
graphiql=True))
# That's it!
if __name__ == "__main__":
app.run(host="0.0.0.0")
Metadata
Release files for sqlalchemy-graphql-schemagen 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sqlalchemy-graphql-schemagen-1.0.6.tar.gz | 13.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlalchemy_graphql_schemagen-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.8 kB
Release files / sqlalchemy-graphql-schemagen-1.0.6.tar.gz
| Download URL | sqlalchemy-graphql-schemagen-1.0.6.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52855725c0b3bae4d0e815635feaadac5120caadbd0fc687c6a1140c076c0fd8
|
|
BLAKE2b-256 checksum How to use checksums |
00b7d4854ffca378a2a65d1444f84963703486ce744f3e57a3e0d01d5b3a45c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.0
|
Release files / sqlalchemy_graphql_schemagen-1.0.6-py3-none-any.whl
| Download URL | sqlalchemy_graphql_schemagen-1.0.6-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
359e2b3dd04cb2d4be30990a045cbd5c7806e266197b6d343fe707c7f79736a8
|
|
BLAKE2b-256 checksum How to use checksums |
42a24fc28cb0fcf9e96f7640fb0f4431c95fb97cf054596ccb0a0c526f885c67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.0
|