Skip to content

Local GraphQLContext doesn't propagate values when spring actuator is active #1142

Closed as not planned
@DoodlesOnMyFood

Description

@DoodlesOnMyFood

On my controllers my code propagates values via local context, so something like this.

@SchemaMapping(typeName = "Foo", field = "bar")
public List<Bar> getBars(DataFetchingEnvironment env) {
var localContext = (GraphQLContext) Objects.requireNonNull(env.getLocalContext());
...
localContext.put("BAR_ID", service.getValue(bar.getId()));
...
}

@SchemaMapping(typeName = "Bar", field = "name")
public String getBarName(DataFetchingEnvironment env) {
var localContext = (GraphQLContext) Objects.requireNonNull(env.getLocalContext());
...
var barId = (String) localContext.get("BAR_ID");
...
}

Which worked fine for my use-case.

But I noticed that my code breaks when I activate spring-actuator.

To elaborate, the local context would no longer have my values, and only contain 'micrometer.observation' values.

var barId = (String) localContext.get("BAR_ID"); // null

I read the documentations regarding contexts and observability but failed to find a fix.

I was wondering if this was intentional and I need some additional configuration to make my code work.

I haven't tested with global context values.

Metadata

Metadata

Assignees

Labels

status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions