Bcc GraphQL
Cross-platform, typed, and queryable API for Bcc. The project contains multiple packages for composing
GraphQL services to meet specific application demands, and a docker-compose stack serving the included
bcc-graphql-server Dockerfile, the extended hasura Dockerfile, bcc-node-ogmios. The schema is defined in
native .graphql
, and used to generate a TypeScript package for client-side static typing. A mutation is available to
submit a signed and serialized transaction to the local node.
Apollo Server exposes the NodeJS execution engine over a HTTP endpoint, and includes support for open source metrics
via Prometheus, and implementing operation filtering to deny unexpected queries. Should you wish to have more control
over the server, or stitch the schema with an existing service, consider importing the executable schema from the
@bcc-graphql/api-*
packages only.
GraphQL is a query language and execution environment with server and client implementations across many programming languages. The language can be serialized for network transmission, schema implementations hashed for assurance, and is suited for describing most domains.
TypeScript (and JS) has the largest pool of production-ready libraries, developers, and interoperability in the GraphQL and web ecosystem in general. TypeScript definitions for the schema, generated by GraphQL Code Generator, are available on npm.
Ogmios is a protocol translation service written in Haskell running on top of bcc-node. It offers a JSON interface through WebSockets and enables applications to speak Shardagnostic' client mini-protocols via remote procedure calls.
Check the releases for the latest version.
git clone \
--single-branch \
--branch <VERSION> \
--recurse-submodules \
https://github.com/The-Blockchain-Company/bcc-graphql.git \
&& cd bcc-graphql
Choose one of the following:
Boot the docker-compose stack using a convention for container and volume scoping based on the network, as well as optionally hitting the remote cache to speed up the build. The containers are detached, so you can terminate the log console session freely. See Docker Compose docs to tailor for your use-case
mainnet
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
docker-compose up -d --build &&\
docker-compose logs -f
testnet
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
API_PORT=3101 \
HASURA_PORT=8091 \
OGMIOS_PORT=1338 \
POSTGRES_PORT=5433 \
METADATA_SERVER_URI="https://metadata.bcc-testnet.tbcodev.io" \
docker-compose -p testnet up -d --build &&\
docker-compose -p testnet logs -f
aurum -purple
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
API_PORT=3102 \
HASURA_PORT=8092 \
OGMIOS_PORT=1339 \
POSTGRES_PORT=5434 \
METADATA_SERVER_URI="https://metadata.bcc-testnet.tbcodev.io" \
docker-compose -p aurum -purple up -d --build &&\
docker-compose -p aurum -purple logs -f
Pull images from Docker Hub and run using a convention for container and volume scoping based on the network. The containers are detached, so you can terminate the log console session freely. See Docker Compose docs to tailor for your use-case.
mainnet
export NETWORK=mainnet &&\
docker pull tbco/bcc-graphql:5.1.0-beta.1-${NETWORK} &&\
docker pull tbco/bcc-graphql-hasura:5.1.0-beta.1 &&\
docker pull tbco/bcc-node-ogmios:v4.0.0-beta.6-${NETWORK} &&\
docker-compose up -d &&\
docker-compose logs -f
testnet
export NETWORK=testnet &&\
docker pull tbco/bcc-graphql:5.1.0-beta.1-${NETWORK} &&\
docker pull tbco/bcc-graphql-hasura:5.1.0-beta.1 &&\
docker pull tbco/bcc-node-ogmios:v4.0.0-beta.6-${NETWORK} &&\
API_PORT=3101 \
HASURA_PORT=8091 \
OGMIOS_PORT=1338 \
POSTGRES_PORT=5433 \
docker-compose -p ${NETWORK} up -d &&\
docker-compose -p ${NETWORK} logs -f
aurum -purple
export NETWORK=aurum -purple &&\
docker pull tbco/bcc-graphql:5.1.0-beta.1-${NETWORK} &&\
docker pull tbco/bcc-graphql-hasura:5.1.0-beta.1 &&\
docker pull tbco/bcc-node-ogmios:v4.0.0-beta.6-${NETWORK} &&\
API_PORT=3102 \
HASURA_PORT=8092 \
OGMIOS_PORT=1339 \
POSTGRES_PORT=5434 \
docker-compose -p ${NETWORK} up -d &&\
docker-compose -p ${NETWORK} logs -f
The following commands will not remove volumes, however should you wish to do so, append -v
mainnet
docker-compose down
testnet
docker-compose -p testnet down
aurum -purple
docker-compose -p aurum -purple down
Use the GraphQL Playground in the browser at http://localhost:3100/graphql:
{ bccDbMeta { initialized syncPercentage }}
or via command line:
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"query": "{ bccDbMeta { initialized syncPercentage }}"}' \
http://localhost:3100/graphql
ℹ️ Wait for initialized
to be true
to ensure the epoch dataset is complete. After the first sync
you may need to restart the services using docker-compose restart bcc-graphql
if the GraphQL server isn't
running.
{ bcc { tip { number slotNo epoch { number } } } }
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"query": "{ bcc { tip { number slotNo epoch { number } } } }"}' http://localhost:3100/graphql
{ "data": { "bcc": { "tip": { "number": 4391749, "slotNo": 4393973, "epoch": { "number": 203 } } } } }
For more information, have a look at the Wiki 📖.
See Using Docker.
See Building.
Link | Audience |
---|---|
API Documentation | Users of the Bcc GraphQL API |
Wiki 📖 | Anyone interested in the project and our development process |
Example Queries - Bcc DB Hasura | Users of the Bcc DB Hasura API |