在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):doyleyoung/apollo-graphql-subscriptions-example开源软件地址(OpenSource Url):https://github.com/doyleyoung/apollo-graphql-subscriptions-example开源编程语言(OpenSource Language):JavaScript 87.8%开源软件介绍(OpenSource Introduction):Apollo GraphQL Subscriptions ExampleSimple application used to demonstrate minimalistic setup for an Apollo GraphQL Subscriptions architecture. System Architecture
The master branch implementation uses filtering to decide if a message is to be sent to a given subscriber. The client app generates a random number to be used as the auth token. All requests placed to the GraphQL server will include the auth token in it. At the server, the auth token will be stored in the GraphQL context and eventually used by the filter function that validates if a message is intended to be sent to any given subscriber. In a real application, the GraphQL server would have to first validate the auth token against a token provider before proceding with any request. Start Subscription Client and Server appsIn a terminal do: cd server-app
yarn start In another terminal cd client-app
yarn start Test it
Your client page as well as the GraphiQL subscription page should now be displaying the new message. Using CURL to exercise GraphQL Mutation: curl -k -H "Content-Type: application/json" -X POST -d '{ "operationName": null, "query": "mutation AddMessage { addMessage(message: \"My CURL message\", broadcast: false) }", "variables": "{}" }' http://localhost:5060/graphql Using the subscription ObservableCheck the observable branch for the simplest subscription implementation. Using the withApollo decoratorFor an example using the withApollo decorator see the withApollo branch. Using Apollo's subscribeToMoreCheckout subscribeToMore branch for an example implementation using Apollo's subscribeToMore subscription callback function. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论