Replies: 3 comments 11 replies
-
Hmm, yes it does seem we removed the response from the context factory. This could easily be added back in. As of right now though it would have to be accomplished with the |
Beta Was this translation helpful? Give feedback.
-
In both 3.x and 4.x If it is some calculated value from incoming request that should also be a part of your GraphQL context, you could calculate it in a webfilter and store it in a subscriber context so you can then retrieve it from context in your context factory. |
Beta Was this translation helpful? Give feedback.
-
5.x.x can access the response as below. class CustomGraphQLContextFactory : GraphQLContextFactory<Nothing, ServerRequest> {
@Deprecated("The generic context object is deprecated in favor of the context map")
override suspend fun generateContext(request: ServerRequest): Nothing? = null
override suspend fun generateContextMap(request: ServerRequest): Map<*, Any> {
return mapOf("request" to request)
}
}
class SampleQuery : Query {
fun test(env: DataFetchingEnvironment): Int {
val response = env.graphQlContext.get<ServerRequest>("request").exchange().response
return 0
}
} |
Beta Was this translation helpful? Give feedback.
-
Version 3.x.x supported access to server response instance when implementing the graphql context.
I have to set a header in the response while graphql sends the response back.
How to do it in 4.x.x given the following code -
In 3.x.x it was much more convenient -
Beta Was this translation helpful? Give feedback.
All reactions