Skip to content

Improve codegen related extensions #2554

@hayes-mysten

Description

@hayes-mysten

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions