Skip to content

strictScalars and scalars map for graphql source codegen #3508

Open
@leemhenson

Description

@leemhenson

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

I am stitching together several graphql sources. They define custom scalar types, and I would like to be able to tell the codegen process what the equivalent typescript type should be for those scalars via the scalars map as documented here.

I would then additionally like to be able to enable the strictScalars flag so that the build process fails if I haven't provided a Typescript mapping for a scalar.

Describe the solution you'd like

I guess this would make sense in the source config:

sources:
  - name: MyGraphQLApi
    handler:
      graphql:
        endpoint: http://my-service-url:3000/graphql
        operationHeaders:
          Authorization: Bearer {env.MY_API_TOKEN}
        scalars:
          ScalarTypeA: string
          ScalarTypeB: number
        strictScalars: true

Describe alternatives you've considered

Leaving it as it is, which applies the type any to any unknown scalar. This isn't great as it will lead to bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions