Skip to content

support placeholder at apiReturnListType and apiReturnType#1200

Merged
kobylynskyi merged 8 commits into
kobylynskyi:mainfrom
matsudamper:feature/damper/api-return-type-and-list-placeholder
May 15, 2023
Merged

support placeholder at apiReturnListType and apiReturnType#1200
kobylynskyi merged 8 commits into
kobylynskyi:mainfrom
matsudamper:feature/damper/api-return-type-and-list-placeholder

Conversation

@matsudamper

Copy link
Copy Markdown
Contributor

Description

Related to #1167

Added placeholder support for apiReturnListType and apiReturnType.
The following syntax is supported.

apiReturnType = "java.util.concurrent.CompletionStage<graphql.execution.DataFetcherResult<{{TYPE}}>>"

Changes were made to:

  • Codegen library - Java
  • Codegen library - Kotlin
  • Codegen library - Scala
  • Maven plugin
  • Gradle plugin
  • SBT plugin

@jxnu-liguobin jxnu-liguobin requested a review from kobylynskyi May 4, 2023 06:04

@kobylynskyi kobylynskyi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsudamper the approach looks good to me. Can you please fix a minor comment I have in Java/Kotlin/Scala mappers and we should be good to merge this. Thanks

return computedTypeName.replace(JAVA_UTIL_LIST, mappingContext.getApiReturnListType());
if (mappingContext.getApiReturnListType().contains(MappingConfigConstants.API_RETURN_NAME_PLACEHOLDER)) {
Matcher matcher = JAVA_UTIL_LIST_ELEMENT_REGEX.matcher(computedTypeName);
matcher.find();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsudamper I think it's better if you do if (matcher.find()) { ... }

boolean isNullable = computedTypeName.endsWith(KOTLIN_UTIL_NULLABLE);

Matcher matcher = KOTLIN_UTIL_LIST_ELEMENT_REGEX.matcher(computedTypeName);
matcher.find();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsudamper I think it's better if you do if (matcher.find()) { ... }

return computedTypeName.replace(SCALA_UTIL_LIST, mappingContext.getApiReturnListType());
if (mappingContext.getApiReturnListType().contains(MappingConfigConstants.API_RETURN_NAME_PLACEHOLDER)) {
Matcher matcher = SCALA_UTIL_LIST_ELEMENT_REGEX.matcher(computedTypeName);
matcher.find();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsudamper I think it's better if you do if (matcher.find()) { ... }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented.
2542b8f

@kobylynskyi kobylynskyi added this to the 5.8.0 milestone May 11, 2023

@kobylynskyi kobylynskyi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Will include this feature in the next release. Thank you for the contribution!

@kobylynskyi kobylynskyi merged commit 8d9d0de into kobylynskyi:main May 15, 2023
@matsudamper matsudamper deleted the feature/damper/api-return-type-and-list-placeholder branch May 18, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants