[GH-ISSUE #36] query with empty fields will build a wrong Syntax #115

Closed
opened 2026-03-15 11:32:48 +03:00 by kerem · 2 comments
Owner

Originally created by @zgy03916618421 on GitHub (Jun 22, 2020).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/36

for example

const query = {
    operation,
    variables: {
      id: {
        value: id,
        type: 'String!',
      },
      uid: {
        value: uid,
        type: 'Int!',
      },
      key: {
        value: key,
        type: 'String',
      }
    },
    fields // this is undefined
  }

//output

query: "query ($id: String!, $uid: Int!, $key: String) { a…orize_info (id: $id, uid: $uid, key: $key) **{  }**"
Originally created by @zgy03916618421 on GitHub (Jun 22, 2020). Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/36 for example ```javascript const query = { operation, variables: { id: { value: id, type: 'String!', }, uid: { value: uid, type: 'Int!', }, key: { value: key, type: 'String', } }, fields // this is undefined } ``` //output ``` query: "query ($id: String!, $uid: Int!, $key: String) { a…orize_info (id: $id, uid: $uid, key: $key) **{ }**" ```
kerem closed this issue 2026-03-15 11:32:53 +03:00
Author
Owner

@Devorein commented on GitHub (Jun 28, 2020):

The last pair of brackets has to be removed for this issue to be resolved, you could try
gqlquery.query = gqlquery.query.replace(/\{\s+\}/, "");.

<!-- gh-comment-id:650762875 --> @Devorein commented on GitHub (Jun 28, 2020): The last pair of brackets has to be removed for this issue to be resolved, you could try `gqlquery.query = gqlquery.query.replace(/\{\s+\}/, "");`.
Author
Owner

@Devorein commented on GitHub (Jul 1, 2020):

@atulmy You can close this issue as the fix has been integrated

<!-- gh-comment-id:652229319 --> @Devorein commented on GitHub (Jul 1, 2020): @atulmy You can close this issue as the fix has been integrated
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#115
No description provided.