Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(package/cli): add params to args conversion to generator #2056

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

kleberbaum
Copy link

@kleberbaum
Copy link
Author

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.

@kleberbaum
Copy link
Author

Hi @vicary, I have rebased the PR to include ohash etc.

Yes, it comes from our legacy of --react when it is the only framework on top of core.
When framework support is further expanded this option will definitely be reworked.
But let's stick with --pylon for the moment.
_Originally posted by @vicary in https://discord.com/channels/874477141834739762/1330852173600391211/1333984259932688495

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.
@kleberbaum kleberbaum changed the title WIP: add generation for serverside frameworks feat(package/cli): add params to args conversion to generator Feb 15, 2025
@kleberbaum
Copy link
Author

Hi @vicary, I reduced the scope of the PR to just include params-to-args conversion like you suggested.

The current idea is to break it down and get the common features into the core from separate PRs until the idea of adding frameworks feels trivial.

_Originally posted by @vicary in https://discord.com/channels/874477141834739762/1330852173600391211/1339810280699334696

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant