Commit Graph

546 Commits

Author SHA1 Message Date
Kien Dang
79b4a23ae0
Miscellaneous CI fixes (#1447)
* 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
2023-08-09 20:48:42 +03:00
Laurent
db34d2e815
fix: foreign key nullable and custom resolver (#1446)
* fix: nullable one to one relation

* fix: makefile
2023-08-09 20:28:26 +03:00
Kien Dang
9a773b9d7b
Use ruff in pre-commit (#1441)
* 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
2023-08-06 01:47:00 +03:00
James
5d7a04fce9
Update mutation.py to serialize Enum objects into input values (#1431)
* 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>
2023-07-27 02:41:40 +03:00
Firas Kafri
3172710d12
exclude 'fans' from ReporterForm tests (#1434) 2023-07-18 20:35:51 +03:00
Tom Dror
b1abebdb97
Support base class relations and reverse for proxy models (#1380)
* 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>
2023-07-18 20:17:45 +03:00
Laurent
0de35ca3b0
fix: fk resolver permissions leak (#1411)
* fix: fk resolver permissions leak

* fix: only one query for 1o1 relation

* tests: added queries count check

* fix: docstring

* fix: typo

* docs: added warning to authorization

* feat: added bypass_get_queryset decorator
2023-07-18 15:16:52 +03:00
Firas Kafri
2fafa881a8
Bump version 2023-07-18 15:13:58 +03:00
Steven DeMartini
cd43022283
Maintain JSONField in graphene_django.compat module (#1429)
Fixes https://github.com/graphql-python/graphene-django/issues/1428

This should improve backwards compatibility, fixing issues in downstream
packages (notably graphene-django-cud
https://github.com/tOgg1/graphene-django-cud/issues/109, and also
graphene-django-extras, both of which depended on
`graphene_django.compat.JSONField`).

Co-authored-by: Steven DeMartini <sjdemartini@users.noreply.github.com>
2023-07-18 15:11:30 +03:00
Firas Kafri
e950164c8e
Bump version to 3.1.2 2023-06-17 09:29:18 +03:00
Steven DeMartini
2358bd30a4
Update compat.py MissingType results after PGJSONField removal (#1423)
As mentioned in https://github.com/graphql-python/graphene-django/pull/1421/files#r1221711648
2023-06-07 20:06:37 +03:00
Dulmandakh
8fa8aea3c0
remove JSONField compat (#1421)
* remove JSONFIeld compat

* fix black
2023-06-07 17:36:29 +03:00
Sezgin ACER
8934393909
Add check for serializers.HiddenField on fields_for_serializer function (#1419)
* Add check for `serializers.HiddenField` on fields_for_serializer function

* Add pre-commit changes
2023-06-06 09:20:32 +03:00
Steven DeMartini
520ddeabf6
Fix graphiql explorer styles by including official CSS, and update local example app for testing (#1418)
* 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>
2023-06-02 11:48:53 +03:00
Kien Dang
38709d8396
Correct schema write test (#1416)
<Mock>.called_once() just returns a Mock, so assert <Mock>.called_once()
always passes. We want <Mock>.assert_called_once().
2023-05-27 16:53:22 +03:00
Firas Kafri
ebf49431e9
Bump version 2023-05-24 16:10:22 +03:00
Firas Kafri
7fe661d423
Bump version 2023-05-24 16:03:14 +03:00
ndpu
be17278b49
Add DjangoFormInputObjectType to forms/types (#1325)
* 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>
2023-05-24 15:58:50 +03:00
Mykhailo Havelia
388ca41d64
fix: use execution_context_class attribute for GraphQLView (#1398)
* fix: use execution_context_class attribute for GraphQLView
2023-05-24 15:54:44 +03:00
shukryzablah
09f9b6d2f1
Remove redundant call to validate (#1393)
* 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>
2023-05-05 13:04:22 +03:00
Kien Dang
52f992183f
Add GraphiQL Explorer plugin (#1397) 2023-05-04 22:06:10 +03:00
Ülgen Sarıkavak
8540a9332c
Add support for Python 3.11 (#1365)
* Add support for Python 3.11

* Fix Python 3.11 compatibility matrix

* Add temporary fix for default enum description

---------

Co-authored-by: Firas Kafri <firaskafri@Firass-MacBook-Pro-2.local>
2023-05-04 15:19:24 +03:00
Firas K
af8888f58e
Upgrade github actions versions, default python and dev dependencies (#1407)
* 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>
2023-05-03 13:25:16 +03:00
Kien Dang
95a0642818 fix: fix graphiql request failure 2023-05-03 12:07:54 +03:00
Firas K
a8ceca77ed Bump version 2023-05-03 11:54:46 +03:00
Steven DeMartini
20a6cecc4c Add test validating query performance with select_related + prefetch_related
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.
2023-05-03 11:37:17 +03:00
Steven DeMartini
9796e93fc7 Remove obsolete tests and add note about rationale 2023-05-03 11:37:17 +03:00
Steven DeMartini
f67c5dbc8c Revert field resolver logic to fix poor query performance
This reverts the change to `convert_field_to_djangomodel` introduced in
https://github.com/graphql-python/graphene-django/pull/1315 for the
reasons discussed here
https://github.com/graphql-python/graphene-django/pull/1315/files#r1015659857.
As mentioned there, without reverting this code, "queries are forced
every time an object is resolved, making an exponential number of
queries when nesting without any possibility of optimizing".

That regression prevented `graphene-django-optimizer` from working with
`graphene-django` v3.0.0b9+ (where this change first was published), as
discussed in
https://github.com/graphql-python/graphene-django/issues/1356#issuecomment-1284718187,
https://github.com/tfoxy/graphene-django-optimizer/issues/86, and
https://github.com/tfoxy/graphene-django-optimizer/pull/83#issuecomment-1451987397.

For now, this marks the two tests that depended on this problematic code
as "expected to fail", and perhaps they can be reintroduced if there's a
way to support this logic in a way that does not prevent
`select_related` and `prefetch_related` query-optimization and introduce
nested N+1s.

As mentioned here
https://github.com/graphql-python/graphene-django/pull/1315#issuecomment-1468594361,
this is blocking upgrade to graphene-django v3 for many users, and
fixing this would allow many to begin upgrading and contributing to keep
graphene-django going.
2023-05-03 11:37:17 +03:00
Firas K
34cc86063b
☂️ v3.0.1 ☂️ 2023-04-29 20:26:39 +03:00
Firas K
a335042dbe
☂️ v3.0.1 ☂️ 2023-04-29 20:26:05 +03:00
Kien Dang
3283d0b1be Update GraphiQL to 2.4.1 2023-04-17 09:17:21 +03:00
Bendik Eger
1d814c54c4 Fix schema print with -.graphql 2023-04-10 14:52:10 +03:00
Josh Warwick
3b41aaf7bf Remove promise based middleware 2023-03-01 11:13:00 +03:00
Kien Dang
d18cab8aa4 Update graphiql to 1.4.7 2022-12-25 01:09:13 +03:00
Yuekui
86c5309c45
Fix broken UT due to pytest import error (#1368) 2022-11-14 13:56:18 +03:00
Nikolai Røed Kristiansen
4517e32224
👷 Add pre-commit (#1336)
* 🔧 Add pre-commit config

Similar to graphene and graphene-sqlalchemy

* ⬆ Bump black

* 👷 Lint on CI

* ⬆ Bump flake8-black

* 🔧 Keep excluding migrations

* ⬆ Bump flake8

* 🔧 Remove black and flake8 from tox config

* ⬆ Update pre-commit versions

* Upgrade syntax to python 3.7+

* Format with pre-commit

dedent docs/schema.py to allow formatting

* Fix tests on python 3.7
2022-10-19 17:10:30 +03:00
Syrus Akbary
f24cbd5148
Fix custom foreignkey resolvers (#1361)
* Fix custom foreignkey resolvers

* Fixed assert name conversion

* Fix lint
2022-10-17 16:57:24 +02:00
Firas K
ed7c995d8c
☂️ v3.0.0 ☂️ (#1355) 2022-09-26 15:08:32 +03:00
Syberen van Munster
bb03306075
Move testing endpoint to settings (#1105)
* Import testing endpoint from graphene settings

* Add documentation for TESTING_ENDPOINT setting

* Remove empty lines

* Run formatter

Co-authored-by: Firas K <3097061+firaskafri@users.noreply.github.com>
2022-09-26 01:56:22 +03:00
Firas K
c697e5c8c1
Bump version to v3.0.0b9 (#1353) 2022-09-26 01:27:22 +03:00
Suyeol Jeon
a78114ada3
Add support to persist GraphQL headers in GraphiQL (#1209) 2022-09-24 17:41:14 +03:00
Forest Anderson
0b2cc4ecb2
Fixed deprecation warning (#1313) 2022-09-24 16:00:45 +03:00
belkka
60b3032014
Fix type hint for DjangoObjectTypeOptions.model (#1269)
Proper type is `typing.Type[Model]`, not `Model`
2022-09-24 16:00:12 +03:00
Craig
05d3df92e7
Delay assignment of csrftoken (#1289) 2022-09-24 15:59:53 +03:00
Firas K
541caa117e
Fixes related to pr#1412 (#1352)
* fix: setup.py graphene dependency

* fix: graphene_django/tests/test_get_queryset.py format

Co-authored-by: Firas Kafri <firaskafri@Firass-MacBook-Pro-2.local>
2022-09-24 15:50:40 +03:00
Semyon Pupkov
0f40da7b31
Make errors in form mutation non nullable (#1286) 2022-09-23 11:47:10 +03:00
Thomas Leonard
5d81ba04f9
fix: unit test for graphene pr#1412 (#1315)
* Issue #1111: foreign key should also call get_queryset method

* fix: test for graphene PR https://github.com/graphql-python/graphene/pull/1412

Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
2022-09-23 11:45:02 +03:00
Firas K
b2f83eb277
Bump version to 3.0.0b8 (#1348) 2022-09-23 11:38:11 +03:00
andrei-datcu
56892d7f4b
Cast translated description for DecimalField (#1255)
* Cast translated description for DecimalField

https://github.com/graphql-python/graphene-django/pull/976 casts all the description fields to strings to prevent schema printing from failing whenever the description is a lazy translated string. The `DecimalField` however got in after the v3 merge and it currently misses the cast.

* Fix row size
2022-09-22 19:13:30 +01:00
Thomas Leonard
a53ded611b
feat: update name of DjangoFilterConnectionField type input to be consistent with graphene (Issue #1316) (#1317)
Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
2022-09-22 19:09:29 +01:00