{"id":26061002,"url":"https://github.com/flavors/django-graphql-extensions","last_synced_at":"2025-07-13T21:07:04.094Z","repository":{"id":50101397,"uuid":"117128883","full_name":"flavors/django-graphql-extensions","owner":"flavors","description":"A collection of custom extensions for Graphene Django","archived":false,"fork":false,"pushed_at":"2021-07-23T17:10:34.000Z","size":70,"stargazers_count":84,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-27T14:04:43.983Z","etag":null,"topics":["authentication","django","errors","extensions","graphene","graphql","test","testcase","trace","utils"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/django-graphql-extensions","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/flavors.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","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":"2018-01-11T17:10:16.000Z","updated_at":"2025-01-25T17:43:27.000Z","dependencies_parsed_at":"2022-08-31T05:01:53.436Z","dependency_job_id":null,"html_url":"https://github.com/flavors/django-graphql-extensions","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/flavors/django-graphql-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flavors","download_url":"https://codeload.github.com/flavors/django-graphql-extensions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-extensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265205671,"owners_count":23727510,"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":["authentication","django","errors","extensions","graphene","graphql","test","testcase","trace","utils"],"created_at":"2025-03-08T14:47:49.894Z","updated_at":"2025-07-13T21:07:04.061Z","avatar_url":"https://github.com/flavors.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Django GraphQL Extensions\n=========================\n\n|Pypi| |Build Status| |Codecov| |Codacy|\n\nA collection of custom extensions for `Django GraphQL`_\n\n.. _Django GraphQL: https://github.com/graphql-python/graphene-django\n\n\nDependencies\n------------\n\n* Python ≥ 3.6\n* Django ≥ 2.0\n* Graphene-django ≥ 3.0.0b1\n\n\nInstallation\n------------\n\nInstall last stable version from Pypi.\n\n.. code:: sh\n\n    pip install django-graphql-extensions\n\n\nAuthentication\n--------------\n\n- ``@login_required``\n- ``@staff_member_required``\n- ``@superuser_required``\n- ``@permission_required``\n- ``@user_passes_test``\n\nSee the `documentation`_ to know the full list of decorators.\n\n.. _documentation: https://github.com/flavors/django-graphql-extensions/wiki/Decorators\n\n.. code:: python\n\n    from django.contrib.auth import get_user_model\n\n    import graphene\n    from graphql_extensions.decorators import (\n        login_required, staff_member_required,\n    )\n\n\n    class Query(graphene.ObjectType):\n        viewer = graphene.Field(UserType)\n        users = graphene.List(UserType)\n\n        @login_required\n        def resolve_viewer(self, info, **kwargs):\n            return info.context.user\n\n        @staff_member_required\n        def resolve_users(self, info, **kwargs):\n            return get_user_model().objects.all()\n\n\nErrors\n------\n\nReturning appropriate **error responses** and **masking** error messages sent to the client.\n\nConfigure your ``GraphQLView``.\n\n.. code:: python\n\n    from django.urls import include, path\n\n    from graphql_extensions.views import GraphQLView\n\n    urlpatterns = [\n        path('', GraphQLView.as_view(), name='index'),\n    ]\n\n**Exceptions**\n\n.. code:: python\n\n    from graphql_extensions import exceptions\n\n\n- ``exceptions.GraphQLError``\n- ``exceptions.PermissionDenied``\n- ``exceptions.ValidationError``\n- ``exceptions.NotFound``\n\n\n**Payload**\n\n.. code:: js\n\n    {\n      \"errors\": [\n        {\n          \"message\": \"You do not have permission to perform this action\",\n          \"locations\": [\n            {\n              \"line\": 3,\n              \"column\": 13\n            }\n          ],\n          \"path\": [\n            \"viewer\"\n          ],\n          \"extensions\": {\n            \"type\": \"PermissionDenied\",\n            \"code\": \"permissionDenied\",\n            \"timestamp\": 1622783872,\n            \"data\": {},\n            \"operation\": \"QUERY\",\n            \"trace\": [\n              \"  File \\\"site-packages/graphql/execution/execute.py\\\", line 617, in resolve_field\\n    result = resolve_fn(source, info, **args)\\n\",\n              \"  File \\\"graphql_extensions/decorators.py\\\", line 23, in wrapper\\n    return func(info.context, *args, **kwargs)\\n\",\n              \"  File \\\"graphql_extensions/decorators.py\\\", line 35, in wrapper\\n    raise exc\\n\"\n            ]\n          }\n        }\n      ],\n      \"data\": {\n        \"viewer\": null\n      }\n    }\n\n\nWriting tests\n-------------\n\nThis package includes a subclass of `unittest.TestCase \u003chttps://docs.python.org/3/library/unittest.html#unittest.TestCase\u003e`__ ``SchemaTestCase`` and improve support for making GraphQL queries.\n\n.. code:: python\n\n    from django.contrib.auth import get_user_model\n\n    from graphql_extensions.test import SchemaTestCase\n\n\n    class UsersTests(SchemaTestCase):\n\n        def test_create_user(self):\n            query = '''\n            mutation CreateUser($username: String!, $password: String!) {\n              createUser(username: $username, password: $password) {\n                user {\n                  id\n                }\n              }\n            }'''\n\n            response = self.client.execute(query, {\n                'username': 'test',\n                'password': 'dolphins',\n            })\n\n            self.assertFalse(response.errors)\n            self.assertTrue(response.data['user'])\n\n        def test_viewer(self):\n            user = get_user_model().objects.create_user(\n                username='test',\n                password='dolphins',\n            )\n\n            self.client.authenticate(self.user)\n\n            query = '''\n            {\n              viewer {\n                username\n              }\n            }'''\n\n            response = self.client.execute(query)\n            data = response.data['viewer']\n\n            self.assertEqual(data['username'], user.username)\n\n\nTypes\n-----\n\nCustom *Graphene* **types**.\n\n- ``Email``\n- ``Timestamp``\n\n\n.. |Pypi| image:: https://img.shields.io/pypi/v/django-graphql-extensions.svg\n   :target: https://pypi.python.org/pypi/django-graphql-extensions\n   :alt: Pypi\n\n.. |Build Status| image:: https://github.com/flavors/django-graphql-extensions/actions/workflows/test-suite.yml/badge.svg\n   :target: https://github.com/flavors/django-graphql-extensions/actions\n   :alt: Build Status\n\n.. |Codecov| image:: https://codecov.io/gh/flavors/django-graphql-extensions/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/flavors/django-graphql-extensions\n   :alt: Codecov\n\n.. |Codacy| image:: https://app.codacy.com/project/badge/Grade/95cb35fad84c4560973181a22352ac4b\n   :target: https://www.codacy.com/gh/flavors/django-graphql-extensions/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=flavors/django-graphql-extensions\u0026amp;utm_campaign=Badge_Grade\n   :alt: Codacy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavors%2Fdjango-graphql-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflavors%2Fdjango-graphql-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavors%2Fdjango-graphql-extensions/lists"}