Class GraphQlCookieInterceptor

java.lang.Object
com.espacogeek.geek.config.GraphQlCookieInterceptor
All Implemented Interfaces:
org.springframework.graphql.server.WebGraphQlInterceptor

@Configuration public class GraphQlCookieInterceptor extends Object implements org.springframework.graphql.server.WebGraphQlInterceptor
Interceptor that manages refreshToken HttpOnly cookie operations for login, refreshToken, and logout GraphQL mutations.

Before execution begins, this interceptor injects shared containers into the GraphQLContext:

  • "incomingRefreshToken" – the value of the refreshToken cookie from the incoming request, extracted from the Cookie HTTP header. Controller methods read this value instead of using @CookieValue, which is not reliably resolved by Spring for GraphQL's argument resolver chain.
  • "pendingRefreshTokens" – controller methods add a refresh token here when one should be set as an HttpOnly cookie on the response.
  • "clearRefreshCookieHolder" – a boolean[1] array; controller methods set index [0] to true to signal that the refresh token cookie should be cleared (e.g., on logout).

After execution completes, this interceptor reads the containers and writes the appropriate Set-Cookie header to the HTTP response via WebGraphQlResponse.getResponseHeaders().

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.graphql.server.WebGraphQlInterceptor

    org.springframework.graphql.server.WebGraphQlInterceptor.Chain
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    reactor.core.publisher.Mono<org.springframework.graphql.server.WebGraphQlResponse>
    intercept(org.springframework.graphql.server.WebGraphQlRequest request, org.springframework.graphql.server.WebGraphQlInterceptor.Chain chain)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.graphql.server.WebGraphQlInterceptor

    andThen, apply
  • Constructor Details

    • GraphQlCookieInterceptor

      public GraphQlCookieInterceptor(JwtConfig jwtConfig)
  • Method Details

    • intercept

      @NonNull public reactor.core.publisher.Mono<org.springframework.graphql.server.WebGraphQlResponse> intercept(@NonNull org.springframework.graphql.server.WebGraphQlRequest request, @NonNull org.springframework.graphql.server.WebGraphQlInterceptor.Chain chain)
      Specified by:
      intercept in interface org.springframework.graphql.server.WebGraphQlInterceptor