Skip to content

GraphQL Subscriptions 101

Lucah Endicott edited this page Apr 28, 2022 · 9 revisions

GraphQL Subscriptions

What are subscriptions?

Resources

Testing real-time data with AWS AppSync

Guide to testing real-time data with AWS AppSync for the RightOn Web App

  1. Log-in to RightOn AWS console and search for AppSync
Screen Shot 2022-04-27 at 11 16 22 AM
  1. Select mobilebackend-dev.
Screen Shot 2022-04-27 at 11 16 42 AM
  1. Select "Queries" form the sidebar.
Screen Shot 2022-04-27 at 11 17 23 AM
  1. Select "Mutation" from the explorer drop down and click the "+" to add it.

Screen Shot 2022-04-28 at 11 26 39 AM

  1. Select a game session field mutation to add with its required inputs using an existing sample game ID.
  • Sample Game ID to use 08d19de5-6a49-4153-b3fc-998d783116c5
  • Copy paste this ID into the "id*" input field in the purple text.

Screen Shot 2022-04-28 at 11 28 47 AM

  1. Copy the existing AWS console URL from the page you're currently on into a new browser tab.
  • In your new AWS query tab - select "Subscription" from the explorer drop down and click the "+" to add it.

Screen Shot 2022-04-28 at 11 32 55 AM

  1. In your new tab with the subscription query added, select the corresponding game session field and select the fields you've taken as inputs from the Mutation query in your previous console tab.

Screen Shot 2022-04-28 at 11 34 40 AM

  1. Click the "play" button above your subscription - this starts the subscription to listen for any updates.

Screen Shot 2022-04-28 at 11 38 16 AM

  1. Direct yourself back to your AWS tab with your mutation query in place. Select a new "isPhaseOne" field from the dropdown.

Screen Shot 2022-04-28 at 11 40 11 AM

  1. Click "Play" in your mutation explorer. You will see the data response with which phase you have chosen on the far right column.

Screen Shot 2022-04-28 at 11 41 59 AM

  1. Direct yourself to the AWS console tab with your subscription running and you'll see the "isPhaseOne" field reflecting the status change in real-time!. You can continue to change the status and click play on your mutation query, and each time you view the subscription tab, that updated change will be reflected. This is a subscription listening for real-time changes anytime new information is added or updated.

Screen Shot 2022-04-28 at 11 45 28 AM