mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Improved Field args
This commit is contained in:
parent
2ed800bae3
commit
8fb4214809
|
@ -3,8 +3,9 @@ from collections import Mapping, OrderedDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from ..utils.orderedtype import OrderedType
|
from ..utils.orderedtype import OrderedType
|
||||||
from .argument import to_arguments
|
from .argument import Argument, to_arguments
|
||||||
from .structures import NonNull
|
from .structures import NonNull
|
||||||
|
from .unmountedtype import UnmountedType
|
||||||
|
|
||||||
|
|
||||||
def source_resolver(source, root, args, context, info):
|
def source_resolver(source, root, args, context, info):
|
||||||
|
@ -30,6 +31,16 @@ class Field(OrderedType):
|
||||||
if required:
|
if required:
|
||||||
type = NonNull(type)
|
type = NonNull(type)
|
||||||
|
|
||||||
|
# Check if name is actually an argument of the field
|
||||||
|
if isinstance(name, (Argument, UnmountedType)):
|
||||||
|
extra_args['name'] = name
|
||||||
|
name = None
|
||||||
|
|
||||||
|
# Check if source is actually an argument of the field
|
||||||
|
if isinstance(source, (Argument, UnmountedType)):
|
||||||
|
extra_args['source'] = source
|
||||||
|
source = None
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self._type = type
|
self._type = type
|
||||||
self.args = to_arguments(args or OrderedDict(), extra_args)
|
self.args = to_arguments(args or OrderedDict(), extra_args)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user