babyfish-ct / graphql-ts-client

Typescript DSL for GraphQL.
MIT License
147 stars 20 forks source link

Using alias for the same field, includes only the last field in the query #19

Closed RestinGreen closed 2 years ago

RestinGreen commented 2 years ago

Hello. I cloned the example repo and was able to replicate it.

Just went into the EmployeeList.tsx file and as a test added these rows:

const test = query$ .findEmployees(employeeConnection$.totalCount, option => option.alias("first")) .findEmployees(employeeConnection$.totalCount, option => option.alias("second")) .findEmployees(employeeConnection$.totalCount, option => option.alias("third")) console.log(test.toString())

Expected output of the console log is: image

But I get image The aliases "first" and "second" didn't show up in the query.

Is this an issue on the way I construct the query or a bug? If i try it in GraphiQl, the expected syntax is correct.

babyfish-ct commented 2 years ago

It's a bug,

For generic types, field name are unique, so Fetcher uses a Map<String, FetcherField>. However, Query type is very special, it allows duplicated field name.

babyfish-ct commented 2 years ago

Hi RestinGreen

Please use v3.1.7 to validate it, if no problem, please close it

RestinGreen commented 2 years ago

In the meantime 3.1.8 was out and i tested it with that version. The bug is fixed.

Thank you! Closing it.