Photo by Milad Fakurian on Unsplash

Making it Easier to Fetch Blockchain Data Using GraphQL

Maxime Julian

--

Blockchain technology holds a lot of promise. It’s a fast-evolving area that’s changing what we can do, especially with Ethereum and other EVM-compatible blockchains. But because it’s so new, it can sometimes be harder to work with than traditional web technologies.

That’s why I’d like to introduce you to a new tool I’ve developed to help make things easier: eth-graphql.

The Problem We’re Solving

When you’re building apps that use blockchain data, one of the biggest headaches can be getting all the information you need. Each page might need data from dozens of different places, and pulling all this together can be a real challenge.

A common way to deal with this is by using a multicall contract. This is a kind of tool that lets you make lots of requests at once, saving you time and making sure all the data you get is as up-to-date as possible. This is particularly important for things that can change quickly, like token prices.

I’ve been using React Query and multicall contracts in my day job, but as someone who’s also worked with more traditional web technologies, I saw potential for something even better — GraphQL.

Introducing eth-graphql

After doing some research and testing out some ideas, I decided to develop and release eth-graphql. It’s an open source project that makes it easier to access contract data from any EVM-compatible blockchain using GraphQL.

I wanted the library to be simple to use. You just need to give the name of a contract and its ABI, and it will automatically build a GraphQL schema for you. Then you can use this to get the data you need — all without leaving your web browser! Plus, it uses a multicall contract to make sure each query only needs to make one request, no matter how many contracts you’re dealing with.

As a bonus, eth-graphql also lets you open a GraphiQL page, where you can see what the generated GraphQL schema looks like and try out your queries.

GraphiQL page opened by eth-graphql to see the generated schema and build your queries

Give eth-graphql a Try

If you’re interested, I’d encourage you to give eth-graphql a go. It’s easy to set up and you can start making your queries in no time. And if you find it useful, I’d appreciate it if you could give it a star on the repository. That way, more people can find out about it and benefit from it.

Integrating GraphQL with blockchain is just the start. As technology continues to advance, I’m sure we’ll see more tools and solutions that bring the best parts of the traditional web to the world of blockchain, making it stronger, more accessible, and more innovative.

--

--