Home

Awesome

<h1 align="center">Hasura SDK</h1> <h2 align="center">Hasura Schema and Metadata Node SDK</h2> <p align="center"> <a href="https://badge.fury.io/js/%40aaronhayes%2Fhasura-sdk"><img src="https://badge.fury.io/js/%40aaronhayes%2Fhasura-sdk.svg" alt="npm version" height="18"></a> <a href="LICENSE"> <img src="https://img.shields.io/badge/license-MIT-yellow.svg" alt="license: MIT" /> </a> <a href="https://prettier.io"> <img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg" alt="code style: prettier" /> </a> <a href="https://github.com/aaronhayes/hasura-sdk/actions"> <img src="https://github.com/aaronhayes/hasura-sdk/workflows/Tests/badge.svg?branch=master"/> </a> <a href="https://codecov.io/gh/aaronhayes/hasura-sdk"> <img src="https://codecov.io/gh/aaronhayes/hasura-sdk/branch/master/graph/badge.svg" /> </a> <a href="https://codeclimate.com/github/aaronhayes/hasura-sdk/maintainability"><img src="https://api.codeclimate.com/v1/badges/02998e4b9a8f31ab2f6d/maintainability" /></a> </p>

Hasura Schema/Metadata API SDK. Written in TypeScript!

Installation

yarn

npm

Usage

import Hasura from '@aaronhayes/hasura-sdk`;

// Note: just the base url - don't add /v1/graphql!
const HASURA_GRAPHQL_ENDPOINT = 'http://localhost:8080';

// Hint: use process.env.HASURA_GRAPHQL_ADMIN_SECRET
const HASURA_GRAPHQL_ADMIN_SECRET = 'yousecret';

const hasura = new Hasura({
    endpoint: HASURA_GRAPHQL_ENDPOINT,
    adminSecret: HASURA_GRAPHQL_ADMIN_SECRET
});

// Using Async/Await Functions
try {
    const resp = await hasura.createCronTrigger({
        name: 'newcronjob',
        schedule: '* * * * *', // every minute
        webhook: '{{EVENT_BASE_URL}}/cron',
        payload: {
            hello: "world"
        },
        comment: 'test cron job every minute'
    });
} catch (error) {
    // handle error
}

// Using Promises
hasura.createCronTrigger({
    name: 'newcronjob',
    schedule: '* * * * *',
    webhook: '{{EVENT_BASE_URL}}/cron',
    payload: {
        hello: "world"
    },
    comment: 'test cron job every minute'
}).then(data => {
    // axios response
}).catch(error => {
    // handle error
});

Schema/Metadata API References

Supported APIs

We currently only support a small range of Hasura APIs. Be assured we working on adding more - if you need something be sure to create an issue!

APISupport
<b>Run SQL</b><b>Yes</b>
<b>Tables/Views</b><b>Yes</b>
Custom SQL FunctionsNo
RelationshipsNo
Computed FieldsNo
PermissionsNo
<b>Event Triggers</b><b>Yes</b>
<b>Scheduled Triggers</b><b>Yes</b>
Remote SchemasNo
Query CollectionsNo
Custom TypesNo
ActionsNo
Manage MetadataNo

Give us a star!

Every star helps build a little more