Skip to content

Increase customizability of values ​​that can be returned by apiReturnType #1167

@matsudamper

Description

@matsudamper

Description

I want to generate the following code

  • Need to return CompletableFuture to dispatch DataLoader
  • Need to set localContext

DataLoader

fun book(
    id: Long,
    env: DataFetchingEnvironment,
): CompletionStage<DataFetcherResult<Book>> { // here
    val bookNameDataLoader = env.dataLoaderRegistry.getDataLoader<Long, String>("key")
    val bookNameCompletableFuture = bookNameDataLoader.load(id)

    return CompletableFuture.supplyAsync {
        DataFetcherResult.newResult<Book>()
            .localContext("additionalContext")
            .data(
                Book(
                    id = id,
                    name = bookNameCompletableFuture.get(),
                )
            )
            .build()
    }
}

The apiReturnType setting does not seem to allow the following to be output. We would like to enable this.
CompletionStage<DataFetcherResult<T>>

Describe the solution you'd like

I want to enable the following statements

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

Describe alternatives you've considered

Other

I can submit the code.
https://github.com/kobylynskyi/graphql-java-codegen/compare/main...matsudamper:graphql-java-codegen:feature/damper/api-return-type-placeholder?expand=1

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions