Class GraphQlWebSocketMessage

java.lang.Object
org.springframework.graphql.server.support.GraphQlWebSocketMessage

public class GraphQlWebSocketMessage extends Object
Represents a GraphQL over WebSocket protocol message.
Since:
1.0.0
Author:
Rossen Stoyanchev
See Also:
  • Method Details

    • getId

      @Nullable public String getId()
      Return the request id that is applicable to messages associated with a request, or null for connection level messages.
    • getType

      public String getType()
      Return the message type value as it should appear on the wire.
    • resolvedType

      public GraphQlWebSocketMessageType resolvedType()
      Return the message type as an emum.
    • getPayload

      public <P> P getPayload()
      Return the payload. For a deserialized message, this is typically a Map or List for an "error" message.
      Type Parameters:
      P - teh payload type
    • setId

      public void setId(@Nullable String id)
    • setType

      public void setType(String type)
    • setPayload

      public void setPayload(@Nullable Object payload)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • connectionInit

      public static GraphQlWebSocketMessage connectionInit(@Nullable Object payload)
      Create a "connection_init" client message.
      Parameters:
      payload - an optional payload
    • connectionAck

      public static GraphQlWebSocketMessage connectionAck(@Nullable Object payload)
      Create a "connection_ack" server message.
      Parameters:
      payload - an optional payload
    • subscribe

      public static GraphQlWebSocketMessage subscribe(String id, GraphQlRequest request)
      Create a "subscribe" client message.
      Parameters:
      id - unique request id
      request - the request to add as the message payload
    • next

      public static GraphQlWebSocketMessage next(String id, Map<String,Object> responseMap)
      Create a "next" server message.
      Parameters:
      id - unique request id
      responseMap - the response map
    • error

      public static GraphQlWebSocketMessage error(String id, List<GraphQLError> errors)
      Create an "error" server message.
      Parameters:
      id - unique request id
      errors - the error to add as the message payload
    • complete

      public static GraphQlWebSocketMessage complete(String id)
      Create a "complete" server message.
      Parameters:
      id - unique request id
    • ping

      public static GraphQlWebSocketMessage ping(@Nullable Object payload)
      Create a "ping" client or server message.
      Parameters:
      payload - an optional payload
    • pong

      public static GraphQlWebSocketMessage pong(@Nullable Object payload)
      Create a "pong" client or server message.
      Parameters:
      payload - an optional payload