atulmy / gql-query-builder

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

Fields data object #67

Closed yashiroiori closed 2 years ago

yashiroiori commented 2 years ago

I try to send de query but send me an error

Query: { metrics { id name paginatorInfo{ count currentPage firstItem hasMorePages lastItem lastPage perPage total } } }

image

Correct query: { metrics { data { id name } paginatorInfo{ count currentPage firstItem hasMorePages lastItem lastPage perPage total } } } Need put fields into object named "data {}", how can make if??

image
yashiroiori commented 2 years ago

I try to send de query but send me an error

Query: { metrics { id name paginatorInfo{ count currentPage firstItem hasMorePages lastItem lastPage perPage total } } }

image

Correct query: { metrics { data { id name } paginatorInfo{ count currentPage firstItem hasMorePages lastItem lastPage perPage total } } } Need put fields into object named "data {}", how can make if??

image

Solve using CustomQueryAdapter Add data to put into object private operationTemplate(variables: VariableOptions | undefined) { return ${this.operation} { data ${variables ? Utils.queryDataNameAndArgumentMap(variables) : ""} ${this.fields && this.fields.length > 0 ? "{ " + Utils.queryFieldsMap(this.fields) + " }" : ""} }; }