Example #1
0
def get_test_app():
    app = Flask(__name__)
    app.debug = True

    app.add_url_rule('/graphql', 'graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
    app.add_url_rule('/', 'index', view_func=index_view,)
    return app
Example #2
0
def register_blueprints(app):
    for name in find_modules('blog.views'):
        mod = import_string(name)
        if hasattr(mod, 'bp'):
            app.register_blueprint(mod.bp)
    app.add_url_rule('/graphql', view_func=GraphQLView.as_view(
        'graphql', schema=schema, graphiql=True))
Example #3
0
def create_app():
    app = Flask(__name__)

    app.add_url_rule(
        '/sale_point',
        view_func=GraphQLView.as_view(
            'sale_point',
            schema=sale_point_schema,
            graphiql=True
        )
    )

    return app
Example #4
0
#     config.read('o11y.ini')
#     beeline.init(writekey=config['DEFAULT']['honeycomb_key'], dataset='RPG Simulation', service_name='graghql_backend')

app = Flask(__name__)

# if path.exists():
#     # db_events defaults to True, set to False if not using our db middleware with Flask-SQLAlchemy
#     HoneyMiddleware(app, db_events=True)

app.debug = True

app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True  # for having the GraphiQL interface
    ))
# /graphql-mutation
app.add_url_rule('/createCharacter',
                 view_func=GraphQLView.as_view('create-character',
                                               schema=schema_mutation,
                                               graphiql=True))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


if __name__ == '__main__':
Example #5
0
def task_detail_wrapper():
    view = GraphQLView.as_view("task_detail",
                               schema=graphene.Schema(query=TaskDetailQuery),
                               graphiql=True)
    return sensible_token(view)
Example #6
0
#!/usr/bin/env bash
import pytest
from flask_graphql import GraphQLView
from flask_graphql_auth import GraphQLAuth
from flask_migrate import MigrateCommand
from flask_script import Manager, Server
from app import create_app, db
from app.schema import schema

app = create_app()
auth = GraphQLAuth(app)

app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view('graphql',
                                               schema=schema,
                                               graphiql=True))
manager = Manager(app, db)
manager.add_command('db', MigrateCommand)
manager.add_command('server', Server)

if __name__ == '__main__':
    manager.run()
Example #7
0
##

from flask import Flask, send_from_directory, make_response, send_file
from flask_graphql import GraphQLView
from .schema import schema
from zeromq import ZeroClient
from os import getcwd

# Instancia
apiServer = Flask(__name__)

#GraphQL
apiServer.add_url_rule('/graphqlTesting',
                       view_func=GraphQLView.as_view(
                           'graphqlTesting',
                           schema=schema,
                           graphiql=True,
                           context={'aggClient': ZeroClient('apiServer')}))


# Screenshoty z testov
@apiServer.route('/screenshot/<path:path>')
def screenshotResult(path):
    return send_from_directory('../screenshot/', path)


# Generovane klientske skripty
@apiServer.route('/client/<file>')
def clientScript(file):
    response = make_response(send_file('../client/' + file))
    response.headers[
Example #8
0
from flask import jsonify, Blueprint, request
from flask_login import login_required, current_user
from flask_graphql import GraphQLView

from rr.db import db
import rr.queries as q
import rr.jobs as jobs
import rr.events as e
from rr.schema import schema

routes = Blueprint('routes', __name__)


    # Optional, for adding batch query support (used in Apollo-Client)
routes.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

@routes.route('/prompts')
def prompt():
    prompts = q.get_prompts()
    return jsonify(
        {prompt.date.isoformat(): prompt
         for prompt in prompts.all()})


@routes.route('/compositions', methods=['POST'])
@login_required
def create_composition_route():
    payload = request.json
    composition = q.create_composition(
        prompt_id=payload['prompt_id'],
Example #9
0
from schema import schema
from template import render_graphiql

app = Flask(__name__)
app.debug = True
sockets = Sockets(app)


@app.route("/graphiql")
def graphql_view():
    return make_response(render_graphiql())


app.add_url_rule(
    "/graphql", view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=False)
)

subscription_server = GeventSubscriptionServer(schema)
app.app_protocol = lambda environ_path_info: "graphql-ws"


@sockets.route("/subscriptions")
def echo_socket(ws):
    subscription_server.handle(ws)
    return []


if __name__ == "__main__":
    from gevent import pywsgi
    from geventwebsocket.handler import WebSocketHandler
Example #10
0
DOCKER_SOCK = str(cf.get('docker', 'sockpath'))
MAX_LIFE = int(cf.get('docker', 'maxlife'))
PASSWD = str(cf.get('docker', 'password'))
#threadPool = ThreadPoolExecutor(max_workers=MAX_CONTAINER)
session = sqlsession.session

models.Base.metadata.create_all(sqlsession.engine)

app = Flask(__name__)
cors = CORS(app)

webhook = Webhook(app)  # Defines '/postreceive' endpoint
app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view(
                     'graphql',
                     schema=schema.dataschema,
                     graphiql=True,
                     get_context=lambda: {'session': session}))

