{"id":13421685,"url":"https://github.com/graphql-python/flask-graphql","last_synced_at":"2025-05-14T18:02:14.189Z","repository":{"id":3587099,"uuid":"50231898","full_name":"graphql-python/flask-graphql","owner":"graphql-python","description":"Adds GraphQL support to your Flask application.","archived":false,"fork":false,"pushed_at":"2023-01-03T16:53:50.000Z","size":395,"stargazers_count":1327,"open_issues_count":42,"forks_count":139,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-08T00:02:26.999Z","etag":null,"topics":["flask","flask-application","graphene","graphql","python","web"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-python.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-23T09:20:02.000Z","updated_at":"2025-04-30T19:00:51.000Z","dependencies_parsed_at":"2023-01-13T12:38:02.707Z","dependency_job_id":null,"html_url":"https://github.com/graphql-python/flask-graphql","commit_stats":null,"previous_names":["graphql-python/graphql-flask"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Fflask-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Fflask-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Fflask-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Fflask-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-python","download_url":"https://codeload.github.com/graphql-python/flask-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198453,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-application","graphene","graphql","python","web"],"created_at":"2024-07-30T23:00:28.222Z","updated_at":"2025-05-14T18:02:14.119Z","avatar_url":"https://github.com/graphql-python.png","language":"Python","readme":"# Flask-GraphQL\n\nAdds GraphQL support to your Flask application.\n\n[![travis][travis-image]][travis-url]\n[![pypi][pypi-image]][pypi-url]\n[![Anaconda-Server Badge][conda-image]][conda-url]\n[![coveralls][coveralls-image]][coveralls-url]\n\n[travis-image]: https://travis-ci.org/graphql-python/flask-graphql.svg?branch=master\n[travis-url]: https://travis-ci.org/graphql-python/flask-graphql\n[pypi-image]: https://img.shields.io/pypi/v/flask-graphql.svg?style=flat\n[pypi-url]: https://pypi.org/project/flask-graphql/\n[coveralls-image]: https://coveralls.io/repos/graphql-python/flask-graphql/badge.svg?branch=master\u0026service=github\n[coveralls-url]: https://coveralls.io/github/graphql-python/flask-graphql?branch=master\n[conda-image]: https://img.shields.io/conda/vn/conda-forge/flask-graphql.svg\n[conda-url]: https://anaconda.org/conda-forge/flask-graphql\n\n## Usage\n\nJust use the `GraphQLView` view from `flask_graphql`\n\n```python\nfrom flask import Flask\nfrom flask_graphql import GraphQLView\n\nfrom schema import schema\n\napp = Flask(__name__)\n\napp.add_url_rule('/graphql', view_func=GraphQLView.as_view(\n    'graphql',\n    schema=schema,\n    graphiql=True,\n))\n\n# Optional, for adding batch query support (used in Apollo-Client)\napp.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view(\n    'graphql',\n    schema=schema,\n    batch=True\n))\n\nif __name__ == '__main__':\n    app.run()\n```\n\nThis will add `/graphql` endpoint to your app and enable the GraphiQL IDE.\n\n### Special Note for Graphene v3\n\nIf you are using the `Schema` type of [Graphene](https://github.com/graphql-python/graphene) library, be sure to use the `graphql_schema` attribute to pass as schema on the `GraphQLView` view. Otherwise, the `GraphQLSchema` from `graphql-core` is the way to go.\n\nMore info at [Graphene v3 release notes](https://github.com/graphql-python/graphene/wiki/v3-release-notes#graphene-schema-no-longer-subclasses-graphqlschema-type) and [GraphQL-core 3 usage](https://github.com/graphql-python/graphql-core#usage).\n\n\n### Supported options for GraphQLView\n\n * `schema`: The `GraphQLSchema` object that you want the view to execute when it gets a valid request.\n * `context`: A value to pass as the `context_value` to graphql `execute` function. By default is set to `dict` with request object at key `request`.\n * `root_value`: The `root_value` you want to provide to graphql `execute`.\n * `pretty`: Whether or not you want the response to be pretty printed JSON.\n * `graphiql`: If `True`, may present [GraphiQL](https://github.com/graphql/graphiql) when loaded directly from a browser (a useful tool for debugging and exploration).\n * `graphiql_version`: The graphiql version to load. Defaults to **\"1.0.3\"**.\n * `graphiql_template`: Inject a Jinja template string to customize GraphiQL.\n * `graphiql_html_title`: The graphiql title to display. Defaults to **\"GraphiQL\"**.\n * `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))\n * `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).\n * `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).\n * `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.\n * `subscriptions`: The GraphiQL socket endpoint for using subscriptions in graphql-ws.\n * `headers`: An optional GraphQL string to use as the initial displayed request headers, if not provided, the stored headers will be used.\n * `default_query`: An optional GraphQL string to use when no query is provided and no stored query exists from a previous session. If not provided, GraphiQL will use its own default query.\n* `header_editor_enabled`: An optional boolean which enables the header editor when true. Defaults to **false**.\n* `should_persist_headers`:  An optional boolean which enables to persist headers to storage when true. Defaults to **false**.\n\nYou can also subclass `GraphQLView` and overwrite `get_root_value(self, request)` to have a dynamic root value\nper request.\n\n```python\nclass UserRootValue(GraphQLView):\n    def get_root_value(self, request):\n        return request.user\n\n```\n\n## Contributing\nSince v3, `flask-graphql` code lives at [graphql-server](https://github.com/graphql-python/graphql-server) repository to keep any breaking change on the base package on sync with all other integrations. In order to contribute, please take a look at [CONTRIBUTING.md](https://github.com/graphql-python/graphql-server/blob/master/CONTRIBUTING.md).\n","funding_links":[],"categories":["Libraries","Python","Third-Party Extensions","Implementations","Utils"],"sub_categories":["Python Libraries","Utils","Python"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-python%2Fflask-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-python%2Fflask-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-python%2Fflask-graphql/lists"}