{"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":"python","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,"search_vec":"'2.0.1':35 'add':7 'api':22,59 'applic':13 'cadenc':44 'compat':47 'core':51 'current':32 'easi':16 'endpoint':23 'flask':2,5,12,49,55 'flask-graphql':1,4 'focus':45 'framework':58 'graphen':60 'graphiql':27 'graphql':3,6,8,21,52,56 'ide':28 'integr':19 'librari':30,54 'option':26 'provid':14 'python':53 'rapid':42 'releas':43 'stabl':39 'support':9 'though':40 'version':34 'way':17 'web':57","created_at":"2026-04-12T16:47:31.451505+00:00","updated_at":"2026-04-16T15:07:01.564488+00:00","problems":[{"fix":"Ensure `flask-graphql` is installed in your active virtual environment using `pip install Flask-GraphQL`. If the issue persists, check for compatible versions of `Flask-GraphQL`, `graphene`, and `graphql-core` and explicitly install them (e.g., `pip install Flask-GraphQL==2.0.1 graphene==2.1.9 graphql-core<3`).","cause":"This error typically occurs when the `flask-graphql` library is not installed, installed incorrectly, or there's a mismatch in the import statement or virtual environment. Sometimes, it's also due to dependency conflicts with `graphql-core` or `graphene` versions.","error":"ModuleNotFoundError: No module named 'flask_graphql' OR ImportError: cannot import name 'GraphQLView' from 'flask_graphql'"},{"fix":"Ensure you define a `graphene.Schema` object (or a `graphql.GraphQLSchema` object) and pass it to the `schema` parameter when configuring your GraphQL endpoint. If using Graphene v3, ensure you pass `schema=schema.graphql_schema`.","cause":"This error means that the `GraphQLView.as_view()` function was called without a valid GraphQL schema object being passed to its `schema` argument.","error":"AssertionError: A Schema is required to be provided to GraphQLView"},{"fix":"Provide a `get_context` callable to your `GraphQLView.as_view()` configuration that returns a dictionary containing the Flask `request` and any other necessary Flask globals (like `g` or `session`). For example: `get_context=lambda: {'request': request, 'session': session}` or `get_context=lambda: {'session': g.db}`.","cause":"This error usually happens inside a GraphQL resolver when you try to access Flask's `request` or `session` objects from the `info.context` without properly configuring the `get_context` function in `GraphQLView` to inject these objects.","error":"AttributeError: 'Request' object has no attribute 'get' OR 'Request' object has no attribute 'session'"},{"fix":"Validate your GraphQL query string for syntax errors. If sending the query as a URL parameter, ensure all special characters (like '&') are URL-escaped (e.g., '&' becomes '%26'). If sending as a JSON body, ensure it's valid JSON and structured correctly (e.g., `{'query': '...', 'variables': {...}}`).","cause":"This error indicates that the GraphQL query sent to the server is malformed or contains invalid syntax. This can often happen when special characters in query parameters are not properly URL-escaped or the JSON body of the request is incorrect.","error":"Syntax Error GraphQL request: Expected Name, found '...' (or similar GraphQL syntax errors)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.0.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/graphql-python/flask-graphql","docs":null,"changelog":null,"pypi":"https://pypi.org/project/flask-graphql/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","llm-agents"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}