{"id":18466525,"url":"https://github.com/graphql-python/aiohttp-graphql","last_synced_at":"2025-07-14T17:38:26.985Z","repository":{"id":51343719,"uuid":"104556205","full_name":"graphql-python/aiohttp-graphql","owner":"graphql-python","description":" Adds GraphQL support to your aiohttp app.","archived":false,"fork":false,"pushed_at":"2021-04-29T21:47:26.000Z","size":46,"stargazers_count":116,"open_issues_count":6,"forks_count":23,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-15T00:12:32.144Z","etag":null,"topics":["aiohttp","graphql"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","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":"2017-09-23T09:25:20.000Z","updated_at":"2025-03-17T15:34:23.000Z","dependencies_parsed_at":"2022-09-26T21:40:37.796Z","dependency_job_id":null,"html_url":"https://github.com/graphql-python/aiohttp-graphql","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/graphql-python/aiohttp-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Faiohttp-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Faiohttp-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Faiohttp-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Faiohttp-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-python","download_url":"https://codeload.github.com/graphql-python/aiohttp-graphql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-python%2Faiohttp-graphql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261037152,"owners_count":23100933,"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":["aiohttp","graphql"],"created_at":"2024-11-06T09:16:39.639Z","updated_at":"2025-07-14T17:38:26.942Z","avatar_url":"https://github.com/graphql-python.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aiohttp-graphql\nAdds [GraphQL] support to your [aiohttp] application.\n\nBased on [flask-graphql] by [Syrus Akbary] and [sanic-graphql] by [Sergey Porivaev].\n\n[![PyPI version](https://badge.fury.io/py/aiohttp-graphql.svg)](https://badge.fury.io/py/aiohttp-graphql)\n[![Build Status](https://travis-ci.com/graphql-python/aiohttp-graphql.svg?branch=master)](https://github.com/graphql-python/aiohttp-graphql)\n[![Coverage Status](https://codecov.io/gh/graphql-python/aiohttp-graphql/branch/master/graph/badge.svg)](https://github.com/graphql-python/aiohttp-graphql)\n\n## Usage\n\nUse the `GraphQLView` view from `aiohttp_graphql`\n\n```python\nfrom aiohttp import web\nfrom aiohttp_graphql import GraphQLView\n\nfrom schema import schema\n\napp = web.Application()\n\nGraphQLView.attach(app, schema=schema, graphiql=True)\n\n# Optional, for adding batch query support (used in Apollo-Client)\nGraphQLView.attach(app, schema=schema, batch=True, route_path=\"/graphql/batch\")\n\nif __name__ == '__main__':\n    web.run_app(app)\n```\n\nThis will add `/graphql` endpoint to your app (customizable by passing `route_path='/mypath'` to `GraphQLView.attach`) and enable the GraphiQL IDE.\n\nNote: `GraphQLView.attach` is just a convenience function, and the same functionality can be achieved with\n\n```python\ngql_view = GraphQLView(schema=schema, graphiql=True)\napp.router.add_route('*', '/graphql', gql_view, name='graphql')\n```\n\nIt's worth noting that the the \"view function\" of `GraphQLView` is contained in `GraphQLView.__call__`. So, when you create an instance, that instance is callable with the request object as the sole positional argument. To illustrate:\n\n```python\ngql_view = GraphQLView(schema=Schema, **kwargs)\ngql_view(request)  # \u003c-- the instance is callable and expects a `aiohttp.web.Request` object.\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 * `jinja_env`: Sets jinja environment to be used to process GraphiQL template. If Jinja’s async mode is enabled (by `enable_async=True`), uses \n`Template.render_async` instead of `Template.render`. If environment is not set, fallbacks to simple regex-based renderer.\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 * `max_age`: Sets the response header Access-Control-Max-Age for preflight requests.\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 * `enable_async`: whether `async` mode will be enabled.\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\n\n## Contributing\nSince v3, `aiohttp-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\n\n## License\nCopyright for portions of project [aiohttp-graphql] are held by [Syrus Akbary] as part of project [flask-graphql] and [sanic-graphql] as part of project [Sergey Porivaev]. All other claims to this project [aiohttp-graphql] are held by [Devin Fee].\n\nThis project is licensed under the MIT License.\n\n  [GraphQL]: http://graphql.org/\n  [aiohttp]: https://github.com/aio-libs/aiohttp/\n  [flask-graphql]: https://github.com/graphql-python/flask-graphql\n  [sanic-graphql]: https://github.com/graphql-python/sanic-graphql\n  [Syrus Akbary]: https://github.com/syrusakbary\n  [Sergey Porivaev]: https://github.com/grazor\n  [GraphiQL]: https://github.com/graphql/graphiql\n  [graphql-python]: https://github.com/graphql-python/graphql-core\n  [Apollo-Client]: https://www.apollographql.com/docs/react/networking/network-layer/#query-batching\n  [Devin Fee]: https://github.com/dfee\n  [aiohttp-graphql]: https://github.com/graphql-python/aiohttp-graphql\n  [graphql-ws]: https://github.com/graphql-python/graphql-ws\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-python%2Faiohttp-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-python%2Faiohttp-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-python%2Faiohttp-graphql/lists"}