Cannot use DataFetcherResult as an item for GraphQL List fields
See original GitHub issueLibrary Version What version are you using? 4.1.1
Describe the bug A clear and concise description of what the bug is. GraphQL-Java supports using DataFetcherResult as an item for list fields with this PR, which is useful for providing local context for individual items in lists (see this issue).
However, graphql-kotlin’s schema generator throws a TypeNotSupportedException when it is provided as a return type for a resolver:
com.expediagroup.graphql.generator.exceptions.TypeNotSupportedException: Cannot convert graphql.execution.DataFetcherResult<mypackage.EntityType> since it is not a valid GraphQL type or outside the supported packages "[mypackage.graphql]"
To Reproduce Steps to reproduce the behavior. Please provide:
- Schema Configuration
graphql:
packages:
- "mypackage.graphql"
(no other config)
- Kotlin code used to generate the schema
data class WorldType(
private val world: World
) {
fun entities(
dataFetchingEnvironment: DataFetchingEnvironment
): List<DataFetcherResult<EntityType>> = world.entities.map {
DataFetcherResult.newResult<EntityType>()
.data(it)
.localContext(dataFetchingEnvironment.getLocalContext<LocalContext>()?.copy(
currentEntityId = it.entityId
))
.build()
}
}
Expected behavior A clear and concise description of what you expected to happen.
There should be no TypeNotSupportedException
thrown, as this configuration is supported by graphql-java and requires no type mapping by graphql-kotlin.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Individual localContexts for entries in List · Issue #1559 - GitHub
DataFetcherResult } or in a List of {@link graphql.execution. ... Allow and process DataFetcherResult as an item for GraphQL List fields.
Read more >Execution - GraphQL Java
How to execute a query using the graphql-java engine. ... information such as the field's parent object, the query root object or the...
Read more >DataFetchingEnvironment (graphql-java 0.0.0-2021-07-18T08 ...
This returns a context object that parent fields may have returned returned via DataFetcherResult.getLocalContext() which can be used to pass down extra ...
Read more >Nested data fetchers - DGS Framework
Commonly, the datafetcher for a nested field requires properties from its parent object to load its data. Take the following schema example.
Read more >GraphQL Java custom scalar type for map is not accepted by ...
I can not find any hind in the tutorials to find out what I am missing out to make it work. I understand...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve created a PR with the change for review: https://github.com/ExpediaGroup/graphql-kotlin/pull/1150
Sorry, EntityType is actually under mypackage.graphql, I had just changed out the package names for the sake of the example, it is not causing the error - the List<> wrapping of DataFetcherResult is