spring-projects / spring-graphql

Spring Integration for GraphQL
https://spring.io/projects/spring-graphql
Apache License 2.0
1.5k stars 297 forks source link

WebSocketGraphQlInterceptor.intercept keeps returning internal error #953

Closed cepoiubogdan-query-labs closed 2 months ago

cepoiubogdan-query-labs commented 3 months ago

Hello! I am implementing WebSocketGraphQlInterceptor for a webapplication, but the intercept method keeps returning

{
    "id": "dc758d5a-451a-433d-9c10-8f16959bd224",
    "type": "error",
    "payload": [
        {
            "message": "Subscription error",
            "locations": [],
            "extensions": {
                "classification": "INTERNAL_ERROR"
            }
        }
    ]
}

Regardles of what I do first we have tried overriding the method, to adapt to our code, without success, an then we have tried without overriding the method, the result is still the same. We are using Springboot 3.2.3.

bclozel commented 3 months ago

Can you share a minimal sample application that we can take a look at?

cepoiubogdan-query-labs commented 3 months ago

What would you like to see in more detail?

cepoiubogdan-query-labs commented 3 months ago

an example of the intercept method would look like this:

    @Override
    public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request,
            Chain chain)
    {
        try
        {
            if (request != null)
            {
                if (request instanceof WebSocketGraphQlRequest)
                {
                    WebSocketGraphQlRequest wsRequests = (WebSocketGraphQlRequest) request;
                    WebSocketSessionInfo sessionInfo = wsRequests
                            .getSessionInfo();
                    Map<String, Object> extensions = request.getExtensions();
                    log.info(new StringBuilder()
                            .append("Intercepting websocket request")
                            .append("; operationName=[")
                            .append(request.getOperationName()).append("]")
                            .append(", clientId=[")
                            .append(SessionUtils.getAttributeFromMap(extensions,
                                    SessionUtils.CLIENT_ID))
                            .append("]")
                            .append(", sessionId=[")
                            .append(sessionInfo.getId()).append("]")
                            .append(", remoteAddress=[")
                            .append(String.valueOf(
                                    sessionInfo.getRemoteAddress()))
                            .append("]")
                            .toString());

                    sessionService.initializeJwtSession(wsRequests);
                }
                else
                {
                    if (log.isDebugEnabled())
                        log.debug(new StringBuilder()
                                .append("Intercepting request")
                                .append("; operationName=[")
                                .append(request.getOperationName()).append("]")
                                .append(", clientId=[")
                                .append(SessionUtils
                                        .getClientId(request.getHeaders()))
                                .append("]")
                                .append(", remoteAddress=[")
                                .append(request.getHeaders()
                                        .getFirst(SessionUtils.REAL_IP))
                                .append("]")
                                .toString());
                }
            }

            return WebSocketGraphQlInterceptor.super.intercept(request, chain);
        }
        catch (Throwable e)
        {
            log.error(new StringBuilder()
                    .append("Exception occured during processing request")
                    .append("; request=[").append(request).append("]")
                    .toString(), e);

            return Mono.error(e);
        }
    }

We are currently using graphql-java version 21.3 Java Springboot 3.2.3, Spring graphql 1.2.5, and Spring security 3.2.3

rstoyanchev commented 3 months ago

@cepoiubogdan-query-labs you need to do more investigation to understand the root cause for the error. If you provide a small isolated sample, we can have a look, but as it is the information provided is insufficient to understand or reproduce the issue.

spring-projects-issues commented 2 months ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 2 months ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.