Querying Hivemind with GraphQLsteemCreated with Sketch.

in #utopian-io6 years ago

For the past few weeks I've been looking into the best way to serve the data from hivemind via a GraphQL API. @emrebeyler 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

Sort:  

Great to see all the new applications and projects arising out of the move to Hivemind. Why is the fact that GraphQL written in Haskel important?

Posted using Partiko iOS

Hello there! Is there a github repository for this project? If so, could you please provide the link to it?

Hi, I didn't end up using the code I'd written so no. I probably should have remove the utopian tag before posting.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.



I'm a huge fan of apollo server

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.033
BTC 92268.82
ETH 3102.93
USDT 1.00
SBD 3.03