Querying Hivemind with GraphQL
For the past few weeks I've been looking into the best way to serve the data from hivemind via a GraphQL API. had a similar idea but implemented a REST API which you can check out here. The main motivation for this is that I wanted to revive my DMTV project and rewrite a lot of it using some new technologies I've learnt. One of those technologies is GraphQL. If you don't know what GraphQL is you can learn more about it here. Basically, it allows the client to be more in control of what data it receives from an API.
I began writing my own API querying the hivemind database directly and it worked really well. However, I then stumbled upon Hasura which implements everything for you and can easily be setup with an existing database schema like hivemind. It's written in Haskell and is very performant.
After messing around with Hasura for a while I was able to get everything working and started to explore the potential. If you are somewhat familiar with GraphQL you can find some possible queries here. Each array is limited to 100 items so you need to use pagination if you want more. Cursor based pagination should be coming to Hasura soon but for now you can use limit and offest.
The great thing about GraphQL is that it's self documenting so head over to https://steem-graphql.jakerawsthorne.co.uk and click the green schema button to see what you can query. Please note that the actual api is served from https://hivemind-graphql.jakerawsthorne.co.uk/v1alpha1/graphql. If you experience any slow queries just let me know and I'll see what I can do. Usually, setting the order_by to id is an easy way to speed up queries
I plan to keep hosting mine publically but if anyone wants help setting Hasura up with their own Hivemind instance just let me know.
Soon I will write some posts showing you how to use the API with React and Apollo Client using the new hooks feature
Leave Querying Hivemind with GraphQL to:
Read more #utopian-io posts
Best Posts From Jake Rawsthorne
We have not curated any of jrawsthorne's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Jake Rawsthorne
- Introducing a new STEEM frontend: LiveSteem
- Would you use a frontend that functioned like a live chat?
- Something I've been testing out recently
- Querying Hivemind with GraphQL
- Busy 2.5.1 Bug: Duplicate comment when showing more replies from a nested comment page
- Busy 2.5.1 Bug: Edit post button doesn't show the post data in the editor initially
- Development Update #5: Comments, Loading States and Refresh Feeds
- Busy.org Bug: Post with no json_metadata crashes the whole page
- Development Update #4: Write New Post, Trending Posts and Upvote Post
- Test
- Brooklyn Nine-Nine review test
- Deadpool 2 test
- Deadpool test
- test
- Game of thrones test review
- Development Update #3: Updated Design, Recommended, Actors Page and New Post Page
- Carbon - Create and share beautiful images of your source code
- Busy.org: Going back in history takes you to the same post page if you got there from a modal
- Busy.org: Reblogged username disappears when you like a post
- Development Update #2: Ratings, Subscriptions and Profiles