Class List Method List File List

# Class: VertxWebGraphql::ApolloWSHandler

Inherits:
  Object
  - Object
  - VertxWebGraphql::ApolloWSHandler
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb

## Overview

A handler for GraphQL requests sent over Apollo's `subscriptions-transport-ws` transport.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) connection_handler { ... }
  Customize the connection .
- - (self) end_handler { ... }
  Customize the end .
- - (void) handle(event = nil)
  Something has happened, so handle it.
- - (self) message_handler { ... }
  Customize the message .
- - (self) query_context(factory = nil) { ... }
  Customize the query context object.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    20
    21
    22
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 20

    def @@j_api_type.accept?(obj)
      obj.class == ApolloWSHandler
    end

### + (`Object`) j_api_type

    29
    30
    31
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 29

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 32

    def self.j_class
      Java::IoVertxExtWebHandlerGraphql::ApolloWSHandler.java_class
    end

### + (`Object`) unwrap(obj)

    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 26

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    23
    24
    25
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 23

    def @@j_api_type.wrap(obj)
      ApolloWSHandler.new(obj)
    end

## Instance Method Details

### - (`self`) connection_handler { ... }

Customize the connection . This handler will be called at the beginning of each websocket connection.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    54
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 48

    def connection_handler
      if block_given?
        @j_del.java_method(:connectionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::ServerWebSocket)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling connection_handler()"
    end

### - (`self`) end_handler { ... }

Customize the end . This handler will be called at the end of each websocket connection.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    70
    71
    72
    73
    74
    75
    76
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 70

    def end_handler
      if block_given?
        @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::ServerWebSocket)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling end_handler()"
    end

### - (`void`) handle(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

- event (`::VertxWeb::RoutingContext`) (defaults to: `nil`) —
  the event to handle

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 38

    def handle(event=nil)
      if event.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(event.j_del)
      end
      raise ArgumentError, "Invalid arguments when calling handle(#{event})"
    end

### - (`self`) message_handler { ... }

Customize the message . This handler will be called for each VertxWebGraphql::ApolloWSMessage received.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    59
    60
    61
    62
    63
    64
    65
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 59

    def message_handler
      if block_given?
        @j_del.java_method(:messageHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWebGraphql::ApolloWSMessage)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling message_handler()"
    end

### - (`self`) query_context(factory = nil) { ... }

Customize the query context object. The provided `factory` method will be invoked for each incoming GraphQL request.

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    81
    82
    83
    84
    85
    86
    87
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-graphql/apollo_ws_handler.rb', line 81

    def query_context(factory=nil)
      if block_given? && factory == nil
        @j_del.java_method(:queryContext, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_object(yield(::Vertx::Util::Utils.safe_create(event,::VertxWebGraphql::ApolloWSMessage))) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling query_context(#{factory})"
    end