Coder Social home page Coder Social logo

aussiegingersnap / cardano-graphql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cardano-foundation/cardano-graphql

0.0 0.0 0.0 95.74 MB

GraphQL API for Cardano

License: Apache License 2.0

Dockerfile 1.37% JavaScript 1.05% TypeScript 47.24% Shell 1.15% Nix 46.74% PLpgSQL 2.44%

cardano-graphql's Introduction

Cardano GraphQL

CI


Overview

Cross-platform, typed, and queryable API for Cardano. The project contains multiple packages for composing GraphQL services to meet specific application demands, and a docker-compose stack serving the included cardano-graphql-server Dockerfile, the extended hasura Dockerfile, cardano-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 @cardano-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 cardano-node. It offers a JSON interface through WebSockets and enables applications to speak Ouroboros' client mini-protocols via remote procedure calls.

Getting Started

Check the releases for the latest version.

git clone \
  --single-branch \
  --branch 6.2.0 \
  --recurse-submodules \
  https://github.com/input-output-hk/cardano-graphql.git \
  && cd cardano-graphql

Up

Choose one of the following:

A) Build and Run via Docker Compose

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

Get the most recent weekly snapshot link here, and set it as RESTORE_SNAPSHOT below, or omit if you wish to sync from genesis.

DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/12/db-sync-snapshot-schema-12-block-6764999-x86_64.tgz \
docker-compose up -d --build &&\
docker-compose logs -f
testnet

Get the most recent weekly snapshot link here, and set it as RESTORE_SNAPSHOT below, or omit if you wish to sync from genesis.

DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
NETWORK=testnet \
RESTORE_SNAPSHOT=https://updates-cardano-testnet.s3.amazonaws.com/cardano-db-sync/12/db-sync-snapshot-schema-12-block-3185999-x86_64.tgz \
API_PORT=3101 \
HASURA_PORT=8091 \
OGMIOS_PORT=1338 \
POSTGRES_PORT=5433 \
METADATA_SERVER_URI="https://metadata.cardano-testnet.iohkdev.io" \
docker-compose -p testnet up -d --build &&\
docker-compose -p testnet logs -f

B) Pull and Run via Docker Compose

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

Get the most recent weekly snapshot link here, and set it as RESTORE_SNAPSHOT below, or omit if you wish to sync from genesis.

export NETWORK=mainnet &&\
docker pull inputoutput/cardano-graphql:6.2.0-${NETWORK} &&\
docker pull inputoutput/cardano-graphql-hasura:6.2.0 &&\
docker pull cardanosolutions/cardano-node-ogmios:v5.1.0-${NETWORK} &&\
RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/12/db-sync-snapshot-schema-12-block-6764999-x86_64.tgz \
docker-compose up -d &&\
docker-compose logs -f
testnet

Get the most recent weekly snapshot link here, and set it as RESTORE_SNAPSHOT below, or omit if you wish to sync from genesis.

export NETWORK=testnet &&\
docker pull inputoutput/cardano-graphql:6.2.0-${NETWORK} &&\
docker pull inputoutput/cardano-graphql-hasura:6.2.0 &&\
docker pull cardanosolutions/cardano-node-ogmios:v5.1.0-${NETWORK} &&\
RESTORE_SNAPSHOT=https://updates-cardano-testnet.s3.amazonaws.com/cardano-db-sync/12/db-sync-snapshot-schema-12-block-3185999-x86_64.tgz \
API_PORT=3101 \
HASURA_PORT=8091 \
OGMIOS_PORT=1338 \
POSTGRES_PORT=5433 \
docker-compose -p ${NETWORK} up -d &&\
docker-compose -p ${NETWORK} logs -f

Down

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

Check Cardano DB sync progress

Use the GraphQL Playground in the browser at http://localhost:3100/graphql:

{ cardanoDbMeta { initialized syncPercentage }}

or via command line:

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "{ cardanoDbMeta { 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 cardano-graphql if the GraphQL server isn't running.

Query the full dataset

{ cardano { tip { number slotNo epoch { number } } } }
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "{ cardano { tip { number slotNo epoch { number } } } }"}' http://localhost:3100/graphql

๐ŸŽ‰

{ "data": { "cardano": { "tip": { "number": 4391749, "slotNo": 4393973, "epoch": { "number": 203 } } } } }

For more information, have a look at the Wiki ๐Ÿ“–.

How to install (Linux / Docker)

Docker

See Using Docker.

From Source

See Building.

Documentation

Link Audience
API Documentation Users of the Cardano GraphQL API
Wiki ๐Ÿ“– Anyone interested in the project and our development process
Example Queries - Cardano DB Hasura Users of the Cardano DB Hasura API

cardano-graphql's People

Contributors

adascanbovich avatar alexey1935 avatar arturwieczorek avatar cherrydt avatar craigem avatar dependabot[bot] avatar disassembler avatar islishude avatar jbgi avatar ktorz avatar lgobbi-atix avatar manveru avatar mebassett avatar mmahut avatar oneedoubled avatar rcmorano avatar rhyslbw avatar sam-jeston avatar sweeetland avatar tatyanavych avatar toaspzoo avatar trevorbenson 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.