# @arcblock/forge-graphql-client

> GraphQL Client for forge core

Latest version **0.15.0** (published 2019-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arcblock/forge-graphql-client
pnpm add @arcblock/forge-graphql-client
yarn add @arcblock/forge-graphql-client
bun add @arcblock/forge-graphql-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.15.0 |
| Published | 2019-03-22 |
| First published | 2019-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 26 |
| Author | wangshijun |
| Maintainers | wangshijun |
| Keywords | graphql, client, forge, blockchain, arcblock |

## Links

- npm: https://www.npmjs.com/package/@arcblock/forge-graphql-client
- Repository: https://github.com/ArcBlock/forge-js
- Homepage: https://github.com/arcblock/forge-js/packages/forge-graphql-client
- Issues: https://github.com/ArcBlock/forge-js/issues
- npm.io page: https://npm.io/package/@arcblock/forge-graphql-client

## Dependencies (11)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [phoenix](https://npm.io/package/phoenix.md) ^1.3.4
- [camelcase](https://npm.io/package/camelcase.md) ^5.2.0
- [base64-url](https://npm.io/package/base64-url.md) ^2.2.0
- [protobufjs](https://npm.io/package/protobufjs.md) ^6.8.8
- [blueimp-md5](https://npm.io/package/blueimp-md5.md) ^2.10.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0
- [phoenix-channels](https://npm.io/package/phoenix-channels.md) ^1.0.0
- [@arcblock/sdk-util](https://npm.io/package/@arcblock/sdk-util.md) ^0.19.4
- [wolfy87-eventemitter](https://npm.io/package/wolfy87-eventemitter.md) ^5.2.5
- [@arcblock/forge-wallet](https://npm.io/package/@arcblock/forge-wallet.md) ^0.15.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.15.0 (latest) — 2019-03-22
- 0.14.3 — 2019-03-20
- 0.14.0 — 2019-03-18
- 0.13.2 — 2019-03-14
- 0.13.0 — 2019-03-13
- 0.12.3 — 2019-03-12
- 0.12.2 — 2019-03-08
- 0.12.0 — 2019-03-07
- 0.11.1 — 2019-03-05
- 0.11.0 — 2019-03-05
- 0.10.0 — 2019-03-05
- 0.9.0 — 2019-03-05
- 0.8.8 — 2019-03-04
- 0.8.7 — 2019-03-01
- 0.8.6 — 2019-02-27
- … 8 more at https://npm.io/package/@arcblock/forge-graphql-client/versions

## README

# `forge-graphql-client`

> Graphql Client for Forge, provided gRPC similar features to interact with a forge-powered app.


## Table of Contents

* [Install](#install)
* [Usage](#usage)
* [Documentation](#documentation)


## Install

```shell
npm i @arcblock/forge-graphql-client -S
# OR
yarn add @arcblock/forge-graphql-client
```


## Usage

```js
const Mcrypto = require('@arcblock/mcrypto');
const GraphqlClient = require('@arcblock/forge-graphql-client');
const { fromRandom, WalletType } = require('@arcblock/forge-wallet');
const { hexToBytes } = require('@arcblock/forge-util');

const client = new GraphqlClient('http://localhost:8210/api');
console.log({
  queries: client.getQueries(),
  subscriptions: client.getSubscriptions(),
  mutations: client.getMutations(),
  transactions: client.getTxMethods(),
});

(async () => {
  // Query Data
  const chainInfo = await client.getChainInfo();
  const forgeState = await client.getForgeState();
  const block = await client.getBlock({ height: 2 });
  console.log('getChainInfo', chainInfo);
  console.log('getForgeState', forgeState);
  console.log('getBlock', block);

  // Send Transaction
  const wallet = fromRandom(
    WalletType({
      role: Mcrypto.types.RoleType.ROLE_ACCOUNT,
      pk: Mcrypto.types.KeyType.SECP256K1,
      hash: Mcrypto.types.HashType.SHA3,
    })
  );
  const res = await client.sendDeclareTx({
    data: {
      moniker: `wangshijun_${Math.round(Math.random() * 1000)}`,
      pk: Buffer.from(hexToBytes(wallet.publicKey)),
      type,
    },
    wallet,
  });
  console.log(res);
})();
```


## Documentation

Checkout: [API.md](./docs/API.md).

---
_Source: https://npm.io/package/@arcblock/forge-graphql-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
