feat(package/cli): add params to args conversion to generator#2056
feat(package/cli): add params to args conversion to generator#2056kleberbaum wants to merge 9 commits intogqty-dev:mainfrom
Conversation
|
Hi @vicary, sorry for the radio silence. I am currently on vacation in Japan until 01.03.2025 I am still interested in introducing these changes and will try to be more responsive during the next week. |
|
Hi @vicary, I have rebased the PR to include ohash etc.
Can I help you with that? |
Currently, the fetch mode is always set to 'CORS' in the generated code. In Cloudflare Workers and many other server-side environments, CORS is not required and sometimes not even supported. This change adds a conditional generation of the fetch mode based on the framework e.g. Hono, Pylon, etc.
Variables are sorted alphabetically using lexicographicSortSchema, which causes TypeScript type conflicts when optional parameters follow required ones. This change conditionally sorts the schema based on the framework (e.g. React, SolidJS, Hono, Pylon) to prevent these type conflicts.
Added mutation-query-types.ts to generate MutationTypes and QueryTypes. This module processes the interpreted GraphQL schema to create type declarations for mutations and queries, enhancing type safety.
Added mutation-query-param-names.ts to generate MutationParamNames and QueryParamNames. This module creates runtime objects that store argument names for each mutation and query field which makes possible to convert between params and args.
Added convert-params-to-args.ts to provide helper functions for converting parameter tuples into argument objects. This module includes functions for dynamically mapping parameters to their respective argument names, enhancing runtime parameter handling.
Introducing these frameworks are out of scope for this PR, so their references have been removed from the SupportedFrameworks type and related logic (schema sorting, CORS, and client code generation).
This reverts commit 7d8881c. Reason: The conditional generation of fetch mode goes beyond the scope of this PR.
|
Hi @vicary, I reduced the scope of the PR to just include params-to-args conversion like you suggested.
Everything that is still in this PR is needed to make this feature possible as a GQty core feature. As I am planing to use this feature in a project could you maybe release as a Snapshot Release (canary) release? Conditional CORS and additional frameworks will maybe be discussed in different PRs in the future. |
#2051