But the problem is when I try to query the coordinates like this
query {
Geocoded(Geocoded: true) {
data {
Address
geocodetimezone
geocodelocation {
lat
lng
}
}
}
}
I get an error from Fauna
{
"errors": [
{
"message": "Ref or Set expected, Object provided.",
"extensions": {
"code": "invalid argument"
}
}
]
}
It looks like it’s a problem with the schema and not understanding the type Location properly. Can someone help me explain how define the schema so it’s an object with lat and lng and how to query that back? I’m assuming this is super simple but just a learning curve problem in knowing how to define the schema to include inner objects properly. Thanks in advance for your help!
Here’s what one of the Documents looks like for your reference:
Your schema has one-to-one relation between Office_Locations and Location which means the data geocodelocation should have a reference to Location document. But in the example you gave location is embedded.
Two ways to resolve this.
Update your schema to use @embedded directive i.e. modify type Location to type Location @embedded
Update your Office_Location document to have Ref of Location instead of object.
How did you create the Office_Locations and Location documents ? My guess is you used Create using FQL and GraphQL API is not able to translate because for the relation it was expecting a ref or set but Object was provided.
More details on what happens behind the scenes with your schema
I was getting the same error when querying my DB. The difference being I created my initial collections and documents in the web dashboard like this:
{
...
user: {
email: "example@email.com",
...
}
}
@Jay-Fauna pointed me in the right direction: the document requires a Ref of Location to another document instead of an object. Solved in the web dashboard using: