groq-js
groq-js copied to clipboard
Accessing nested objects fails
First of all, thank you for the amazing work.
When accessing properties deep nested inside object, query fails silently with null data.
simple way to reproduce :
describe('failing', () => {
it('array', async () => {
const dataset = {
users: [
{ name: 'foo', age: 12 },
{ name: 'bar', age: 30 },
],
};
const query = `*.users`;
const tree = parse(query);
const value = await evaluate(tree, { dataset });
const data = await value.get();
expect(data).toStrictEqual([
{ name: 'foo', age: 12 },
{ name: 'bar', age: 30 },
]);
});
});
Behaviour in GROQ playground
Behaviour in jest
Seems like this problem is occurring in the previous versions too. And this error is also occurring when finding relations. What version of GROQ we are using on groq.dev? as the problem is not occurring there
Seems like this problem is occurring in the previous versions too. And this error is also occurring when finding relations. What version of GROQ we are using on groq.dev? as the problem is not occurring there
It looks like groq.dev is using 0.1.3
- https://github.com/sanity-io/groq-cli/blob/master/package.json#L35
(*).users seems to work as expected with the latest version