|
2 | 2 | import graphene
|
3 | 3 |
|
4 | 4 |
|
5 |
| -def _resolve_type_coordinates(self, info): |
6 |
| - return self['coordinates'] |
7 |
| - |
8 |
| - |
9 | 5 | def _resolve_fs_field(field, name, default_value=None):
|
10 | 6 | v = getattr(field.instance, field.key)
|
11 | 7 | return getattr(v, name, default_value)
|
@@ -39,33 +35,34 @@ def resolve_data(self, info):
|
39 | 35 | return None
|
40 | 36 |
|
41 | 37 |
|
42 |
| -class _TypeField(graphene.ObjectType): |
| 38 | +class _CoordinatesTypeField(graphene.ObjectType): |
43 | 39 |
|
44 | 40 | type = graphene.String()
|
45 | 41 |
|
46 | 42 | def resolve_type(self, info):
|
47 | 43 | return self['type']
|
48 | 44 |
|
| 45 | + def resolve_coordinates(self, info): |
| 46 | + return self['coordinates'] |
49 | 47 |
|
50 |
| -class PointFieldType(_TypeField): |
51 | 48 |
|
52 |
| - coordinates = graphene.List( |
53 |
| - graphene.Float, resolver=_resolve_type_coordinates) |
| 49 | +class PointFieldType(_CoordinatesTypeField): |
54 | 50 |
|
| 51 | + coordinates = graphene.List(graphene.Float) |
55 | 52 |
|
56 |
| -class PolygonFieldType(_TypeField): |
| 53 | + |
| 54 | +class PolygonFieldType(_CoordinatesTypeField): |
57 | 55 |
|
58 | 56 | coordinates = graphene.List(
|
59 | 57 | graphene.List(
|
60 |
| - graphene.List(graphene.Float)), |
61 |
| - resolver=_resolve_type_coordinates |
| 58 | + graphene.List(graphene.Float)) |
62 | 59 | )
|
63 | 60 |
|
64 | 61 |
|
65 |
| -class MultiPolygonFieldType(_TypeField): |
| 62 | +class MultiPolygonFieldType(_CoordinatesTypeField): |
66 | 63 |
|
67 | 64 | coordinates = graphene.List(
|
68 | 65 | graphene.List(
|
69 | 66 | graphene.List(
|
70 |
| - graphene.List(graphene.Float))), |
71 |
| - resolver=_resolve_type_coordinates) |
| 67 | + graphene.List(graphene.Float))) |
| 68 | + ) |
0 commit comments