apollographql / apollographql/apollo-tooling

apollo client:codegen Add custom header to output

Open
#1,043 3 comments 16 reactions 0 assignees View on GitHub
🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

With `--passthroughCustomScalars`, the TypeScript codegen will generate files with unknown types for custom scalars, resulting in output that does not compile.

To get my definition of those scalars into the codegen output, I am using `--customScalarsPrefix=CustomScalars.` and then using a shell script to add the following code at the top of the codegen output:
```
import * as CustomScalars from './CustomScalars'
```

To avoid this postprocessing step, can we add an option to prepend arbitrary content to the codegen output?

Contributor guide

Open the contributing guide

Research direction

Locate the TypeScript codegen entry point handling --passthroughCustomScalars and --customScalarsPrefix, then trace where generated output is assembled. Confirm that configurable content can be emitted before the generated code and that the resulting output compiles without shell postprocessing.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.