dotansimha / dotansimha/graphql-code-generator
Add a config option for importing all scalars from a .d.ts file
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Is your feature request related to a problem? Please describe.**
Somewhat related to #153
I am currently using the ScalarMap solution in the config to add custom scalars.
Currently the best workflow I've seen is to use `add` to append an import statement, define scalars in a separate file, and then fill my config with 40 or so lines of
```
- scalars:
PersonId: s.PersonId
DogId: s.DogId
...
```
It's not the worst thing in the world, and it works! But it takes manual updating, opens us up to human error/weird bugs in generated code, and makes the config file larger.
**Describe the solution you'd like**
What would be amazing is if we could just define a `scalars.d.ts`, point graphql-codegen at it, and produce a typed schema which uses our defined types. That way we have a single, non-generated definition file to import from in the naming format we choose.
**Describe alternatives you've considered**
Just the completely valid drop-in solution above :)
**Additional Context**
I would think this might be a common need as nominally typed ids become more popular. For my current setup, I'm using nominally typed id strings for the ids of every table represented in my table (super useful setup because I never accidentally use a DogId where I really need a PersonId).
This, or some kind of inflector that could make branded ids based on a pattern would be INCREDIBLE for this workflow.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.