Absinthe Graphql - Schemas and Queries with geography fields

Hey guys,

I’m trying absinthe for graphql and i got stucked trying to use geography fields in my absinthe schemas.

I need to map two geography fields in my schema and also need to query those data, sending a request like that:

{"query": "{ findPostsByLocation(geometry: {type: Point, coordinates: [30.700640541690966, 76.78872369023148]}, radius: 5819.699584137614) { title location}}" }

But i don’t know how :frowning:
Anyone has some document or knows how can i do this?

Thank you!

You can create a custom absinthe type for geometry and use that as an argument.

See https://github.com/absinthe-graphql/absinthe/wiki/Scalar-Recipes for some examples of custom scalars. I’m pretty sure someone has created absinthe scalars for WKT formatted geo data.

2 Likes

For those who need to solve the same problem, i used input objects to do what i need.
Here an example:

    input_object :geography do
     field :coordinates, :coordinate
    end

   input_object :coordinate do
    field :latitude, :float
    field :longitude, :float
   end

And so, i added this geography input object inside my schema.

2 Likes