This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
Replies: 1 comment
-
i also want to add emphasis on how to avoid relaying on implicit cast as it's a generic type method // kotlin
fun createRoom(input: CreateRoomInput, environment: DataFetchingEnvironment): Room {
environment.getContext<CustomGraphQLContext>().apply{
roomService.create(it.getTenantId(), input)
}
} // java
public Room createRoom(final CreateRoomInput input, final DataFetchingEnvironment environment) {
return roomService.create( environment.getContext<CustomGraphQLContext>().getTenantId(), input);
} if we inspect i want to know how can i get access to env.getContext<GraphQLServletContext>().httpServletRequest
// arbitrary calls to request to demonstrate my usage, i'm using it to authenticate for instance
.getSession(true)
.setAttribute("SPRING_SECURITY_CONTEXT", SecurityContextHolder.getContext());
otherwise how can i do that? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I used to use custom
GraphQLServletContext
to hold request-scoped variables (context.getTenantId()
) like this:However
environment.getContext()
method is new deprecated and context returned fromenvironment.getGraphQlContext()
cannot be casted toCustomGraphQLContext
. Is there new/another way how can I store and retrieve request-scoped variables?Beta Was this translation helpful? Give feedback.
All reactions