I need to be able to use the point and box Geometric types. It looks like these currently fallback into strings in the PostGraphQL API.
I'm able to get my use case to work by using ::box and ::point. I'm very new to PostgreSQL so I don't know if this is the right way to have this work or not. PostGraphQL still only recognizes them as strings. My schema calls them point and box and then explicitly handles text input to work like point and box. The procedure looks like this:
create function search_resources(search text, bounds box)
returns setof resource as $$
select * from resource
where
resource.place_id in (
select place.id from place
where bounds::box @> place.coords::point
) and
(resource.name ilike ('%' || search || '%')
or resource.description ilike ('%' || search || '%'))
$$ language sql stable;
And it works, so this may not be an issue.
In order to implement this, all we need is a parser for the geometric types. If someone wanted to write and publish this to pg-geometric, we could integrate fairly easily :+1:
This parsing could also be added directly to the pg package for better type parsing for the entire community.
PostGraphQL v4 will allow you to add plugins which extend the PG types that PostGraphQL understands 👍
I'm also encountering this issue now, wondering what is the current workaround? Has there been any changes?
Also based on the post, what would be the value format of the string be when updating a point type attribute?
This plugin currently registers all the types we support explicitly. It should be feasible to write another plugin that adds support for additional types, but I'm afraid there's no documentation around it currently.
Regarding the string format, you should look this up in the relevant documentation for the Postgres module you're using.
Thanks for the swift response. The plugin system in v4 looks very promising for extensibility.
When you mean relevant documentation, do you mean this?
https://www.postgresql.org/docs/9.4/static/datatype-geometric.html
If so, does it mean if I pass "(3, 4)" as string and postgraphql should automatically store it and cast into a point value?
Try it; see what happens! PostGraphQL won't convert it to a point value, but PostgreSQL might.
Just tested, it seems to work!
[semi-automated message] Hi, there has been no activity in this issue for over 8 weeks so I'm closing it to keep the issues/pull request manageable. If this is still an issue, please re-open with a comment explaining why.
