Commit Graph

570 Commits

Author SHA1 Message Date
Alexandre Detiste
269225085d
remove dead code: singledispatch has been in the standard library ... (#1534)
* remove dead code: singledispatch has been in the stard library for many years

(BTW this function does not seems to be used anywhere anymore)

* lint
2024-09-15 21:50:15 +07:00
Markus Richter
28c71c58f7 Bump to 3.2.2 2024-06-12 10:52:45 +08:00
Kien Dang
6f21dc7a94
Not require explicitly set ordering in DjangoConnectionField (#1518)
* Revert "feat!: check django model has a default ordering when used in a relay connection (#1495)"

This reverts commit 96c09ac439.

* Fix assert no warning for pytest>=8
2024-04-18 12:00:31 +08:00
Ülgen Sarıkavak
ea45de02ad
Make use of http.HTTPStatus for response status code checks (#1487) 2024-04-09 03:43:34 +03:00
Kien Dang
d69c90550f
Bump to 3.2.1 (#1512) 2024-04-09 03:37:32 +03:00
Alisson Patricio
45c2aa09b5
Allows field's choices to be a callable (#1497)
* Allows field's choices to be a callable

Starting in Django 5 field's choices can also be a callable

* test if field with callable choices converts into enum

---------

Co-authored-by: Kien Dang <mail@kien.ai>
2024-03-21 00:48:51 +08:00
Diogo Silva
ac09cd2967
fix: Fix broke 'get_choices' with restframework 3.15.0 (#1506) 2024-03-18 09:58:47 +08:00
Thomas Leonard
96c09ac439
feat!: check django model has a default ordering when used in a relay connection (#1495)
Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
2024-01-30 12:09:18 +03:00
Laurent
b85177cebf
fix: same type list (#1492)
* fix: same type list

* chore: improve test
2024-01-20 16:36:00 +08:00
Firas Kafri
4d0484f312
Bump version 2023-12-20 13:22:33 +03:00
Noxx
c416a2b0f5
Provide setting to enable/disable converting choices to enums globally (#1477)
Co-authored-by: Firas Kafri <3097061+firaskafri@users.noreply.github.com>
Co-authored-by: Kien Dang <mail@kien.ai>
2023-12-20 17:55:15 +08:00
Kien Dang
feb7252b8a
Add support for validation rules (#1475)
* Add support for validation rules

* Enable customizing validate max_errors through settings

* Add tests for validation rules

* Add examples for validation rules

* Allow setting validation_rules in class def

* Add tests for validation_rules inherited from parent class

* Make tests for validation rules stricter
2023-12-20 12:48:45 +03:00
Firas Kafri
3a64994e52
Bump version (#1486) 2023-12-20 12:44:40 +03:00
danthewildcat
e735f5dbdb
Optimize views (#1439)
* Optimize execute_graphql_request

* Require operation_ast to be found by view handler

* Remove unused show_graphiql kwarg

* Old style if syntax

* Revert "Remove unused show_graphiql kwarg"

This reverts commit 33b3426092.

* Add missing schema validation step

* Pass args directly to improve clarity

* Remove duplicated operation_ast not None check

---------

Co-authored-by: Firas Kafri <3097061+firaskafri@users.noreply.github.com>
Co-authored-by: Kien Dang <mail@kien.ai>
2023-10-29 23:42:27 +08:00
Kien Dang
36cf100e8b
Use ruff format to replace black (#1473)
* Use ruff format to replace black

* Adjust ruff config to be compatible with ruff-format

https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules

* Format

* Replace black with ruff format in Makefile
2023-10-25 11:33:00 +03:00
Kien Dang
e8f36b018d
Fix test Client headers for Django 4.2 (#1465)
* Fix test Client headers for Django 4.2

* Lazy import pkg_resources

since it could be quite heavy

* Remove use of pkg_resources altogether
2023-09-18 23:23:53 +08:00
mnasiri
83d3d27f14
Fix graphiql explorer styles by sending graphiql_plugin_explorer_css_sri param to render_graphiql function of the GraphQlView (#1418) (#1460) 2023-09-14 00:26:18 +08:00
Romain Létendart
ee7560f629
Support displaying deprecated input fields in GraphiQL docs (#1458)
* Update GraphiQL docs URL in docs/settings

And deduplicate link declaration.

* Support displaying deprecated input fields in GraphiQL docs
2023-09-13 09:49:01 +03:00
lilac-supernova-2
67def2e074
Typo fixes (#1459)
* Fix Star Wars spaceship name

* Fix some typos in comments

* Typo fixes

* More typo fixes
2023-09-06 10:29:58 +03:00
mahmoudmostafa0
e49a01c189
adding optional_field in Serializermutation to enfore some fields to be optional (#1455)
* 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>
2023-08-28 00:15:35 +03:00
Thomas Leonard
0473f1a9a3
fix: empty list is not an empty value for list filters even when a custom filtering method is provided (#1450)
Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
2023-08-11 23:24:58 +08:00
Firas Kafri
4ac3f3f42d
Update __init__.py 2023-08-10 01:12:15 +03:00
Firas Kafri
ee7598e71a
Remove typo 2023-08-09 23:41:57 +03:00
Firas Kafri
05d7fb5396
Bump version 2023-08-09 20:49:51 +03:00
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