Thinkmill / ts-gql

Write GraphQL queries with a gql tag in TypeScript -> have generated types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for unnamed queries? (Use hash of query text?)

benny-medflyt opened this issue · comments

Hello, the requirement to name each query is sometimes inconvenient (and for large projects can lead to collisions).

What about the idea of auto-generating a name based on the hash of the query text?

I might be able to submit a pull request for this.

Thank you

A PR for an eslint rule (not in the main ESLint rule) that can fix unnamed queries with a random string(random rather than a hash so that it doesn't change when you make a change to the query and there won't be conflicts if there are identical queries) sounds good

Thank you. May I ask why not a hash? If two queries happen to be identical then they will have the same hash and then they will use the same generated file. Why would this lead to a conflict?

It would lead to a conflict because @ts-gql/compiler disallows multiple queries with the same name