Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DjangoDebug needs context to be writable #1470

Open
bsiebens opened this issue Oct 22, 2023 · 4 comments
Open

DjangoDebug needs context to be writable #1470

bsiebens opened this issue Oct 22, 2023 · 4 comments
Labels

Comments

@bsiebens
Copy link

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • What is the current behavior?
    When trying to access http://localhost:8000/graphql with DEBUG = True, the GraphQL interface returns the following error and is unable to load the schema:
{
  "errors": [
    {
      "message": "DjangoDebug need the context to be writable, context received: WSGIRequest.",
      "locations": [
        {
          "line": 3,
          "column": 7
        }
      ],
      "path": [
        "__schema"
      ]
    }
  ],
  "data": null
}

Blank Django project, set DEBUG to True.
Schema settings used:

GRAPHENE = {
    "SCHEMA": "coldplaysharks.schema.schema",
}

Relevant schema file

import graphene
from graphene_django import DjangoObjectType

from .models import Team


class TeamType(DjangoObjectType):
    class Meta:
        model = Team


class Query(graphene.ObjectType):
    teams = graphene.List(TeamType)

    def resolve_teams(root, info, **kwargs):
        return Team.objects.all()


schema = graphene.Schema(query=Query)

Relevant models.py file for Team

class Team(models.Model):
    """Holds all information related to the different teams in the club."""

    name = models.CharField(max_length=250)
    slug = models.SlugField(unique=True)
    logo = models.ImageField(upload_to="team/logo/")
    menu_active = models.BooleanField("Show in menu?", default=True, help_text="If activated this team will be shown under the 'Teams' menu option")
    menu_weight = models.IntegerField(default=0, help_text="Teams in the menu will be ordered from heavy to lightest, with the lighter ones floating to the top")

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.name
  • What is the expected behavior?
    I would expect to be able to query the schema using the GraphQL browser

  • What is the motivation / use case for changing the behavior?
    It's not working currently

  • Please tell us about your environment:

    • Version: 3.1.5 (Django version 4.2.6)
    • Platform: Windows 11
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

@bsiebens
Copy link
Author

Further searching shows that putting DEBUG to False does work, so it's something to do with how graphene-django interacts with the requests.

@agpldev
Copy link

agpldev commented Dec 20, 2023

Struggling with the same issue, but setting DEBUG to False does not work for me; I get a blank page instead with no errors when I change that.

Environment
graphene-django version: 3.1.5
Django Version: 5.0
Python Version: 3.11.6, 3.12.0
Platform: MacOS Ventura [13.4.1 (c)] on an M2 Pro

I attempted this on Django 4.2.8 and see the same error. Similarly, the same issue when downgrading to graphene-django 3.1.3.

pipenv graph output
graphene-django==3.1.5
├── Django [required: >=3.2, installed: 4.2.8]
│ ├── asgiref [required: >=3.6.0,<4, installed: 3.7.2]
│ └── sqlparse [required: >=0.3.1, installed: 0.4.4]
├── graphene [required: >=3.0,<4, installed: 3.3]
│ ├── aniso8601 [required: >=8,<10, installed: 9.0.1]
│ ├── graphql-core [required: >=3.1,<3.3, installed: 3.2.3]
│ └── graphql-relay [required: >=3.1,<3.3, installed: 3.2.0]
│ └── graphql-core [required: >=3.2,<3.3, installed: 3.2.3]
├── graphql-core [required: >=3.1.0,<4, installed: 3.2.3]
├── graphql-relay [required: >=3.1.1,<4, installed: 3.2.0]
│ └── graphql-core [required: >=3.2,<3.3, installed: 3.2.3]
├── promise [required: >=2.1, installed: 2.3]
│ └── six [required: Any, installed: 1.16.0]
└── text-unidecode [required: Any, installed: 1.3]

The dependency graph for graphene-django 3.1.3 is the same except for the graphene-django version itself.

@agpldev
Copy link

agpldev commented Dec 20, 2023

Struggling with the same issue, but setting DEBUG to False does not work for me; I get a blank page instead with no errors when I change that.

Environment graphene-django version: 3.1.5 Django Version: 5.0 Python Version: 3.11.6, 3.12.0 Platform: MacOS Ventura [13.4.1 (c)] on an M2 Pro

I attempted this on Django 4.2.8 and see the same error. Similarly, the same issue when downgrading to graphene-django 3.1.3.

pipenv graph output graphene-django==3.1.5 ├── Django [required: >=3.2, installed: 4.2.8] │ ├── asgiref [required: >=3.6.0,<4, installed: 3.7.2] │ └── sqlparse [required: >=0.3.1, installed: 0.4.4] ├── graphene [required: >=3.0,<4, installed: 3.3] │ ├── aniso8601 [required: >=8,<10, installed: 9.0.1] │ ├── graphql-core [required: >=3.1,<3.3, installed: 3.2.3] │ └── graphql-relay [required: >=3.1,<3.3, installed: 3.2.0] │ └── graphql-core [required: >=3.2,<3.3, installed: 3.2.3] ├── graphql-core [required: >=3.1.0,<4, installed: 3.2.3] ├── graphql-relay [required: >=3.1.1,<4, installed: 3.2.0] │ └── graphql-core [required: >=3.2,<3.3, installed: 3.2.3] ├── promise [required: >=2.1, installed: 2.3] │ └── six [required: Any, installed: 1.16.0] └── text-unidecode [required: Any, installed: 1.3]

The dependency graph for graphene-django 3.1.3 is the same except for the graphene-django version itself.

I have tested this now on my Digital Ocean server running Ubuntu 23.10 ... and it works for the following environment:

Environment
graphene-django version: 3.1.5
Django Version: 5.0
Python Version: 3.11.6

In the absence of further testing, this seems to be fine on an x86_64 architecture but on on Apple Scilicon (M2 Pro)

@miliakhaled
Copy link

Hello,
I got the same error when i add a database without granting permission to user, my database user has only limited access to database, when a delete the database object from settings.py the error disappears

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants