mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Added InputObjectType and InputObjectField
This commit is contained in:
parent
ea5207d025
commit
2bab94d72f
|
@ -11,9 +11,10 @@ from graphql.core.type import (
|
|||
GraphQLID,
|
||||
GraphQLArgument,
|
||||
GraphQLFloat,
|
||||
GraphQLInputObjectField,
|
||||
)
|
||||
from graphene.utils import to_camel_case
|
||||
from graphene.core.types import BaseObjectType
|
||||
from graphene.core.types import BaseObjectType, InputObjectType
|
||||
from graphene.core.scalars import GraphQLSkipField
|
||||
|
||||
|
||||
|
@ -145,7 +146,12 @@ class Field(object):
|
|||
return self.resolve(*args)
|
||||
else:
|
||||
resolver = self.resolve
|
||||
return GraphQLField(
|
||||
|
||||
field_type = GraphQLField
|
||||
if object_type and issubclass(object_type, InputObjectType):
|
||||
field_type = GraphQLInputObjectField
|
||||
|
||||
return field_type(
|
||||
internal_type,
|
||||
description=description,
|
||||
args=args,
|
||||
|
|
|
@ -5,6 +5,7 @@ from collections import OrderedDict
|
|||
|
||||
from graphql.core.type import (
|
||||
GraphQLObjectType,
|
||||
GraphQLInputObjectType,
|
||||
GraphQLInterfaceType,
|
||||
GraphQLArgument
|
||||
)
|
||||
|
@ -170,9 +171,8 @@ class BaseObjectType(object):
|
|||
@memoize
|
||||
@register_internal_type
|
||||
def internal_type(cls, schema):
|
||||
fields_list = cls._meta.fields
|
||||
fields = lambda: OrderedDict([(f.name, f.internal_field(schema))
|
||||
for f in fields_list])
|
||||
for f in cls._meta.fields])
|
||||
if cls._meta.is_interface:
|
||||
return GraphQLInterfaceType(
|
||||
cls._meta.type_name,
|
||||
|
@ -200,3 +200,17 @@ class ObjectType(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
|
|||
|
||||
class Mutation(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
|
||||
pass
|
||||
|
||||
|
||||
class InputObjectType(ObjectType):
|
||||
@classmethod
|
||||
@memoize
|
||||
@register_internal_type
|
||||
def internal_type(cls, schema):
|
||||
fields = lambda: OrderedDict([(f.name, f.internal_field(schema))
|
||||
for f in cls._meta.fields])
|
||||
return GraphQLInputObjectType(
|
||||
cls._meta.type_name,
|
||||
description=cls._meta.description,
|
||||
fields=fields,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user