swr-graphql
The Idea behind the Example
This is a sample app demonstrating usage of useSWR
, mutate
and trigger
of SWR
library with a Hasura GraphQL API. The app uses native websockets for implementing GraphQL subscriptions on the client.
- Hasura GraphQL APIs for instant GraphQL backend.
- Integrate simple GraphQL queries.
- Optimistic UI with GraphQL mutations.
- GraphQL Subscriptions using native websockets.
Deploy Hasura to get a GraphQL API
-
Click on the following button to deploy GraphQL engine on Hasura Cloud including Postgres add-on or using an existing Postgres database:
-
Open the Hasura console
Click on the button "Launch console" to open the Hasura console.
-
Create table users
Head to the
Data
tab and create a new table calledusers
with columns: id (text), name (text), created_at (timestamp now()). -
Try out a GraphQL Query
query { users { id name created_at } }
One-Click Deploy
Deploy your own SWR project with ZEIT Now.
How to Use
Install it and run:
yarn
yarn dev
# or
npm install
npm run dev
Deploy it to the cloud with now (download)
now