mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Added support for Enum Python data structure
This commit is contained in:
parent
d7e1d9c598
commit
e82c680fd1
|
@ -1,5 +1,10 @@
|
|||
import inspect
|
||||
import six
|
||||
try:
|
||||
from enum import Enum
|
||||
except ImportError:
|
||||
class Enum(object):
|
||||
pass
|
||||
from functools import total_ordering, wraps
|
||||
from graphql.core.type import (
|
||||
GraphQLField,
|
||||
|
@ -101,8 +106,11 @@ class Field(object):
|
|||
|
||||
def internal_type(self, schema):
|
||||
field_type = self.field_type
|
||||
_is_class = inspect.isclass(field_type)
|
||||
if isinstance(field_type, Field):
|
||||
field_type = self.field_type.internal_type(schema)
|
||||
elif _is_class and issubclass(field_type, Enum):
|
||||
field_type = enum_to_graphql_enum(field_type)
|
||||
else:
|
||||
object_type = self.get_object_type(schema)
|
||||
if object_type:
|
||||
|
|
|
@ -2,6 +2,7 @@ from .str_converters import to_camel_case, to_snake_case
|
|||
from .proxy_snake_dict import ProxySnakeDict
|
||||
from .caching import cached_property, memoize
|
||||
from .lazymap import LazyMap
|
||||
from .misc import enum_to_graphql_enum
|
||||
|
||||
__all__ = ['to_camel_case', 'to_snake_case', 'ProxySnakeDict',
|
||||
'cached_property', 'memoize', 'LazyMap']
|
||||
'cached_property', 'memoize', 'LazyMap', 'enum_to_graphql_enum']
|
||||
|
|
Loading…
Reference in New Issue
Block a user