Deploy a GraphQL API + MongoDB for the EOSIO blockchain
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix linting Aug 31, 2018
.dockerignore
.gitignore
.travis.yml
Dockerfile Update dockerfile Aug 1, 2018
LICENSE Update license & package.json Jul 26, 2018
README.md add APIs for programmatic use, supports extensions and customizations Aug 7, 2018
config.ts Add sort & limit Jul 28, 2018
docker-compose.yml
index.ts fix lint errors Aug 7, 2018
package-lock.json update tsconfig Aug 27, 2018
package.json
service.ts update tsconfig Aug 27, 2018
tsconfig.json
tslint.json Add extra attributes to actions Aug 1, 2018

README.md

EOSIO GraphQL API

Build Status MIT licensed

Deploy a GraphQL API + MongoDB for the EOSIO blockchain.

Install

$ git clone https://github.com/EOS-BP-Developers/eosio-graphql.git
$ cd eosio-graphql
$ npm install

Quickstart

$ npm start
🚀 Server ready at http://localhost:4000/graphql

Programmatic use

import { eosGraphQLGateway, gql } from 'eosio-graphql'
import { getMongoClient } from "./mongoClient";

(async () => {

  const {
    startService,
    server, // optional
    service, // optional
  } = eosGraphQLGateway({
    mongoClient: await getMongoClient(),
    host: 'localhost', // optional
    port: 4000, // optional
    buildSchema: ({ // optional
      scalarSchema,
      typeSchema,
      querySchema,
    }) => gql`
      ${scalarSchema}
      # my scalars
      schema {
        query: Query
      }
      ${typeSchema}
      # my types
      type Query {
        ${querySchema}
        # my queries
      }
    `,
    buildResolvers(resolvers) {  // optional
      return Object.assign(resolvers, { /* my resolvers */ });
    },
    abiDir = './my-abi-files/',  // optional
  });

  server.use(/* ... */);  // optional

  service.use(/* ... */);  // optional

  startService();

})();

Contributors

This is made with ♥ by:

Voting on the EOSIO mainnet helps build more awesome tools for the EOS community.

GraphQL examples

eosio.token transfer

Find most recent 50 transfers from chainceout11 using the KARMA token contract.

query {
  eosiotoken {
    transfer (
      limit: 50,
      from: "chainceout11"
      contracts: ["therealkarma"],
      sort: {block_num: -1}
    ) {
      data {
        from
        to
        quantity
        memo
      }
    }
  }
}

eosio blocks

Find the most recent irreversible blocks.

query {
  blocks(sort: { block_num: -1 }, match: { irreversible: true }) {
    block_num
    irreversible
    block {
      producer
    }
  }
}

eosio account

Query an account by name & block_num to get the exact stake_quanity at that given referen block number.

query {
  account(name:"eosnationftw", block_num:6000000) {
    name
    block_num
    stake_quantity
    stake_net_quantity
    stake_cpu_quantity
  }
}

eosio.forum post

Query all posts based on an exact title match.

query {
  eosforumtest {
    post(title: "SYSTEM_UPGRADE") {
      block_num
      data {
        account
        post_uuid
        title
        content
      }
    }
  }
}

eosio.forum vote

Query all votes based on a particular proposition.

query {
  eosforumtest {
    vote(proposition: "http://ballista/eosconstitution.io/public/proposals/4/articles/61#comment-1") {
      block_num
      data {
        voter
        proposition
        proposition_hash
        vote_value
      }
    }
  }
}