curl --header "Content-Type: application/json" \
--request POST \
--data '{"query":"query { medication ( where:{ _and: [ { diagnosis_code: {_in: [\"S00-T88\",\"T20-R73\"]}}, { price: {_lt: 150}}, { inventory: {_gt: 10}} ] } ) { id name diagnosis_code price inventory } }","variables":null}' \
https://hasura-graphql-test.herokuapp.com/v1alpha1/graphql
-
Get a Postgres instance and the Hasura GraphQL engine running on Heroku's free tier in less than a minute: https://docs.hasura.io/0.15/graphql/manual/getting-started/heroku-simple.html
-
Create table and add test data
- Create a table named
medication
with the following schema:
-
Add some test data:
name diagnosis_code price inventory Ibuprofen T39.311A 2.00 12 Lyrica oral S00-T88 148.00 15 Butrans transdermal S00-T88 10.00 121 Ketorolac TROMETHAMINE T21.431C 211.50 1 diclofenac potassium oral T20-R73 12.50 9 Advil PM oral T20-R73 160.00 123
- Create a table named
-
Use the GraphiQL window (click on
GRAPHIQL
link) to run the the following GraphQL query:query { medication ( where:{ _and: [ { diagnosis_code: {_in: ["S00-T88","T20-R73"]}}, { price: {_lt: 150}}, { inventory: {_gt: 10}} ] } ) { id name diagnosis_code price inventory } }
-
Run the following query (or just change the
query
keyword tosubscription
in the above query and run it again) and modify the data in themedication
table in another tab for real-time updates in your response:subscription { medication ( where:{ _and: [ { diagnosis_code: {_in: ["S00-T88","T20-R73"]}}, { price: {_lt: 150}}, { inventory: {_gt: 10}} ] } ) { id name diagnosis_code price inventory } }