Location field not working in graphQl api

I have a field of type “location”, but when I include it in GraphQL to retrieve it, I get an error saying that this field does not exist in my space.

1 Like

Hi!
Currently we don’t support Location field in GraphQL, that’s still in the backlog, sorry :disappointed_relieved:

1 Like

Hi @Douglas_Porto

We have added support for Location fields in GraphQL.
Suppose Entity Database has Location Field of type Location, then you can query it like that.

{
  findEntities {
    location {
      latitude
      longitude
      fullAddress
      addressParts {
        neighborhood
        poi
        postcode
        locality
        place
        district
        address
        region
        country
      }
    }
  }
}

Query filters by Location is not supported yet. Mutations of this field is supported, however be sure that it has a value semantic, so you’ll need to pass ENTIRE location object to set new value.

3 Likes

Hi @Viktar_Zhuk,

We’re trying to fill in the location field via GraphQL

I was hoping that we could fill in the location field with the full address only.

But it seems that latitude is required? Or is that a bug?

1 Like

Hi, I guess you’ve tried to partially update location inner field, but we do not support this.
You have to supply entire Location value, that overrides existing one.

1 Like

Hi Viktar,

The end goal is

  • We create a new order in order database
  • We fill in the address of the client in the location field in order database

What do we need to do to accomplish this? We get an error if we don’t provide latitude.

1 Like

Can you share exact arguments you are using regarding to set field of Location type?

As I get it, from Fibery API

{
 "longitude": 2.349606,
 "latitude": 48.890764,
 "fullAddress": "Métro Marcadet Poissonniers, 67 boulevard Barbès, Paris, 75018, France",
 "addressParts": {
   "city": "Paris",
   "country": "France"
 }
}
All address parts are optional. Supported values

only addressParts are optional all other fields are mandatory, so you have to supply longitude and latitude within fullAddress

If you are trying to update fullAddress for existing entry, you have to retrieve previous value of entire Location field, update fullAddress in it and pass this to graphQl as entire value.

I was hoping we could fill in the address without longitude and latitude since we don’t have them. If that’s not possible, we need to skip the location field. Bummer, because the map is very valuable.

Would there be a possibility in Fibery to convert a text field to a location field? Tried it with AI in automation but with no good result.

1 Like

Unfortunately, you have to provide coordinates (longitude and latitude) for now. Converting human-readable address to coordinates is slow, expensive and not always reliable procedure, so we don’t provide it via API yet, only via Fibery UI.

You can call some third-party geocoding API (that converts addresses to coordinates) directly on your side though. Google and Mapbox providers are good candidates.

2 Likes

Thanks, will look into that!

Interesting, because I ran into this same problem but with CSV imported data. My solution was AI, though I have not tested it with many examples yet. This is what my rule looks like, it’s absurdly simple but it has worked in my tests at least. The AI Prompt is literally just this:
Create Location from {{Address Text}}
where “Address Text” is the text field holding my address.

2 Likes

O wow; I’ve made my prompt way to complex :joy: This works! Thanks!

1 Like

Hah! Glad to hear it worked. “Trust the machine” :wink:

1 Like