コード例 #1
0
    def initialize(self):
        loop = tornado.ioloop.IOLoop.current()

        generate_schema()
        api_schema = get_api_schema()
        module_schema = get_module_schema()

        if options.generate_schema_and_exit:
            query = get_introspection_query(descriptions=False)
            introspection_query_result = graphql_sync(api_schema, query)
            client_schema = build_client_schema(introspection_query_result.data)
            sdl = print_schema(client_schema)

            with open(
                Path(options.basedir).joinpath("..", "schema.graphql").resolve(), "w+"
            ) as fid:
                fid.write(sdl)
            sys.exit(0)

        start_all_modules()
        self.database = None  # MavDatabase()

        application = TornadoQL()

        # Start Non-SSL server
        server = tornado.httpserver.HTTPServer(application)
        server.listen(port=options.server_port_nonssl, address=options.server_interface)
        application_log.info(
            f"Starting Maverick API server: {options.server_interface}:{options.server_port_nonssl}/{options.app_prefix}"
        )

        # Start SSL server, unless disabled
        if not options.disable_ssl:
            ssl_options = self.get_ssl_options()
            server = tornado.httpserver.HTTPServer(application, ssl_options=ssl_options)
            server.listen(
                port=options.server_port_ssl, address=options.server_interface
            )
            application_log.info(
                f"Starting Maverick API server - SSL: {options.server_interface}:{options.server_port_ssl}/{options.app_prefix}"
            )
コード例 #2
0
    def __init__(self):
        handlers = [
            (r"/subscriptions", GraphQLSubscriptionHandler),
            (r"/graphql", GraphQLHandler),
            (r"/graphiql", GraphiQLHandler),
            (r"/schema", SchemaHandler),
            (r"/login", LoginHandler),
            (r"/logout", LogoutHandler),
            (r"/refresh_token", RefreshTokenHandler),
        ]

        settings = dict(
            debug=options.debug,
            compress_response=True,
            websocket_ping_interval=10,
            cookie_secret=options.app_secretkey,
            static_path=os.path.join(options.basedir, "data", "static"),
            xsrf_cookies=False,
        )
        TornadoQL.schema = get_api_schema()
        super(TornadoQL, self).__init__(handlers, **settings)
コード例 #3
0
 def schema(self):
     return get_api_schema()
コード例 #4
0
 async def get(self):
     query = get_introspection_query(descriptions=True)
     introspection_query_result = await graphql(get_api_schema(), query)
     introspection_dict = introspection_query_result.data
     self.write(json.dumps(introspection_dict, indent=4, sort_keys=True))
     self.finish()