Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing nested objects fails #49

Open
yesoreyeram opened this issue Jan 28, 2022 · 3 comments
Open

Accessing nested objects fails #49

yesoreyeram opened this issue Jan 28, 2022 · 3 comments

Comments

@yesoreyeram
Copy link

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

image

Behaviour in jest

image

@MathurAditya724
Copy link

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

@magicfoodhand
Copy link

magicfoodhand commented Jun 11, 2022

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

@magicfoodhand
Copy link

(*).users seems to work as expected with the latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants