Skip to content

Commit

Permalink
Merge pull request #108 from tOgg1/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tOgg1 committed Jul 11, 2023
2 parents 82e3662 + b09e91e commit 6cb0045
Show file tree
Hide file tree
Showing 58 changed files with 1,027 additions and 1,286 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
push:
branches: [ develop, master ]

jobs:
pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: pre-commit/action@v2.0.3
34 changes: 14 additions & 20 deletions .github/workflows/primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,33 @@ on:
jobs:
test:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ["3.7", "3.8", "3.9", "3.10"]
poetry-version: ["1.3.1"]

steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Run image
uses: abatilo/actions-poetry@v2.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
pip install poetry==1.1.4
poetry config virtualenvs.in-project true
- name: Cache pip
uses: actions/cache@v1
poetry-version: ${{ matrix.poetry-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
path: .venv
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version}}-pip-
${{ runner.os }}-${{ matrix.python-version}}-
${{ runner.os }}-
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: poetry install --no-interaction
run: poetry install
- name: Test with coverage
run: |
make test-cov
release:
needs: test
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
Expand All @@ -51,7 +45,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.9
- name: Install dependencies
run: |
pip install twine
Expand Down
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3.8
exclude: (migrations/|locale/|docs/)
args:
- --line-length=120
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
exclude: (migrations/|locale/|docs/)
args:
- --max-line-length=120
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Changelog

## Version 0.11.0

* Fix graphene-django 3.x compatibility issues (thanks @sjdemartini, @wito-alex).
* Improve documentation (thanks @sjdemartini, @Plebbimon).
* Add `perform_delete` override to `DjangoDeleteMutation` (thanks @calummackervoy). This allows for better soft deletes.
* Add `get_return_id` override to `DjangoBatchDeleteMutation`, enabling ID overwrites (thanks @rymanso).
* Fix compatability issues with custom pks (thanks @NwawelAIroume).
* Bump some package versions.
* Some general project and file clean up.
* Remove debug prints. Pardon all the mlogs.

## Version 0.10.0

* Put `select_for_update` behind a new option `use_select_for_update`, which is enabled by default.
* Rename `only_fields` -> `fields` and `exclude_fields` -> `exclude`. Alias the old names but add deprecation warnings.
* Make the library graphene(-django) 3.x compatible.
* Respect required_fields in Patch and BatchPatch mutations (thanks @mbuvarp).

## Version 0.9.1

* Improve atomicity of patch/update-calls (thanks @keithhackbarth)
* Improve documentation
* Security-critical package updates
Expand All @@ -15,7 +28,7 @@
* (BREAKING) Ensure inputs are sent to all after_mutate hooks.

## Version 0.8.1
* (BREAKING) DjangoDeleteMutation now returns three id fields: deletedId, deletedRawId and deletedInputId. The default behaviour of deletedId is now to return a global id if the associated model type has a GlobalIDField for the "id" field.
* (BREAKING) DjangoDeleteMutation now returns three id fields: deletedId, deletedRawId and deletedInputId. The default behaviour of deletedId is now to return a global id if the associated model type has a GlobalIDField for the "id" field.