client = docker.Client(base_url=DOCKER_SOCK)


def operate_proj(git, commit, gittime, committer, message):
    exist, buildId, projId, name = buildProj.build(git, commit, gittime,
                                                   committer, message)
    #print(exist,buildId,projId,name)
    if exist == True:
        pass
    else:
        print("%s threading is printed %s, %s" %
              (threading.current_thread().name, git, commit))
Example #11
0
def init_service(service, schema):
    """ Add GraphQL support to the given Flask app """
    # add default graphql endpoints
    GraphQL(service.app, schema=schema)
    # add the index query per service agreement
    service.app.add_url_rule('/', view_func=GraphQLView.as_view('index', schema=schema))
Example #12
0
def init_views():
    from photogal.graphql import schema
    enable_graphiql = app.env == 'development'
    app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=enable_graphiql))
    app.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view('graphql-batch', schema=schema, batch=True))
Example #13
0

def honeycomb_middleware(next, root, info, **args):
    with beeline.tracer(name="graphql_execute"):
        beeline.add_context({
            "graphql.parent_type":
            root._meta.name if root and hasattr(root, "_meta") else "",
            "graphql.field_name":
            info.field_name,
            "graphql.args":
            args,
        })
        return next(root, info, **args)


app.add_url_rule(
    "/graphql",
    view_func=GraphQLView.as_view(
        "graphql",
        schema=schema,
        root_value=splitter,
        graphiql=True,
        middleware=[honeycomb_middleware],
    ),
)

atexit.register(beeline.close)

if __name__ == "__main__":
    app.run(host="0.0.0.0")
Example #14
0
from flask import Flask

from database import db_session
from flask_graphql import GraphQLView
from schema import schema

app = Flask(__name__)
app.debug = True

app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True, context={'session': db_session}))

@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()

