django-graphql-geojson
django-graphql-geojson copied to clipboard
Using of this module makes types to be incompatible with custom interfaces
I have several types for which I want to make a search. I've created a Searchable interface which requires a displayName
field to be in a type and I've added the field to all appropriate types. But a type inherited from GeoJSONType doesn't conform to the Searchable interface eventually, because it's displayName
is located in properties. How can I make things work properly?
Hi @artemnesterenko,
All declared fields from a GeoJSONType
class are moved to properties
field, we could add a field within GeoJSONType.Meta
to exclude some properties
.
Could you paste the code for the Searchable interface?
Hi @mongkok!
from django.contrib.gis.db import models
from graphene import Interface, NonNull, String, Node
import graphql_geojson
class MyModel(models.Model):
name = models.CharField(max_length=32, blank=False, null=False)
location = models.MultiPolygonField(blank=True, null=True)
class Searchable(Interface):
display_name = NonNull(String)
class MyGeoType(graphql_geojson):
display_name = NonNull(String)
def resolve_display_name(self, info, **kwargs):
return self.name
class Meta:
model = MyModel
geojson_field = 'location'
interfaces = (Node, Searchable)
So, interface fields can be defined not only in models themselves but also in GraphQL types.
Any update on this?
Hi @artemnesterenko, I am sorry for the long long delay to response.
Graphene interfaces are not compatible for GeoJSONType.
I am trying to move the interfaces fields within the properties
field but I can not find an easy way to do this, I will keep you updated with new changes