![]() # firing up yet another Express boilerplate with express-generator express secure-websocket If none of these libraries fits your use case, you can also create your own PubSubEngine subclass.You’ve just generated a fresh Express project ready to develop your next API - which happens to require a secure WebSocket connection. The following are community-created PubSub libraries for popular event-publishing systems: Instead, you should use a subclass of the PubSubEngine abstract class that you can back with an external datastore such as Redis or Kafka. This means that events published by one instance of your GraphQL server are not received by subscriptions that are handled by other instances. Production PubSub librariesĪs mentioned above, the PubSub class is not recommended for production environments, because its event-publishing system is in-memory. If no user exists or the lookup otherwise fails, our resolvers can throw an error and the corresponding subscription operation is not executed. To sum up, the example above looks up a user based on the authentication token sent with each subscription request before returning the user object to be used by our resolvers. For example, a chat application's server might use a subscription to push newly received messages to all clients in a particular chat room.īecause subscription updates are usually pushed by the server (instead of polled by the client), they generally use the WebSocket protocol instead of HTTP. Most commonly, updated results are pushed from the server to subscribing clients. Subscriptions are long-lasting GraphQL read operations that can update their result whenever a particular server-side event occurs. For more information about the differences between the two libraries, see Switching from subscriptions-transport-ws. We no longer recommend using the previously documented subscriptions-transport-ws, because this library is not actively maintained. This article uses the graphql-ws library to add support for subscriptions to Apollo Server 4. Subscriptions are not currently supported in Apollo Federation. ![]() You can enable support for subscriptions as described below. Apollo Server does not provide built-in support for subscriptions. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |