Skip to main content

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")

Download files

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

Source Distribution

sqlalchemy-graphql-schemagen-1.0.3.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_graphql_schemagen-1.0.3-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy-graphql-schemagen-1.0.3.tar.gz.

File metadata

  • Download URL: sqlalchemy-graphql-schemagen-1.0.3.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0

File hashes

Hashes for sqlalchemy-graphql-schemagen-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e11edef500605e2ff709221c90f322c8cece4c503bb268b5c3708845b149a7ec
MD5 2bc91990765ee470acc77124d00c8f27
BLAKE2b-256 5626129bd74950043c6385d3490eb1f3b494b2817b633e27a118e3f00247a515

See more details on using hashes here.

File details

Details for the file sqlalchemy_graphql_schemagen-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemy_graphql_schemagen-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0

File hashes

Hashes for sqlalchemy_graphql_schemagen-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 77fb4b6dfc688c12b9b5e540d56ac5cd9d27e7f0a7ac59815959de2f484fd05c
MD5 cfc6afdecea8c7fd4fca48bdf28faefb
BLAKE2b-256 03e2d1e54f3e5dfd46adcb9ee678a64c1d6e52b89c0f72924a94bd5ff1413335

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

This release

1.0.3 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page