@Override
    public void onNext(WebSocketFrame webSocketFrame) {
        logger.trace("onNext: {}", webSocketFrame);
        assert subscription != null;
        switch (webSocketFrame.type()) {
            case BINARY:
                graphqlWSSubProtocol.handleBinary(outgoing);
                break;
            case TEXT:
                // Parse the graphql-ws sub protocol. Maybe this could be done in a different thread so not
                // to block the publisher?
                graphqlWSSubProtocol.handleText(webSocketFrame.text(), outgoing);
                /*
                It is RECOMMENDED that Subscribers request the upper limit of what they are able to process,
                as requesting only one element at a time results in an inherently
                inefficient "stop-and-wait" protocol.
                 */
                subscription.request(1);
                break;
            case PING:
                outgoing.writePong();
                subscription.request(1);
                break;
            case CLOSE:
                outgoing.close();
                break;
            // PONG is a noop
            case PONG:
                subscription.request(1);
                break;
            // Continuation is not mentioned in the spec. Should never happen.
            case CONTINUATION:
                logger.trace("Ignoring frame type: {}", webSocketFrame.type());
                subscription.request(1);
                break;
            default:
                // Should never reach here.
                throw new Error();
        }
    }
Calling onSubscribe, onNext, onError or onComplete MUST return normally except when any provided
parameter is null in which case it MUST throw a java.lang.NullPointerException to the caller, for all
other situations the only legal way for a Subscriber to signal failure is by cancelling its
Subscription. In the case that this rule is violated, any associated Subscription to the Subscriber
MUST be considered as cancelled, and the caller MUST raise this error condition in a fashion that is
adequate for the runtime environment.
graphql/src/main/java/com/linecorp/armeria/server/graphql/GraphqlWebSocketSubscriber.java