Giter VIP home page Giter VIP logo

eosio-graphql's Introduction

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
      }
    }
  }
}

eosio-graphql's People

Contributors

deniscarriere avatar dexteryy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.