If DjangoDebugMiddleware is installed, calling `cursor.execute(b)` where b is a `bytes` object causes the recording (and thus the entire database call) to throw a TypeError due to 775644b536/graphene_django/debug/sql/tracking.py (L126) :
```
"is_select": sql.lower().strip().startswith("select"),
```
Calling execute with a bytes parameter, to my knowledge, is not currently done within the high-level abstractions in the Django ORM, but is very much supported by psycopg2, as evidenced by the use in psycopg2's own `execute_values` in https://github.com/psycopg/psycopg2/blob/2_9_3/lib/extras.py#L1270 :
```
cur.execute(b''.join(parts))
```
This fix ensures that the sql parameter is safely decoded before scanning whether it begins with SELECT; since this is the only usage, the change is trivial.
The only workaround if code calls execute_values is to disable the DjangoDebugMiddleware altogether, which is far from ideal.
* adding optional_fields to enforce fields to be optional
* adding support for all
* adding unit tests
* Update graphene_django/rest_framework/mutation.py
Co-authored-by: Kien Dang <kiend@pm.me>
* linting
* linting
* add missing import
---------
Co-authored-by: Kien Dang <kiend@pm.me>
* Update Makefile
* django master requires at least python 3.10 now
* Allow customizing options passed to tox -e pre-commit
* py.test -> pytest
* Update ruff
* Fix E721
Do not compare types, use `isinstance()`
* Add back black to dev dependencies
* Pin black and ruff versions
* Use ruff in pre-commit
* Add pyupgrade
* Add isort
* Add bugbear
* Fix B015 Pointless comparison
* Fix B026
* B018 false positive
* Remove flake8 and isort config from setup.cfg
* Remove black and flake8 from dev dependencies
* Update black
* Show list of fixes applied with autofix on
* Fix typo
* Add C4 flake8-comprehensions
* Add ruff to dev dependencies
* Fix up
* Fix for issue #1385: Update mutation.py to serialize Enum objects into input values for ChoiceFields
* Update graphene_django/rest_framework/mutation.py
Co-authored-by: Steven DeMartini <1647130+sjdemartini@users.noreply.github.com>
---------
Co-authored-by: Steven DeMartini <1647130+sjdemartini@users.noreply.github.com>
* support reverse relationship for proxy models
* support multi table inheritence
* update query test for multi table inheritance
* remove debugger
* support local many to many in model inheritance
* format and lint
---------
Co-authored-by: Firas K <3097061+firaskafri@users.noreply.github.com>
* Add venv and .venv to gitignore since common venv paths
* Update cookbook-plain app requirements and local-dev notes
This also adds the DEFAULT_AUTO_FIELD to the app's Django settings to
resolve this warning when running `migrate`:
```
ingredients.Category: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the IngredientsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
```
* Fix#1417 graphiql explorer styles by including official CSS
Like in the official graphiql-plugin-explorer example here
6198646919/packages/graphiql-plugin-explorer/examples/index.html (L26-L29)
Resolves https://github.com/graphql-python/graphene-django/issues/1417
* Update GraphiQL version
---------
Co-authored-by: Steven DeMartini <sjdemartini@users.noreply.github.com>
Co-authored-by: Kien Dang <mail@kien.ai>
* Add DjangoFormInputObjectType to forms/types
InputObjectType derived class which gets fields from django form.
Type of fields with choices (converted to enum) is set to custom scalar
type (using Meta.object_type) to dynamically convert enum values back.
* Correct Reporter model a_choice field type according to CHOICES tuple
* Add tests for DjangoFormInputObjectType
* Add pyenv files to .gitignore
* Fix pyupgrade
* Fix tests
* Add docs
* Fix docs example
---------
Co-authored-by: Firas Kafri <3097061+firaskafri@users.noreply.github.com>
* change Sphinx version from 1.5.3 to 7.0.0
* change sphinx-autobuild version from 0.7.1 to 2021.3.14
* add pygments-graphql-lexer to docs/requirements.txt
* Remove redundant call to validate
The call to `validate` in the django view is redundant with the validation call in graphql-core.
* Remove whitespace
---------
Co-authored-by: Firas K <3097061+firaskafri@users.noreply.github.com>
* Use Python 3.10 for deployments on PyPi
* Update gh-action-pypi-publish version
* Update python version
* Update checkout and setup-python versions
* Upgrade dev dependencies
* fromat examples and few files to follow black new version
* Upgrade pytest version
---------
Co-authored-by: Firas Kafri <firaskafri@Firass-MacBook-Pro-2.local>
pre-commit is currently configured nicely but hasn't been part of the
Makefile setup and isn't mentioned in the contributing notes. This
change makes it so that pre-commit is installed as a part of the dev
setup, whereas before it had to be manually installed.
This test passes after reverting the `CustomField` resolver change
introduced in
https://github.com/graphql-python/graphene-django/pull/1315, but fails
with that resolver code present. For instance, adding back the resolver
code gives a test failure showing:
```
Failed: Expected to perform 2 queries but 11 were done
```
This should ensure there aren't regressions that prevent
query-optimization in the future.