# Class GraphQLSubscription

java.lang.Object
com.codename1.io.graphql.GraphQLSubscription

public final class GraphQLSubscription extends java.lang.Object

Handle for a live GraphQL subscription. Implements the `graphql-transport-ws` message protocol over `WebSocket` (introduced in core alongside this package): `connection_init` -> `connection_ack` -> `subscribe`, then a stream of `next` payloads terminated by `complete` or `error`.

Each `next` payload's `data` object is mapped to `T` and delivered to

invalid reference

    Handler#onNext(Object)

. All handler callbacks are dispatched on

the Codename One EDT (matching the `OnComplete` semantics the query and mutation paths use), even though the underlying WebSocket fires on a background thread.

The connection offers the `graphql-transport-ws` subprotocol during the WebSocket handshake (RFC 6455 `Sec-WebSocket-Protocol`), as the graphql-ws specification requires.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `GraphQLSubscription.Handler<T>`
  Receives the events of one subscription.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `cancel()`
  Cancels the subscription: sends a `complete` to the server and closes the socket.

  ### Methods inherited from class java.lang.Object

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

- ## Method Details

  - ### cancel

    public void cancel()
    Cancels the subscription: sends a `complete` to the server and closes the socket. Idempotent; safe to call from any thread.