Docs
  • ClishaChain
  • Quick Start
    • Whats is ClishaChain
    • Install
    • Start Node
    • How To
    • Genesis File
  • Consensus
    • Proof of Authority (PoA)
    • QBFT
    • Validators
    • Bootnodes
  • Transactions
    • Transaction pool
    • Transaction types
    • Transaction Validation
  • Operate a node
    • Data storage formats
    • Events and logs
    • Backup/restore node instance
    • Add and remove validators without voting
  • JSON RPC Commands
    • Access Logs
    • Authenticate
    • Graphql
    • JSON RPC
    • RPC Pub/Sub
Powered by GitBook
On this page
  • GraphQL requests with cURL
  • GraphQL requests with GraphiQL app
  • Pending
  1. JSON RPC Commands

Graphql

How to access the ClishaChain API using GraphQL

PreviousAuthenticateNextJSON RPC

Last updated 10 months ago

GraphQL can reduce the overhead needed for common queries. For example, instead of querying each receipt in a block, GraphQL can get the same result with a single query for the entire block.

The [Clisha GraphQL schema] describes the GraphQL implementation for Ethereum. Enable the GraphQL service using .

!!! note

GraphQL is not supported over WebSocket.

Access the GraphQL endpoint at http://<HOST>:<PORT>/graphql. Configure <HOST> and <PORT> using and . The default endpoint is http://127.0.0.1:8547/graphql.

GraphQL requests with cURL

with an equivalent query include a GraphQL request and result in the method example.

!!! example

The following [`syncing`](../../reference/api/index.md#eth_syncing) request returns data
about the synchronization status.

```bash
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{syncing{startingBlock currentBlock highestBlock}}"}' http://localhost:8547/graphql
```

GraphQL requests with GraphiQL app

The third-party tool, , provides a tabbed interface for editing and testing GraphQL queries and mutations. GraphiQL also provides access to the [Clisha GraphQL schema] from within the app.

Pending

transactionCount and transactions supports the Pending query.

!!! important

Besu does not execute pending transactions so results from `account`, `call`, and `estimateGas`
for Pending do not reflect pending transactions.

!!! example

=== "Pending transaction count"

    ```bash
    curl -X POST -H "Content-Type: application/json" --data '{ "query": "{pending {transactionCount}}"}' http://localhost:8547/graphql
    ```

=== "Result"

    ```bash
    {
      "data" : {
        "pending" : {
          "transactionCount" : 2
        }
      }
    }
    ```

!!! example

=== "Pending transactions"

    ```bash
    curl -X POST -H "Content-Type: application/json" --data '{ "query": "{pending {transactions{hash}}}"}' http://localhost:8547/graphql
    ```

=== "Result"

    ```bash
    {
      "data" : {
        "pending" : {
          "transactions" : [ {
            "hash" : "0xbb3ab8e2113a4afdde9753782cb0680408c0d5b982572dda117a4c72fafbf3fa"
          }, {
            "hash" : "0xf6bd6b1bccf765024bd482a71c6855428e2903895982090ab5dbb0feda717af6"
          } ]
        }
      }
    }
    ```
command line options
graphql-http-host
graphql-http-port
ClishaChain JSON-RPC API methods
GraphQL
GraphiQL
GraphiQL