[PR #33] Handle parameters on nested fields #71

Closed
opened 2026-03-03 00:03:16 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/atulmy/gql-query-builder/pull/33

State: closed
Merged: Yes


fix #3

Hi, I have used this lib for a moment, and really like what it brings, and I fell upon a missing feature (that was brought up in your issue #3), adding variables to fields, like so :

query ($id: ID) { 
  getPublicationNames  { 
    publication (id: $id) {
      id, 
      name
    } 
  } 
}

I added a test case, and worked on the syntax that was provided on the issue :

const query = gql.query({
  operation: 'users',
  variables: { limit: 4 },
  fields: [
    'name',
    'email'
    {
      operation: 'posts',
      variables: { limit: 10 },
      fields: [
        'title', 
        'body'
      ]
    },
  ]
})

It seems to work for me, the tests are ok, and it worked in a real app as a test. If this can be of interest, I'd love to have this added to the library.

I did try to clean up as much my additions, but feel free to tell me where I could ease the integration, and where could be some improvements or errors.

Thanks a lot !!!

**Original Pull Request:** https://github.com/atulmy/gql-query-builder/pull/33 **State:** closed **Merged:** Yes --- fix #3 Hi, I have used this lib for a moment, and really like what it brings, and I fell upon a missing feature (that was brought up in your [issue #3](https://github.com/atulmy/gql-query-builder/issues/3)), adding variables to fields, like so : ```js query ($id: ID) { getPublicationNames { publication (id: $id) { id, name } } } ``` I added a test case, and worked on the syntax that was provided on the issue : ```js const query = gql.query({ operation: 'users', variables: { limit: 4 }, fields: [ 'name', 'email' { operation: 'posts', variables: { limit: 10 }, fields: [ 'title', 'body' ] }, ] }) ``` It seems to work for me, the tests are ok, and it worked in a real app as a test. If this can be of interest, I'd love to have this added to the library. I did try to clean up as much my additions, but feel free to tell me where I could ease the integration, and where could be some improvements or errors. Thanks a lot !!!
kerem 2026-03-03 00:03:16 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gql-query-builder#71
No description provided.