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

Improve codegen related extensions #2554

Open
hayes-mysten opened this issue Oct 2, 2024 · 2 comments
Open

Improve codegen related extensions #2554

hayes-mysten opened this issue Oct 2, 2024 · 2 comments

Comments

@hayes-mysten
Copy link

Is your feature request related to a problem? Please describe.

The extensions on scalars that inform codegen what types to use are useful, but seem inconsistent and incomplete

For example, the USCurrency scalar sets codegenScalarType to string which is the serialized type, but not what is expected as a resolver return type, or what is provided in resolver args.

The DateTime scalar sets codegenScalarType to Date | string which is what is expected as a return type of resolvers, but will always serialize to a string, and parse to a Date in args.

Describe the solution you'd like

It would be great if we could have 3 types represented in the extensions of scalars:

  1. The serialized type (we probably already have this in the form of the jsonSchema.type)
  2. A type representing the values that are allowed to be returned from resolver that can correctly be serialized
  3. A type representing parsed values. This may often the the same as 2, but should be stricter in same cases like the date related scalars

Describe alternatives you've considered

Additional context

@hayes-mysten
Copy link
Author

One other thing that would be really useful is if these types could be inferred from the scalars, rather than only being available at runtime.

@adrtivv
Copy link

adrtivv commented Oct 2, 2024

Enum types for scalars like CountryCode as well.

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

No branches or pull requests

2 participants