if __name__ == '__main__':
    app.run()
                  )
                GROUP BY
                  file.project
                ORDER BY
                  total_downloads DESC
                LIMIT 250
            """):
                p = Package()
                p.name = project
                p.recent_downloads = downloads
                yield p

        return list(gen())


schema = graphene.Schema(query=Query)

app.add_url_rule('/',
                 view_func=GraphQLView.as_view('graphql',
                                               schema=schema,
                                               graphiql=True))

# Optional, for adding batch query support (used in Apollo-Client)
app.add_url_rule('/batch',
                 view_func=GraphQLView.as_view('graphql_batch',
                                               schema=schema,
                                               batch=True))

if __name__ == '__main__':
    # common.serve()
    app.run()
Example #16
0
    ):  #this is a function that gets called when message property is requested
        return 'My first project'

    def resolve_name(self, info):
        return 'hello'


#gschema=graphene.Schema(query=QuerySample) #create graphene schema(graphql schema) from class QuerySample

# end static query

# Flask Rest & Graphql Routes
app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view(
                     'graphql',
                     schema=tableSchema,
                     graphiql=True,
                 ))


@app.route('/')
def root():
    return render_template("index.html")


#@app.route('/app.js')
#def script():
#   return render_template("app.js")

if __name__ == '__main__':
    app.run()
Example #17
0
import os

from gevent import monkey
from flask import Flask
from flask_graphql import GraphQLView
from graphql.execution.executors.gevent import GeventExecutor

from graphene import Schema

from schema import Query

monkey.patch_all()

view_func = GraphQLView.as_view('graphql',
                                schema=Schema(query=Query),
                                executor=GeventExecutor(),
                                graphiql=True)

app = Flask(__name__)
app.add_url_rule('/graphql', view_func=view_func)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=os.environ.get('PORT', 5000))
Example #18
0
from database.base import db_session
from flask import Flask
from flask_graphql import GraphQLView
from schema import schema

app = Flask(__name__)
app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


if __name__ == '__main__':
    app.run(threaded=True)  # debug=True
Example #19
0
def create_graphql_route(app):
    app.add_url_rule('/graphql/', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
Example #20
0
from flask import Flask
from flask_graphql import GraphQLView
from graphene import Schema

from com.tutorial.schema.user import User

view_func = GraphQLView.as_view('graphql', schema=Schema(query=User))

app = Flask(__name__)

app.add_url_rule('/', view_func=view_func)

if __name__ == '__main__':
    app.run()
Example #21
0
 def _add_url_rules(self):
     self.blueprint.add_url_rule('/', view_func=self.index_view)
     self.blueprint.add_url_rule('/<path:path>', view_func=self.index_view)
     self.blueprint.add_url_rule('/graphql',
                                 view_func=GraphQLView.as_view(
                                     'graphql', schema=self.schema))
Example #22
0
from flask import Flask, redirect, url_for
from flask_graphql import GraphQLView
from example.database import db_session, init_db
from example.schema import schema

app = Flask(__name__)

app.add_url_rule(
    '/graphql', view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True,
        context={'session': db_session},
    ))


@app.route('/')
def index():
    #return "GraphQL at /graphql"
    return redirect(url_for('graphql'))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


if '__main__' == __name__:
    # for testing purposes
    init_db()
    app.run(host='0.0.0.0', port=5001, debug=True)
fake = Factory.create()

FIXTURE = Fixture()
with open("./datos/robots.json", "r") as f:
    for robot in json.loads(f.read()):
        FIXTURE.inscribir_robot(*robot)

SCRAPPER = Robot_scrapper(True)
SCRAPPER.scrap_file()

app = Flask(__name__)
CORS(app)

app.add_url_rule('/fixture', view_func = GraphQLView.as_view('fixture', 
    schema=schema, 
    get_context= lambda *args, **kwargs: {"fixture": FIXTURE},
    graphiql=True))

@app.route('/')
def index(): 
    return render_template("index.html", robots = len(FIXTURE.robots))

@app.route('/scrapper/<categoria>')
def scrapper(categoria):
    equipos = SCRAPPER.get_equipos()
    equipos = [equipo for equipo in equipos if equipo.categoria.startswith(categoria)]
    FIXTURE.limpiar()
    for equipo in equipos:
        FIXTURE.inscribir_equipo(equipo)
    return redirect("/")
Example #24
0
    @staticmethod
    def resolve_county_wise_current_records(*args):
        return (CovidByCountyRecord.query.order_by(
            CovidByCountyRecord.date.desc()).limit(15).all())

    @staticmethod
    def resolve_risk_index_records(*args):
        return (RiskIndexRecord.query.order_by(
            RiskIndexRecord.created_at.desc(),
            RiskIndexRecord.risk_index.desc())
                # .limit(537)
                .all())


schema = graphene.Schema(query=Query)

backend_application.add_url_rule(
    "/graphql-api",
    view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True),
)

# @backend_application.route("/detailed-countries", methods=["GET"])
# def detailed_countries():
#     return Response(json.dumps([country.casefold() for country in DETAILED_COUNTRIES]))


@backend_application.route("/<path:filename>", methods=["GET"])
def dev_frontend_test(filename):
    return send_from_directory(
        directory=f"{BackendSettings.BASE_DIR}/frontend", filename=filename)
Example #25
0
def users_view():
    view = GraphQLView.as_view('users',
                               schema=schema2,
                               graphiql=bool(app.config.get("DEBUG", False)))
    view = jwt_required(view)
    return view
Example #26
0
from flask_restful import Api, Resource
from flask_cors import CORS
from flask_graphql import GraphQLView
from graphene import Schema
from resources.election import ElectionList
from resources.region import RegionList
from resources.constituency import Constituency
from resources.candidate import Candidate
from graphql_api.schema import Query
import tenderServiceRunner

TENDER_DATA_FILE = 'common/dataSource/rawData/tenderRepository'
tenderServiceRunner.initTenderService(TENDER_DATA_FILE)

app = Flask(__name__)
api = Api(app)
CORS(app)

api.add_resource(ElectionList, '/elections')
api.add_resource(RegionList, '/<string:electionName>/<int:year>/regions')
api.add_resource(
    Constituency,
    '/<string:electionName>/<int:year>/constituencies/<string:id>')
api.add_resource(Candidate,
                 '/<string:electionName>/<int:year>/candidates/<int:id>')

app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view('graphql',
                                               schema=Schema(Query),
                                               graphiql=True))
Example #27
0
def get_app():
    """Returns a Flask application object

    The rules are maintained in the ROUTES variable (Note: By default a rule just listens for GET)

    CORS is used to allow CORS for all domains on all routes

    :return: a Flask application object
    """
    connect()

    graphql = GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True  # for having the GraphiQL interface
    )
    graphql_streaming = GraphQLStreamingApi()

    app = Flask(__name__)
    CORS(app)

    # Exclude all non-secure urls fot the audit log and provide the callable to get the user from the request
    app.config['AUDIT_LOG'] = {
        'EXEMPT_URLS': [fr'^(?!{API_SECURE_BASE_PATH}).+'],
        'LOG_HANDLER_CALLABLE_PATH':
        'gobapi.util.audit_log.get_log_handler',
        'USER_FROM_REQUEST_CALLABLE_PATH':
        'gobapi.util.audit_log.get_user_from_request',
    }

    # Add the AuditLogMiddleware
    AuditLogMiddleware(app)

    # Health check route
    app.route(rule='/status/health/')(_health)

    # Application routes
    PUBLIC = [API_BASE_PATH, API_SECURE_BASE_PATH]
    # SECURE = [API_SECURE_BASE_PATH]
    ROUTES = [
        (PUBLIC, '/', _catalogs, ['GET']),
        (PUBLIC, '/<catalog_name>/', _catalog, ['GET']),
        (PUBLIC, '/<catalog_name>/<collection_name>/', _collection, ['GET']),
        (PUBLIC, '/<catalog_name>/<collection_name>/<entity_id>/', _entity,
         ['GET']),
        (PUBLIC,
         '/<catalog_name>/<collection_name>/<entity_id>/<reference_path>/',
         _reference_collection, ['GET']),
        (PUBLIC, '/alltests/', _clear_tests, ['DELETE']),
        (PUBLIC, '/toestanden/', _states, ['GET']),
        (PUBLIC, '/graphql/', graphql, ['GET', 'POST']),
        (PUBLIC, '/graphql/streaming/', graphql_streaming.entrypoint, ['POST'
                                                                       ]),
        (PUBLIC, '/dump/<catalog_name>/<collection_name>/', _dump,
         ['GET', 'POST']),
        (PUBLIC, '/worker/<worker_id>', worker_result, ['GET']),
        (PUBLIC, '/worker/end/<worker_id>', worker_end, ['DELETE']),
        (PUBLIC, '/worker/status/<worker_id>', worker_status, ['GET']),
        (PUBLIC, '/fat_file/<gbs>', fat_file, ['GET']),
        (PUBLIC, '/info/<info_type>/', get_db_info, ['GET'])
    ]
    for paths, rule, view_func, methods in ROUTES:
        _add_route(app, paths, rule, view_func, methods)

    app.teardown_appcontext(shutdown_session)

    return app
Example #28
0
      name,
      balanceValue,
      meta {
        profile {
          profileImage
        }
      }
    },
    votes(first: 10) {
      edges {
        node {
          voter {
            name,
          }
        }
      }
    }
  }
}
""".strip()


