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

Using of this module makes types to be incompatible with custom interfaces #4

Open
artemnesterenko opened this issue Jun 27, 2018 · 4 comments
Labels
bug Something isn't working

Comments

@artemnesterenko
Copy link

artemnesterenko commented Jun 27, 2018

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?

@artemnesterenko artemnesterenko changed the title Using of this module makes models to be incompatible with custom interfaces Using of this module makes types to be incompatible with custom interfaces Jun 27, 2018
@mongkok
Copy link
Member

mongkok commented Jun 29, 2018

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?

@artemnesterenko
Copy link
Author

artemnesterenko commented Jul 2, 2018

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.

@artemnesterenko
Copy link
Author

Any update on this?

@mongkok mongkok added the bug Something isn't working label Aug 12, 2018
@mongkok
Copy link
Member

mongkok commented Aug 12, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants