Run a query on a geolocation field for a supported object using the GeolocationInput type. The geolocation custom field types stores location values on records using latitude and longitude values. You can create queries that calculate the distance between two location values or between a location value and a latitude-longitude coordinate.
To create a location-based filter, use the where and orderBy arguments.
Query Records with Geolocation Fields
A compound geolocation field includes latitude and longitude values. To work with compound geolocation fields, reference the individual components of the returned value. For example, if your geolocation field name is Location, use the Location__Latitude__s and Location__Longitude__s.
Pass in the where argument to filter records based on a geolocation compound field. Let’s say you have a custom geolocation field Location__c on accounts. This where argument finds accounts that are within 500 miles of 47.6062°, -122.3321° (Seattle, WA) using the lt function.
Find accounts within 500 miles of a specified lat/long
Given a set of records with geolocation fields, you can sort them by distance using the distance filter type with the orderBy argument. You can also order the results in ascending or descending order.
When you query geolocation compound fields, use the constituent fields in the query.
1edges{2 node{3 Name{4 value5},6 Location__c{ # don't do this7 value8}9}10}
Provide a direct reference to the internal primitive data types. For example, use Location__Latitude__s and Location__Longitude__s if you have a compound geolocation field Location__c.
Similar to how SOQL calculates and compares distances, you can’t check locations or distances for equality with GraphQL API. You can only determine whether a location is farther or closer than another location, or one distance is greater or smaller than another.