DEV Community

Cover image for Building GraphQL APIs on Ethereum

Building GraphQL APIs on Ethereum

Nader Dabit on May 04, 2021

The number of production dapps continues to explode and the demand for developers building with Solidity and other blockchain languages continues t...
Collapse
 
camerenisonfire profile image
Cameren Dolecheck

Nice tutorial, thank you for creating high quality blockchain related tutorials on Dev.to!

I had not heard of The Graph until recently. What it allows to be built with relative ease is quite cool. The UI design of the application is great, too.

Maybe as a follow up, or a link to an existing explanation, it would be helpful to get more explanation on what's going on in mapping.ts.

Collapse
 
ethchainheavy profile image
Roberto Cantu

Thanks for the tutorial!

One thing I had to change: I couldn't get yarn deploy to work, so I went with the CLI command provided from The Graph UI graph deploy --product hosted-service <GitHub_Username>/<Subgraph_name>

Otherwise, the tutorial worked great!

Collapse
 
dmytro profile image
bilykdmytro • Edited

Thank you for tutorial!
I think for initializing Zora contract we need to use / instead of \ at
graph init --from-contract 0xabEFBc9fD2F806065b4f3C237d4b59D9A97Bcac7 --network mainnet / --contract-name Token --index-events

At least I had to do it on Windows.

Collapse
 
konbuscus profile image
Axel Masson

Hello ! I'm getting Compile data source: Token => build\Token\Token.wasm

  • Compile subgraphERROR TS2322: Type 'generated/schema/Token | null' is not assignable to type 'generated/schema/Token'.

token.contentURI = event.params._uri;

 in src/mapping.ts(14,3)

for all the function that uses or load Token do you have any idea on why ?
Enter fullscreen mode Exit fullscreen mode
Collapse
 
dabit3 profile image
Nader Dabit

Hey, unsure what happened, maybe there was an update to the CLI, but I just fixed the mappings and it should work now, sorry for the inconvenience!

Collapse
 
jeainnybean profile image
Friendly Tin Man • Edited

Hi Nader!
The command "graph build" failed to compile data source mapping. This was caused by the error "Type 'Bytes' is not assignable to type 'string'."

This error pops up in two places:

  1. inside mapping.ts function "handleTokenIPFSPathUpdated",
    entity.indexedTokenIPFSPath = event.params.indexedTokenIPFSPath

  2. inside mapping.ts function "handleMinted",
    entity.indexedTokenIPFSPath = event.params.indexedTokenIPFSPath

How can I fix this issue?

Collapse
 
soniajoseph profile image
Sonia Joseph

I'm also getting this issue. Any updates on progress?

Collapse
 
darkeye123 profile image
Matej Leško

Thank you!!!! It is very interesting :) I like you omit basic stuff and go to the core

Collapse
 
rafacypherpunk profile image
Rafael Fuentes

Eres el mejor! Estoy aprendiendo mucho gracias a ti.

Collapse
 
zomdar profile image
Wooj

great tutorial dude! really enjoyed the content

Collapse
 
lupelius profile image
Serdar Senay

I was having an issue with graph auth stage, getting an error Error: Error storing deploy key: Invalid URL

Solution was to run this command instead:
graph auth --product hosted-service

Collapse
 
arcticmatt profile image
Matt Lim

FYI I needed to run yarn add @graphprotocol/graph-ts before graph build to make the build work

Collapse
 
freshcotech profile image
Darrius Singleton

Is GRT limited to just Ethereum based queries or can it be used for other protocols like Solana?

Collapse
 
orangeagain profile image
orangeagain

There Is Free Geth Graphql: querymaid.com/