captbaritone / captbaritone/grats

Add Node interface codegen functionality

Open
#233 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
358
Forks
24
PR merge metrics
No merged PRs in 30d

Description

There is a known limitation where if you have types implementing the node interface you have to manually define the [typenames again](https://github.com/captbaritone/grats/blob/main/examples/production-app/graphql/Node.ts#L46-L57).

As a result, this loses type safety and can be easy to miss.

I'm not too sure what the typescript compiler has access to but potentially there could be a codegen step to generate a schema-types.ts with all the typenames that implement node.

Potentially it may require having a special `@gqlNodeInterface` comment tag in the application code

Contributor guide

Open the contributing guide

Research direction

Start with examples/production-app/graphql/Node.ts, especially the manually repeated typenames, and inspect how the TypeScript compiler and proposed code-generation step could discover Node implementations. Review the idea of generating schema-types.ts and the possible @gqlNodeInterface comment tag. Done means Node implementations no longer require manually duplicated typenames while retaining type safety.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, backend-api-design, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.