Map Field

Simple Query

Sample Map Query - Latitude + Longitude

{
shops {
location {
latitude
longitude
}
}
}

Output

{
"data": {
"shops": [
{
"location": {
"latitude": 48.7,
"longitude": -122.5
}
}
]
}
}

Sample Map Query - Distance Between

{
shops {
location {
distance(from: {
latitude: 47.6,
longitude: -122.3
})
}
}
}

Output

{
"data": {
"shops": [
{
"location": {
"distance": 122616.8
}
}
]
}
}

Mutating a Map

Mutation

mutation {
createShop(data: {
title: "Delight Coffee",
location: {
latitude: -18.1,
longitude: 178.4
}
}) {
title
location {
latitude
longitude
}
}
}

Output

{
"data": {
"createShop": {
"title": "Delight Coffee",
"location": {
"latitude": -18.1,
"longitude": 178.4
}
}
}
}

This site uses cookies to provide you with a better user experience. For more information, refer to our Privacy Policy