GraphQL Subscriptions
SwiftGraphQL packs a fully-featured GraphQL subscription client that conforms to the GraphQL over WebSocket protocol specification.
You can use GraphQLWebSocket as a standalone client or with the query-builder or in combination with SwiftGraphQLClient.
Using WebSocketExchange
To create a subscription request on the client, you need to use WebSocketExchange
. WebSocketExchange
depends on the GraphQLWebSocket
client that you may further modify to suit your needs.
SwiftGraphQLClient also exposes public utility methods that let you use SwiftGraphQL query builder to make a subscription and decode responses automatically.
Using GraphQLWebSocketClient
In case you don’t want to go all-in on SwiftGraphQL, you can use just the WebSockets implementation. It doesn’t depend on any other parts of the codebase and strictly follows the GraphQL over WebSocket protocol.
Additionally, if you import the SwiftGraphQL
library and make a selection, you can also automatically encode queries and decode responses.