Netflix / Netflix/dgs-codegen

Client projection of a field with arguments does not return correct projection

Open
#644 1 comment 0 reactions 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

In versions 6.x when you create a schema like this:

type Query {
    request: Response
}

type Foobar {
    foo(first: Int): String
}

type Response {
    bar: Foobar
}

Field foo(Integer first) returns FieldObjectProjection instead of FieldObjectProjection<PARENT, ROOT>.

public class FoobarProjection<PARENT extends BaseSubProjectionNode<?, ?>, ROOT extends BaseSubProjectionNode<?, ?>> extends BaseSubProjectionNode<PARENT, ROOT> {
  public FoobarProjection(PARENT parent, ROOT root) {
    super(parent, root, java.util.Optional.of("Foobar"));
  }

  public FoobarProjection<PARENT, ROOT> foo() {
    getFields().put("foo", null);
    return this;
  }

  public FoobarProjection foo(Integer first) {
    getFields().put("foo", null);
    getInputArguments().computeIfAbsent("foo", k -> new ArrayList<>());
    InputArgument firstArg = new InputArgument("first", first);
    getInputArguments().get("foo").add(firstArg);
    return this;
  }
}

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 with the schema and generated FoobarProjection shown in the issue, then trace the projection-generation path for fields that accept arguments. Reproduce the schema case and compare the parameterized foo method with the no-argument method. Done means the generated method preserves the PARENT and ROOT generic types and a regression test covers the argument-bearing field.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.