-
Notifications
You must be signed in to change notification settings - Fork 766
Convert GeometryField (fixes #390) #392
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
Conversation
In my own project using graphql I prefer having GeometryField to not serialize as a string but a generic scalar because we're using geojson and the client doesn't bother (de)serializing json but gets direct objects. Aside from that, we probably shouldn't be importing Here is what I have for reference:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm inclined to agree with @zbyte64. In general I think custom scalars for complex data like this are more useful. Converting this to a string would require more processing on the client, and if the client is a web frontend using a mapping tool, that might be unnecessarily complex.
Serialising to some generic JSON, or even to a custom type that is represented "on the wire" with an object structure feels like it will be simpler for more clients to use, and also plays to GraphQL's strengths with its use of the type system, particularly with a custom type.
If we do go down one of these two routes, which I am strongly in favour of, I think we should document this somewhere, perhaps in a new document describing how Graphene treats complex type (such as the IP addresses, File fields, etc that have default converters).
If we don't think that specific types are the correct way to handle this, I'd suggest that we may want to not provide this at all, forcing users to implement custom scalars. Our documentation around this could be better, but in general I think more custom scalars create more type safety, and are a good thing.
I don't know enough about GeometryField's in Django to be able to contribute here but I would say that (as @danpalmer mentions) generally creating customer scalar fields that are typed to match the underlying data model is a good thing. I'm not sure whether it is up to graphene-django to define what that type should look like this case but I don't see why not since GeometryField is part of Django. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
the PR convert Geometry fields to well-known text (WKT):