Netflix / Netflix/dgs-codegen

Adding custom suffix to generated types

Open
#389 5 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good-first-issues
Dominant language
Kotlin
Stars
217
Forks
116
PR merge metrics
No merged PRs in 30d

Description

With DGS codegen, I want the schema types to correspond my Model entity types.

For example let's assume that I have a query in my schema:

type Dog {
name: String!
}

My generated type will be <generated_types_package>.Dog.java
In most cases, I will have another class for my model object. <model_type_package>.Dog.java

What happens in this case that in my DataFetcher I need to declare explicitly on the type package prefix, which makes the code pretty hard to read.

My suggestion is to add a custom suffix to any schema generated type (not input)
<model_type_package>.Dog.java --> <model_type_package>.DogGQL.java

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The request concerns DGS codegen's generated schema types and the Java types consumed by DataFetchers. Start by locating the generator entry point and its tests, then trace how non-input schema types are named. Done means a configurable suffix is applied to those generated types while input types remain unchanged, with coverage for the Dog example.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.