mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-16 19:40:39 +03:00
Improved Mutation warning
This commit is contained in:
parent
c7c611266b
commit
6dde81ee65
|
@ -9,6 +9,7 @@ developer have to write to use them.
|
||||||
Deprecations:
|
Deprecations:
|
||||||
* [`AbstractType`](#abstracttype-deprecated)
|
* [`AbstractType`](#abstracttype-deprecated)
|
||||||
* [`resolve_only_args`](#resolve_only_args)
|
* [`resolve_only_args`](#resolve_only_args)
|
||||||
|
* [`Mutation.Input`](#mutation-input)
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
* [`Node Connections`](#node-connections)
|
* [`Node Connections`](#node-connections)
|
||||||
|
@ -72,6 +73,26 @@ class User(ObjectType):
|
||||||
return self.name
|
return self.name
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Mutation.Input
|
||||||
|
|
||||||
|
`Mutation.Input` is now deprecated in favor using `Mutation.Arguments` (`ClientIDMutation` still uses `Input`).
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class User(Mutation):
|
||||||
|
class Input:
|
||||||
|
name = String()
|
||||||
|
```
|
||||||
|
|
||||||
|
With 2.0:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class User(Mutation):
|
||||||
|
class Arguments:
|
||||||
|
name = String()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Breaking Changes
|
## Breaking Changes
|
||||||
|
|
||||||
|
@ -177,6 +198,25 @@ class Dog(ObjectType, interfaces=[Pet]):
|
||||||
name = String()
|
name = String()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Abstract types
|
||||||
|
|
||||||
|
Now you can create abstact types super easily, without the need of subclassing the meta.
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Base(ObjectType):
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
id = ID()
|
||||||
|
|
||||||
|
def resolve_id(self):
|
||||||
|
return "{type}_{id}".format(
|
||||||
|
type=self.__class__.__name__,
|
||||||
|
id=self.id
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
### UUID Scalar
|
### UUID Scalar
|
||||||
|
|
||||||
In Graphene 2.0 there is a new dedicated scalar for UUIDs, `UUID`.
|
In Graphene 2.0 there is a new dedicated scalar for UUIDs, `UUID`.
|
||||||
|
|
|
@ -6,6 +6,7 @@ from .field import Field
|
||||||
from .objecttype import ObjectType, ObjectTypeOptions
|
from .objecttype import ObjectType, ObjectTypeOptions
|
||||||
from .utils import yank_fields_from_attrs
|
from .utils import yank_fields_from_attrs
|
||||||
from ..utils.auto_resolver import auto_resolver
|
from ..utils.auto_resolver import auto_resolver
|
||||||
|
from ..utils.deprecated import warn_deprecation
|
||||||
|
|
||||||
|
|
||||||
class MutationOptions(ObjectTypeOptions):
|
class MutationOptions(ObjectTypeOptions):
|
||||||
|
@ -40,7 +41,11 @@ class Mutation(ObjectType):
|
||||||
if not input_class:
|
if not input_class:
|
||||||
input_class = getattr(cls, 'Input', None)
|
input_class = getattr(cls, 'Input', None)
|
||||||
if input_class:
|
if input_class:
|
||||||
print("WARNING: Please use Arguments for Mutation (Input is for ClientMutationID)")
|
warn_deprecation((
|
||||||
|
"Please use {name}.Arguments instead of {name}.Input."
|
||||||
|
"Input is now only used in ClientMutationID.\n"
|
||||||
|
"Read more: https://github.com/graphql-python/graphene/blob/2.0/UPGRADE-v2.0.md#mutation-input"
|
||||||
|
).format(name=cls.__name__))
|
||||||
|
|
||||||
if input_class:
|
if input_class:
|
||||||
arguments = props(input_class)
|
arguments = props(input_class)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user