Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: DataFetchingEnvironment::localContext overwritten by Spring Actuator for Nested Data Fetchers #1780

Closed
kevinlee2198 opened this issue Jan 18, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@kevinlee2198
Copy link

Please read our contributor guide before
creating an issue.

Expected behavior

When Spring boot actuator is present, values passed to child data fetcher via localContext should be accessible following the documentation.

Actual behavior

Values are overridden to instead be a Map containing a SimpleObservation value.
Class cast exception then occurs follows:

"message": "java.lang.ClassCastException: class graphql.GraphQLContext cannot be cast to class java.util.Map (graphql.GraphQLContext is in unnamed module of loader 'app'; java.util.Map is in module java.base of loader 'bootstrap')",

Steps to reproduce

  1. Create Spring boot project with web, graphql, actuator, and dgs dependencies
  2. Create nested data fetcher like the preload example in the documentation
  3. Run a graphql query, querying for the child attribute of the parent

Minimal Reproducible Example: https://github.com/kevinlee2198/dgs-local-context-demo

Note: Remove the actuator dependency and the query works as expected

Note: A test case would be highly appreciated, but we understand that's not always possible

@kevinlee2198 kevinlee2198 added the bug Something isn't working label Jan 18, 2024
@kilink
Copy link
Member

kilink commented Jan 18, 2024

In your example app, you are including the dependency spring-boot-starter-graphql, which is causing this issue (see this code). If you remove that dependency, your example app works fine.

@kilink kilink closed this as completed Jan 18, 2024
@kilink
Copy link
Member

kilink commented Feb 23, 2024

Here is the related issue in spring-graphl.

@kevinlee2198
Copy link
Author

Got it, thanks for being on top of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants