atulmy / gql-query-builder

🔧 Simple GraphQL Query Builder
https://npmjs.com/package/gql-query-builder
MIT License
396 stars 43 forks source link

feat(variables): take consideration of nested variables #55

Closed clement-berard closed 3 years ago

clement-berard commented 3 years ago

Hello community!

Nested fields have served me well. Nevertheless, the variables for the sub-operations were not added to the variables of the query (only the first sub-operation).

So I propose a small modification to collect all the variables, no matter how deep they are.

Below, the result of the query added in test.

query(
  $id: ID
  $visible: Boolean
  $platformLimit: Int
  $idChannel: Int!
  $channelLimit: Int
  $rightsLimit: Int
  $rightsOffset: Int
  $userLimit: Int
  $userFilter: String
) {
  getPublicationNames {
    publication(id: $id) {
      id
      name
      platforms(visible: $visible, limit: $platformLimit) {
        totalCount
        edges {
          label
          code
          parentId
          id
          rights(
            idChannel: $idChannel
            limit: $rightsLimit
            offset: $rightsOffset
          ) {
            id
            label
            users(limit: $userLimit, filters: $userFilter) {
              id
              name
            }
          }
        }
        subField
        channels(id: $idChannel, limit: $channelLimit) {
          id
          label
        }
      }
    }
  }
}

thanks to all of you :)

atulmy commented 3 years ago

Thanks for the contribution @clement-berard!