Netflix / dgs-framework

GraphQL for Java with Spring Boot made easy.
https://netflix.github.io/dgs
Apache License 2.0
3.1k stars 297 forks source link

bug: DGSNotFoundException path not returning the correct path #1585

Closed samuel-torres-code2 closed 10 months ago

samuel-torres-code2 commented 1 year ago

When throwing a DGSNotFoundError in a JavaSpringBoot DGS application, the full path is not returned when thrown in the DgsEntityFetcher for a given type. The type should return an array of elements. I am able to return a string message with information about the failed element of the list, but the path does not reflect that.

Expected behavior

TypedGraphQLError{message='Cluster 'app-stack-deets' not fount in account 'mgmt'', locations=[], path=[_entities,0], extensions={class=com.netflix.graphql.dgs.exceptions.DgsEntityNotFoundException, errorType=NOT_FOUND}}

Note the extra variables on path. I don't know the full extend of path data which should be returned, but I need more than just the '_entities'.

Actual behavior

TypedGraphQLError{message='Cluster 'app-stack-deets' not fount in account 'mgmt'', locations=[], path=[_entities], extensions={class=com.netflix.graphql.dgs.exceptions.DgsEntityNotFoundException, errorType=NOT_FOUND}}

Steps to reproduce

Create the following entities:

type SPIN_Cluster {
...
serverGroups(name: String, region: String): [SPIN_ServerGroup!]
...
}

interface SPIN_ServerGroup {
...
}

In the DgsEntityFetcher for the SPIN_Cluster, return a DGSNotFoundException.

I am using JavaSpringBoot (JDK 17.0.3).

Bijnagte commented 1 year ago

It looks like the issue here is that https://github.com/Netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/federation/DefaultDgsFederationResolver.kt#L81 doesn't keep track of the index it is on and create a new DataFetchingEnvironment with the ExecutionStepInfo updated

kilink commented 10 months ago

This was fixed in #1605.