Netflix / Netflix/dgs-codegen

Option to add custom logic during Entity codegen

Open
#248 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm looking for ability to add Spring Data Jdbc annotations (@Id, @MappedCollection) for generated GraphQL entities.
Such option allow to reuse existing Pojos for DAO layer and eliminate tons of redundant LOC.

I see that JsonProperty is hardcoded in
graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin/KotlinDataTypeGenerator.kt:116.

Can you please provide some API for users, exposing some pluggable Kotlinpoet functions or something like that...

Without this option it's a disaster to duplicate Entities / Classes, then using some sort of Mappers and other annoying stuff to reach database.

EDIT

Also, all collections are mapped to List, although handwritten Set works. Most ORM / ORM-like frameworks require Set collection over List for relationships. Usually, List servers more rare cases in database mapping.
Ability to set Collection type also falls into "must have" zone.

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

Start by reading graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin/KotlinDataTypeGenerator.kt around line 116, where JsonProperty is hardcoded. Review how generated Kotlin entities handle annotations and collections; done should provide a defined extension point for Spring Data JDBC annotations and a configurable collection type.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.