dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

Regression in behaviour of generation in combination with typeMappings [>=4.4.7]

Open marceloverdijk opened this issue 4 years ago • 3 comments

I found a regression while upgrading codegen from 4.4.6 to the latest 5.0.2 but also 4.4.7 fails.

I have a custom PageInfo type like:

type PageInfo {
   hasNextPage: Boolean!
   hasPreviousPage: Boolean!
   totalCount: Int!
}

used in e.g.:

type EngineManufacturerPage {
   items: [EngineManufacturer!]!
   pageInfo: PageInfo!
}

and a DGS code generator config for it like:

packageName = "com.mycomp.graphql"
subPackageNameTypes = "type"
generateInterfaces = true
typeMapping = ["PageInfo": "com.mycomp.graphql.type.IPageInfo"]

In 4.4.6 and before above graphqls would generate a IPageInfo like:

public interface IPageInfo {
  Boolean getHasNextPage();
  Boolean getHasPreviousPage();
  Integer getTotalCount();
}

but from 4.4.7 this is not happening anymore unfortunately...

Could it be something changed in the behaviour? Other interfaces are generated so I suspect the combination with the typeMapping configuration.

marceloverdijk avatar Jul 01 '21 21:07 marceloverdijk

Basically, I want to use my own PageInfo object as defined in my schema and not the graphql.relay.PageInfo which was used because of the defined commonScalars in the generator here: https://github.com/Netflix/dgs-codegen/blob/34e5d46bd0d1a0bdf87997d124843ab1a39f8c3a/graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/java/TypeUtils.kt#L45

To avoid it (graphql.relay.PageInfo) I defined the typeMapping = ["PageInfo": "com.mycomp.graphql.type.IPageInfo"].

Is there a way to remove a common scalar from the generator config?

marceloverdijk avatar Jul 07 '21 11:07 marceloverdijk

I have the same issue and am also using typeMapping to side step the default relay PageInfo, but this results in the generated PageInfo from my schema not being generated...

iamlothian avatar Aug 01 '21 23:08 iamlothian

Same here. Would very much like it if codegen didn't assume I wanted to use graphql-java's implementation of Relay pagination, or there was a way to explicitly disable that behavior (especially if the schema never makes use of @connection and graphql-dgs-pagination isn't an explicit dependency).

sp-llminc avatar Sep 22 '22 15:09 sp-llminc