Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default values for input objects #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions graphene_mongo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def construct_self_referenced_fields(self_referenced, registry):
return fields


def create_graphene_generic_class(object_type, option_type):
def create_graphene_generic_class(object_type, option_type, field_type):
class MongoengineGenericObjectTypeOptions(option_type):

model = None
Expand Down Expand Up @@ -124,7 +124,7 @@ def __init_subclass_with_meta__(
model, registry, only_fields, exclude_fields, non_required_fields
)
mongoengine_fields = yank_fields_from_attrs(
converted_fields, _as=graphene.Field
converted_fields, _as=field_type
)
if use_connection is None and interfaces:
use_connection = any(
Expand Down Expand Up @@ -188,7 +188,7 @@ def __init_subclass_with_meta__(
)
if converted_fields:
mongoengine_fields = yank_fields_from_attrs(
converted_fields, _as=graphene.Field
converted_fields, _as=field_type
)
cls._meta.fields.update(mongoengine_fields)
registry.register(cls)
Expand All @@ -206,7 +206,7 @@ def rescan_fields(cls):
)

mongoengine_fields = yank_fields_from_attrs(
converted_fields, _as=graphene.Field
converted_fields, _as=field_type
)

# The initial scan should take precedence
Expand Down Expand Up @@ -247,9 +247,14 @@ def resolve_id(self, info):
return GrapheneMongoengineGenericType, MongoengineGenericObjectTypeOptions


MongoengineObjectType, MongoengineObjectTypeOptions = create_graphene_generic_class(ObjectType, ObjectTypeOptions)
MongoengineInterfaceType, MongoengineInterfaceTypeOptions = create_graphene_generic_class(Interface, InterfaceOptions)
MongoengineObjectType, MongoengineObjectTypeOptions = create_graphene_generic_class(ObjectType,
ObjectTypeOptions,
graphene.Field)
MongoengineInterfaceType, MongoengineInterfaceTypeOptions = create_graphene_generic_class( Interface,
InterfaceOptions,
graphene.Field)
MongoengineInputType, MongoengineInputTypeOptions = create_graphene_generic_class(InputObjectType,
InputObjectTypeOptions)
InputObjectTypeOptions,
graphene.InputField)

GrapheneMongoengineObjectTypes = (MongoengineObjectType, MongoengineInputType, MongoengineInterfaceType)
Loading