Issue with querying geopoint in Sanity Vision
33 replies
Last updated: May 5, 2021
W
Hello I’m having issue with querying geopoint. This is an example query:
But this simple query is giving me error:
Is there anything that I do wrong? or anything I need to install to enable the geo function?
*[_type == 'space'] {
_id,
dis: geo::latLng(59.911491, 10.757933)
}
But this simple query is giving me error:
expected '}' following object body
Is there anything that I do wrong? or anything I need to install to enable the geo function?
May 5, 2021, 11:38 AM
Hi Welly! Are you by any chance using the
v1version of the API? geo-support was added in
v2021-03-25
May 5, 2021, 11:44 AM
You would also need to add “dis” in quotes, so
should work
*[_type == 'space'] { _id, "dis": geo::latLng(59.911491, 10.757933) }
May 5, 2021, 11:44 AM
W
How do I check v1 or v2?
May 5, 2021, 11:45 AM
W
I’ve tried the “dis” but it still doesnt work
May 5, 2021, 11:45 AM
W
I’m trying the query in the sanity vision
May 5, 2021, 11:46 AM
Aha, in Vision you should see API Version as a dropdown on top. But that was added recently
May 5, 2021, 11:47 AM
W
I’m using the 2.10.0 version
May 5, 2021, 11:48 AM
W
I don’t
May 5, 2021, 11:50 AM
Right, then it would default to
v1. Can you try and delete the node_modules folder and reinstall the packages with
sanity installbefore running
sanity startagain?
May 5, 2021, 11:53 AM
W
Sure let me try first
May 5, 2021, 11:54 AM
W
Now I’m getting when I run
@sanity/core not installed in current project
sanity startbecause I deleted the whole node_modules
May 5, 2021, 11:57 AM
W
yes but I only got
✔ Saved lockfile
May 5, 2021, 11:59 AM
W
Nothing is installed in the node_modules dir
May 5, 2021, 11:59 AM
W
Here is what I got:
[1/4] :mag: Resolving packages...
success Already up-to-date.
:sparkles: Done in 0.53s.
May 5, 2021, 12:04 PM
W
Nothing in the node_modules dir now
May 5, 2021, 12:05 PM
W
I’m using v14.16.1
May 5, 2021, 12:06 PM
Hm, very strange! Can you try
yarn cache cleandeleting node_modules and then do a
sanity install?
May 5, 2021, 12:10 PM
W
Let me try
May 5, 2021, 12:11 PM
W
It’s still the same, empty node_modules
May 5, 2021, 12:18 PM
hmm. Can you also remove the
yarn.lock-file? 🤔 Starting to run out of options I can think of 😅 Are you by any chance inside a yarn workspace?
May 5, 2021, 12:19 PM
W
Removing the lock file works!
May 5, 2021, 12:21 PM
W
Is there any breaking changes between v1 and v2?
May 5, 2021, 12:22 PM
https://www.sanity.io/changelog?platforms=GROQ#a6473a5c1682 there’s a some changes, yes
May 5, 2021, 12:23 PM
W
Yes, the geo function is already working well. Thanks a lot!
May 5, 2021, 12:23 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.