Netflix / Netflix/dgs-codegen

Interface desarialization doesn't work

Open
#490 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have the following schema:

union ValidationRule = MinimumCharacterRule

type MinimumCharacterRule {
    value: Int!
}

It will generate the following classes:

@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "__typename"
)
@JsonSubTypes(@JsonSubTypes.Type(value = MinimumCharacterRule.class, name = "MinimumCharacterRule"))
public interface ValidationRule {
}
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NONE
)
public class MinimumCharacterRule implements ValidationRule {
...
}

If I try to deserialize the MinimumCharacterRule class I will get the following error:

Could not resolve subtype of [simple type, class com.example.ValidationRule ]: missing type id property '__typename'

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 issue provides the schema and generated ValidationRule and MinimumCharacterRule classes but names no repository file or test. Start by reproducing deserialization of MinimumCharacterRule and inspect how the generated Jackson annotations handle __typename; done means the generated types deserialize without the reported missing type-id error, with regression coverage if the relevant test area is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.