Apollo Link Ethereum
apollo-link-ethereum allows you to use GraphQL to speak directly to a smart contract on the Ethereum blockchain. The package integrates with Apollo Client as a link. There are several resolvers so that you can resolve web3 calls using either web3js 1.0 or Ethers.js. A separate mutations package is available to actually execute transactions (currently only supports ethers.js).
Please see the documentation for each package for more information.
|apollo-link-ethereum||The base package|
|apollo-link-ethereum-resolver-ethersjs||Resolve calls using Ethers.js|
|apollo-link-ethereum-mutations-ethersjs||Send transactions with Ethers.js|
|apollo-link-ethereum-resolver-web3js||Resolve calls using Web3js 1.0|
Here's a simple read-only Example DApp:
A more in-depth application supporting both Ethereum reads (calls) and writes (transactions):
You'll need to install the base package apollo-link-ethereum and one of the resolver packages. If you'd like to execute transactions you should also install the mutations package for the bindings you've selected. Currently there is only a mutations package for Ethers.js.
We use yarn and lerna. Run yarn to install the lerna dependency:
Then use lerna to set up the child packages:
$ lerna bootstrap
The yarn watch command runs both the typescript transpilation and rollup to build the JS into a distributable:
$ yarn watch