schema = graphene.Schema(query=query.Queries)
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql',
                                                           schema=schema,
                                                           graphiql=True,
                                                           query=default_query))

if __name__ == '__main__':
    app.run()
Example #29
0

@application.teardown_appcontext
def shutdown_session(exception=None):
    session.remove()


@application.route("/", defaults={"path": ""})
@application.route("/<path:path>")
def serve(path):
    if path != "" and os.path.exists(application.static_folder + "/" + path):
        return send_from_directory(application.static_folder, path)
    else:
        print(application.static_folder)
        return send_from_directory(application.static_folder, "index.html")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--interactive-graphql", action="store_true")
    arguments = parser.parse_args()

    application.add_url_rule(
        "/graphql",
        view_func=GraphQLView.as_view("graphql",
                                      schema=schema,
                                      graphiql=arguments.interactive_graphql),
    )

    application.run()
Example #30
0
        return jsonify({"user": {"token": tok}}), 200
    except Exception as e:
        return jsonify({"errors": {"global": str(e)}}), 200


def f():
    if True:
        return

    return


app.add_url_rule('/graphiql',
                 view_func=requires_auth(
                     GraphQLView.as_view('graphiql',
                                         schema=schema,
                                         graphiql=True)))
app.add_url_rule('/graphql',
                 view_func=token_auth.login_required(
                     GraphQLView.as_view('graphql',
                                         schema=schema,
                                         graphiql=False)))


@app.route("/about")
def about():
    return render_template('about.html')


@app.route("/")
def home():
Example #31
0
from flask import Flask, escape, request
from flask_pymongo import PyMongo
from dotenv import load_dotenv
from flask_graphql import GraphQLView
from graphene import Schema
from resolvers import Query
from flask_cors import CORS

load_dotenv()

app = Flask(__name__)
CORS(app)

view_func = GraphQLView.as_view("/graphql", schema=Schema(query=Query))

app.add_url_rule("/graphql", view_func=view_func)


@app.route('/')
def index():
    return "GraphQL server is listening on /graphql"


if __name__ == "__main__":
    app.run()
