diff --git a/graphene_mongo/advanced_types.py b/graphene_mongo/advanced_types.py index b5bd8921..216d33f5 100644 --- a/graphene_mongo/advanced_types.py +++ b/graphene_mongo/advanced_types.py @@ -2,10 +2,6 @@ import graphene -def _resolve_type_coordinates(self, info): - return self['coordinates'] - - def _resolve_fs_field(field, name, default_value=None): v = getattr(field.instance, field.key) return getattr(v, name, default_value) @@ -39,33 +35,34 @@ def resolve_data(self, info): return None -class _TypeField(graphene.ObjectType): +class _CoordinatesTypeField(graphene.ObjectType): type = graphene.String() def resolve_type(self, info): return self['type'] + def resolve_coordinates(self, info): + return self['coordinates'] -class PointFieldType(_TypeField): - coordinates = graphene.List( - graphene.Float, resolver=_resolve_type_coordinates) +class PointFieldType(_CoordinatesTypeField): + coordinates = graphene.List(graphene.Float) -class PolygonFieldType(_TypeField): + +class PolygonFieldType(_CoordinatesTypeField): coordinates = graphene.List( graphene.List( - graphene.List(graphene.Float)), - resolver=_resolve_type_coordinates + graphene.List(graphene.Float)) ) -class MultiPolygonFieldType(_TypeField): +class MultiPolygonFieldType(_CoordinatesTypeField): coordinates = graphene.List( graphene.List( graphene.List( - graphene.List(graphene.Float))), - resolver=_resolve_type_coordinates) + graphene.List(graphene.Float))) + )