Zaid-Ajaj / Snowflaqe

A dotnet CLI to generate type-safe GraphQL clients for F# and Fable with automatic deserialization, static query verification and type checking
MIT License
154 stars 25 forks source link

Hoist and reuse field types #88

Open etareduction opened 1 year ago

etareduction commented 1 year ago

Currently complex types in query selection and input types are generated under the query's module, even though they can be the same type in different queries. This makes reuse and creation of functions that operate on types in graphql schema quite difficult. I suggest generating those types under root namespace of a generated project.

Zaid-Ajaj commented 1 year ago

Hi @etareduction I found that implementing such feature was really complicated so opted to keep the types separate per query/mutation. For cases where you need to write a function that operates on a generated type, probably easiest is to write a common type by hand and mapper functions from the generated types to the common type, then have the function operate on the common type.

I realize it is not ideal, but it is kind of OK to work with.

etareduction commented 1 year ago

Yes, currently i use inline functions with member constraints on argument for a mapper. It is kinda okay for a few types, but i expect having dozens of them. What blockers have you encountered while evaluating the possibility of this feature?