Example #32
0
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
from flask_graphql import GraphQLView

from models import db_session
from schema import schema

app = Flask(__name__)
app.debug = True
app.config['SECRET_KEY'] = 'SECRET'

toolbar = DebugToolbarExtension(app)

app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True  # for having the GraphiQL interface
    ))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


if __name__ == '__main__':
    app.run()
Example #33
0
from flask import Flask
from flask_graphql import GraphQLView as View
from database import db_session
from graph_ql.schema import schema

app = Flask(__name__)
app.debug = True
app.add_url_rule("/",
                 view_func=View.as_view("graphql",
                                        graphiql=True,
                                        schema=schema))


@app.teardown_appcontext
def shutdown_session(Error=None):
    db_session.remove()


def main():
    app.run()


if __name__ == "__main__":
    main()
Example #34
0
def create_app(path='/graphql', **kwargs):
    app = Flask(__name__)
    app.debug = True
    app.add_url_rule(path, view_func=GraphQLView.as_view('graphql', schema=Schema, graphiql=True))
    return app
Example #35
0
        else:
            helpers.set_mode('easy')
    else:
        if session.get('difficulty') == None:
            helpers.set_mode('easy')


schema = graphene.Schema(query=Query, mutation=Mutations)

gql_middlew = [
    middleware.CostProtectionMiddleware(),
    middleware.DepthProtectionMiddleware(),
    middleware.IntrospectionMiddleware(),
    middleware.processMiddleware()
]

igql_middlew = [middleware.IGQLProtectionMiddleware()]

app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view('graphql',
                                               schema=schema,
                                               middleware=gql_middlew,
                                               batch=True))

app.add_url_rule('/graphiql',
                 view_func=GraphQLView.as_view('graphiql',
                                               schema=schema,
                                               graphiql=True,
                                               middleware=igql_middlew,
                                               batch=True))
Example #36
0
from flask import Flask, send_from_directory
from flask_cors import CORS
from flask_graphql import GraphQLView

from db.models import db_session
from interfaces import discover, playlists

app = Flask(__name__)
app.debug = True
CORS(app)


app.add_url_rule(
    '/discover/graphql',
    view_func=GraphQLView.as_view('discover_graphql', schema=discover.schema, graphiql=True)
)
app.add_url_rule(
    '/playlists/graphql',
    view_func=GraphQLView.as_view('playlists_graphql', schema=playlists.schema, graphiql=True)
)

@app.route('/client/<path:filename>')
def serve_static(filename):
    return send_from_directory("client/", filename)


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()

Example #37
0
import graphene
import os
import json
from flask import Flask, url_for, redirect, request
from flask_graphql import GraphQLView
from query import Query, query_url
from OpenSSL import SSL
from graphql import GraphQLError

app = Flask(__name__)
view_func = GraphQLView.as_view('graphql',
                                schema=graphene.Schema(query=Query),
                                graphiql=True)
app.add_url_rule('/graphql', view_func=view_func)


@app.route("/", methods=['GET'])
def hello():
    return redirect(url_for('static', filename='index.html'))


@app.route("/graphQL", methods=['GET'])
def queryURL():
    url = request.args.get('url')
    if url != None and url != '' and url != ' ':
        try:
            reg = query_url(url, Query)
            if reg == 'null':
                # print('reg is ' + reg)
                return 'url is invalid, please provide valid url'
            return reg
Example #38
0
# flask_sqlalchemy/app.py
from flask import Flask
from flask_graphql import GraphQLView

from models import db_session
from schema import schema, Department

app = Flask(__name__)
app.debug = True

app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True # for having the GraphiQL interface
    )
)

@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()

if __name__ == '__main__':
    app.run()
Example #39
0
# Copyright 2019 Axis Communications AB.
#
# For a full list of individual contributors, please see the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import Flask
from flask_graphql import GraphQLView
from .schemas.schema import SCHEMA

APP = Flask(__name__)

APP.add_url_rule("/graphql", view_func=GraphQLView.as_view('graphql', schema=SCHEMA, graphiql=True))
Example #40
0
default_query = '''
{
  allEmployees {
    edges {
      node {
        id,
        name,
        department {
          id,
          name
        },
        role {
          id,
          name
        }
      }
    }
  }
}'''.strip()

app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()

if __name__ == '__main__':
    init_db()
    app.run()
Example #41
0
 def _add_url_rules(self):
     self.blueprint.add_url_rule('/', view_func=self.index_view)
     self.blueprint.add_url_rule('/<path:path>', view_func=self.index_view)
     self.blueprint.add_url_rule(
         '/graphql', view_func=GraphQLView.as_view(
             'graphql', schema=self.schema))