## Version 0.8.0
* Add customisation of resolving IDs via the resolve_id(s) methods (@bjmc)
Expand Down Expand Up @@ -185,4 +198,3 @@ Initial release, add core and classes:
* DjangoUpdateMutation
* DjangoDeleteMutation
* DjangoBatchDeleteMutation

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ build:
.PHONY: release
release:
poetry run twine upload dist/*


4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CreateUserMutation(DjangoCreateMutation):
class Mutation(graphene.ObjectType):
create_user = CreateUserMutation.Field()


class Query(graphene.ObjectType):
user = graphene.Field(UserNode, id=graphene.String())

Expand All @@ -75,7 +75,7 @@ mutation {
id
name
address
}
}
}
}
```
Expand Down
58 changes: 31 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,42 @@

from sphinx.highlighting import lexers

project = 'graphene-django-cud'
copyright = '2021, Tormod Haugland'
author = 'Tormod Haugland'
project = "graphene-django-cud"
copyright = "2021, Tormod Haugland"
author = "Tormod Haugland"

# The full version, including alpha/beta/rc tags
release = '0.10.0'
release = "0.11.0"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_rtd_theme"
]
extensions = ["sphinx_rtd_theme"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

master_doc = 'index'
master_doc = "index"

# Add custom graphql lexer

Expand All @@ -80,24 +78,30 @@ class GraphqlLexer(RegexLexer):
Lexer for GraphQL.
"""

name = 'GraphQL'
aliases = ['graphql', 'gql']
filenames = ['*.graphql', '*.gql']
mimetypes = ['application/graphql']
name = "GraphQL"
aliases = ["graphql", "gql"]
filenames = ["*.graphql", "*.gql"]
mimetypes = ["application/graphql"]

tokens = {
'root': [
(r'#.*', Comment.Singline),
(r'\.\.\.', Operator),
"root": [
(r"#.*", Comment.Singline),
(r"\.\.\.", Operator),
(r'"([^\\"]|\\")*"', String.Double),
(r'(-?0|-?[1-9][0-9]*)(\.[0-9]+[eE][+-]?[0-9]+|\.[0-9]+|[eE][+-]?[0-9]+)', Number.Float),
(r'(-?0|-?[1-9][0-9]*)', Number.Integer),
(r'\$+[_A-Za-z][_0-9A-Za-z]*', Name.Variable),
(r'[_A-Za-z][_0-9A-Za-z]+\s?:', Text),
(r'(type|query|fragment|mutation|@[a-z]+|on|true|false|null)\b', Keyword.Type),
(r'[!$():=@\[\]{|}]+?', Punctuation),
(r'[_A-Za-z][_0-9A-Za-z]*', Keyword),
(r'(\s|,)', Text),
(
r"(-?0|-?[1-9][0-9]*)(\.[0-9]+[eE][+-]?[0-9]+|\.[0-9]+|[eE][+-]?[0-9]+)",
Number.Float,
),
(r"(-?0|-?[1-9][0-9]*)", Number.Integer),
(r"\$+[_A-Za-z][_0-9A-Za-z]*", Name.Variable),
(r"[_A-Za-z][_0-9A-Za-z]+\s?:", Text),
(
r"(type|query|fragment|mutation|@[a-z]+|on|true|false|null)\b",
Keyword.Type,
),
(r"[!$():=@\[\]{|}]+?", Punctuation),
(r"[_A-Za-z][_0-9A-Za-z]*", Keyword),
(r"(\s|,)", Text),
]
}

Expand Down
1 change: 0 additions & 1 deletion docs/guide/auto-context-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ that auto context fields are automatically set as ``required=False``, to
please Graphene. Finally note that if we add an explicit value to the
``createdBy`` field when calling the mutation, this value will override
the auto context field.

1 change: 0 additions & 1 deletion docs/guide/custom-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ Running the below mutation will increase the bark count by one:
barkCount
}
}
2 changes: 0 additions & 2 deletions docs/guide/field-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ Django model field; then you must implement a :ref:`custom handler<custom_field_
@classmethod
def handle_tag(cls, value, *args, **kwargs):
return "Dog-" + str(value)
2 changes: 1 addition & 1 deletion docs/guide/included-and-excluded-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ included, and let all others be excluded. This can be achieved with the ``only_f
If both ``only_fields`` and ``exclude_fields`` are supplied, first the fields matching ``only_fields`` are extracted,
and then the fields matching ``exclude_fields`` are removed from this list.
and then the fields matching ``exclude_fields`` are removed from this list.
1 change: 0 additions & 1 deletion docs/guide/mutations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,3 @@ The mutation returns two fields for resolving:
}
}
}
2 changes: 1 addition & 1 deletion docs/guide/naming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ The two others can be customized by the following meta parameters:
Given the existence of `GraphQL aliasing`_, the utility of the latter is questionable.

.. _GraphQL aliasing: https://graphql.org/learn/queries/#aliases
.. _GraphQL aliasing: https://graphql.org/learn/queries/#aliases
25 changes: 24 additions & 1 deletion docs/guide/nested-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Cat objects to be added by id.
Many to many extras
~~~~~~~~~~~~~~~~~~~

The ``many_to_one_extras`` field is a dictionary containing information
The ``many_to_many_extras`` field is a dictionary containing information
regarding how to handle many to many relations. Suppose we have the
``Cat`` model as above, and a ``Dog`` model like:

Expand Down Expand Up @@ -358,6 +358,29 @@ The name of the argument will be ``killEnemies`` instead of the default
``enemiesKill``. The name will be translated from snake\_case to
camelCase as per usual.

Excluding fields
~~~~~~~~~~~~~~~~~~~~~~~~~~

By default, all fields are included in the input type. However, you can
exclude fields by using the ``exclude_fields`` attribute:

.. code:: python
class CreateDogMutation(DjangoCreateMutation):
class Meta:
model = Dog
many_to_many_extras = {
"enemies": {
"exact": {
"type": "CreateCatInput",
"exclude_fields": ("name",),
},
}
}
This will exclude the ``name`` field from the input type.


Deep nested arguments
~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 0 additions & 1 deletion docs/guide/optional-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ A field can explicitly be marked as optional or required with the meta-attribute
model = User
required_fields = ("first_name",)
optional_fields = ("last_name",)
1 change: 0 additions & 1 deletion docs/ref/models/DjangoBatchDeleteMutation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ All meta arguments:
deletionCount
}
}
1 change: 0 additions & 1 deletion docs/ref/models/DjangoFilterDeleteMutation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ If there are multiple filters, these will be combined with
deletionCount
}
}
1 change: 0 additions & 1 deletion docs/ref/models/DjangoFilterUpdateMutation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ If there are multiple filters, these will be combined with
}
}
}
2 changes: 0 additions & 2 deletions docs/ref/models/DjangoUpdateMutation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,3 @@ All meta arguments:
}
}
}
1 change: 0 additions & 1 deletion graphene_django_cud/consts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

OPERATION_UPDATE = "update"
OPERATION_DELETE = "delete"
OPERATION_CREATE = "create"
Expand Down

0 comments on commit 6cb0045

Please sign in to comment.