Issue with querying geopoint in Sanity Vision

33 replies
Last updated: May 5, 2021
Hello I’m having issue with querying geopoint. This is an example query:
*[_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
v1
version 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
*[_type == 'space'] {
  _id,
  "dis": geo::latLng(59.911491, 10.757933)
}
should work
May 5, 2021, 11:44 AM
How do I check v1 or v2?
May 5, 2021, 11:45 AM
I’ve tried the “dis” but it still doesnt work
May 5, 2021, 11:45 AM
How are you running your query?
May 5, 2021, 11:45 AM
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
Which version of
@sanity/vision
are you on?
May 5, 2021, 11:47 AM
I’m using the 2.10.0 version
May 5, 2021, 11:48 AM
Do you have this drop down above the query editor?
May 5, 2021, 11:49 AM
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 install
before running
sanity start
again?
May 5, 2021, 11:53 AM
Sure let me try first
May 5, 2021, 11:54 AM
Now I’m getting
@sanity/core not installed in current project
when I run
sanity start
because I deleted the whole node_modules
May 5, 2021, 11:57 AM
Did you run
sanity install
?
May 5, 2021, 11:58 AM
yes but I only got
✔ Saved lockfile
May 5, 2021, 11:59 AM
Nothing is installed in the node_modules dir
May 5, 2021, 11:59 AM
That is weird 🤔 Can you try
yarn install
manually?
May 5, 2021, 12:02 PM
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
Do you have something in node_modules now?
May 5, 2021, 12:05 PM
Nothing in the node_modules dir now
May 5, 2021, 12:05 PM
Which version of node are you on?
May 5, 2021, 12:06 PM
I’m using v14.16.1
May 5, 2021, 12:06 PM
Hm, very strange! Can you try
yarn cache clean
deleting node_modules and then do a
sanity install
?
May 5, 2021, 12:10 PM
Let me try
May 5, 2021, 12:11 PM
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
Removing the lock file works!
May 5, 2021, 12:21 PM
Is there any breaking changes between v1 and v2?
May 5, 2021, 12:22 PM
Hurray! And did you get the api version in Vision?
May 5, 2021, 12:23 PM
May 5, 2021, 12:23 PM
Yes, the geo function is already working well. Thanks a lot!
May 5, 2021, 12:23 PM
🙂
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.

Was this answer helpful?