spring-projects / spring-graphql

Spring Integration for GraphQL
https://spring.io/projects/spring-graphql
Apache License 2.0
1.52k stars 300 forks source link

Observation instrumentation assumes local context is a GraphQLContext #918

Closed bclozel closed 7 months ago

bclozel commented 7 months ago

Currently, our GraphQlObservationInstrumentation wraps the local GraphQLContext when passing it on to the next child DataFetcher in order to set the current observation in the context with the ObservationThreadLocalAccessor.KEY key.

While graphql.GraphQLContext is a popular choice of context implementation, DataFetcher can choose to use custom types that do not extend this type.

We should relax this requirement and make sure to contribute only if the local context in DataFetchingEnvironment is null or if it is already an instance of GraphQLContext.