{"id":4947,"library":"flask-graphql","title":"Flask-GraphQL","description":"Flask-GraphQL adds GraphQL support to your Flask application, providing an easy way to integrate a GraphQL API endpoint and an optional GraphiQL IDE. The library is currently at version 2.0.1 and has a stable, though not rapid, release cadence, focusing on compatibility with Flask and core GraphQL Python libraries.","status":"active","version":"2.0.1","language":"en","source_language":"en","source_url":"https://github.com/graphql-python/flask-graphql","tags":["flask","graphql","web framework","api","graphene"],"install":[{"cmd":"pip install flask-graphql","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"The underlying web framework for the GraphQL integration.","package":"Flask"},{"reason":"Commonly used Python library for building GraphQL schemas, frequently integrated with Flask-GraphQL. Flask-GraphQL 2.x is compatible with Graphene 2.x.","package":"graphene","optional":true},{"reason":"The reference implementation of GraphQL in Python, required for schema execution. Flask-GraphQL 2.0.1 requires graphql-core <3,>=2.1.","package":"graphql-core","optional":false},{"reason":"Provides the core logic for serving GraphQL over HTTP. Version 1.1 is used by Flask-GraphQL 2.0.x.","package":"graphql-server-core","optional":false}],"imports":[{"note":"The primary class for handling GraphQL requests is directly importable from the top-level package.","wrong":"from flask_graphql.graphqlview import GraphQLView","symbol":"GraphQLView","correct":"from flask_graphql import GraphQLView"}],"quickstart":{"code":"import os\nfrom flask import Flask\nfrom flask_graphql import GraphQLView\nimport graphene\n\nclass Query(graphene.ObjectType):\n    hello = graphene.String(description='A typical hello world')\n\n    def resolve_hello(self, info):\n        # In a real app, 'info' can contain request context, e.g., for auth\n        # For this example, we'll just return a string.\n        return 'Hello, World!'\n\nschema = graphene.Schema(query=Query)\n\napp = Flask(__name__)\napp.add_url_rule(\n    '/graphql',\n    view_func=GraphQLView.as_view(\n        'graphql',\n        schema=schema,\n        graphiql=True # Enable the GraphiQL IDE for testing\n    )\n)\n\n# Optional: for adding batch query support (used in Apollo-Client)\napp.add_url_rule(\n    '/graphql/batch',\n    view_func=GraphQLView.as_view(\n        'graphql_batch',\n        schema=schema,\n        batch=True\n    )\n)\n\nif __name__ == '__main__':\n    # Use a secure way to get host/port in production\n    host = os.environ.get('FLASK_HOST', '127.0.0.1')\n    port = int(os.environ.get('FLASK_PORT', 5000))\n    app.run(host=host, port=port)\n","lang":"python","description":"This quickstart sets up a basic Flask application with a GraphQL endpoint at `/graphql`. It defines a simple 'hello world' GraphQL query using Graphene and enables the interactive GraphiQL interface for easy testing in the browser. It also demonstrates how to enable batch query support."},"warnings":[{"fix":"Ensure `graphql-core` is constrained to a 2.x version (e.g., `pip install 'graphql-core<3,>=2.1'`) and `graphene` is constrained to a 2.x version (e.g., `pip install 'graphene<3,>=2.1'`).","message":"Flask-GraphQL 2.x is incompatible with `graphql-core` v3.x and `graphene` v3.x due to strict dependency pinning (`graphql-core <3,>=2.1`). Attempting to install or upgrade to `graphql-core` v3.x or `graphene` v3.x will result in dependency conflicts.","severity":"breaking","affected_versions":"2.0.0, 2.0.1"},{"fix":"Change `schema=my_graphene_schema_instance` to `schema=my_graphene_schema_instance.graphql_schema` if using Graphene v3.","message":"When using Graphene v3 (if you manage to override `graphql-core` incompatibility or are on a future `flask-graphql` version), passing the Graphene `Schema` object directly to `GraphQLView.as_view`'s `schema` parameter is incorrect. You must use the `graphql_schema` attribute of the Graphene `Schema` object.","severity":"gotcha","affected_versions":"All versions when attempting to use Graphene v3"},{"fix":"Add a separate `app.add_url_rule` for `/graphql/batch` and set `batch=True` in `GraphQLView.as_view` options, as shown in the quickstart example.","message":"Enabling batch GraphQL queries requires an additional URL rule definition with `batch=True`. Without this, clients expecting batch query functionality will encounter errors.","severity":"gotcha","affected_versions":"All versions since 1.4.0"},{"fix":"Review Flask 2.0 changelog for breaking changes, ensure Python version is 3.6+ (preferably 3.7+), and update other Flask extensions as needed.","message":"Flask-GraphQL supports Flask 2.x, but be aware that Flask 2.0 introduced several breaking changes itself, including dropping support for Python 2 and 3.5. Ensure your Python environment and other Flask extensions are compatible with Flask 2.x before upgrading.","severity":"gotcha","affected_versions":"Flask-GraphQL versions running on Flask >= 2.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}