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

Inner operation without the variables property produce an Uncaught TypeError: t.map is not a function #93

Open
MurzNN opened this issue Aug 12, 2024 · 0 comments

Comments

@MurzNN
Copy link

MurzNN commented Aug 12, 2024

I need to build a query with nested operations, like this:

query ($id: Int) {
  thought (id: $id) {
    id,
    name,
    thought,
    details {
      image,
      description
    }
  }
}

So, I composed this JS code to make it:

const query = gql.query({
    operation: 'thought',
    variables: { id: 1 },
    fields: [
        'id',
        'name',
        'thought',
        {
            operation: 'details',
            fields: [
                'image',
                'description',
            ],
        },
    ]
})

But it produces an error:

Uncaught TypeError: t.map is not a function

But if I add an empty variables: {} property, it starts working, here is the example:

const query = gql.query({
    operation: 'thought',
    variables: { id: 1 },
    fields: [
        'id',
        'name',
        'thought',
        {
            operation: 'details',
            variables: {},
            fields: [
                'image',
                'description',
            ],
        },
    ]
})

So, is it a bug, or intended behavior? If intended, could you please describe the reasons?

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

1 participant