JSPM

@sean-11x/hasura-sdk

1.5.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q35911F
  • License MIT

Hasura Schema/Metadata API SDK. Written in TypeScript!

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sean-11x/hasura-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Hasura SDK

    Hasura Schema and Metadata Node SDK

    npm version license: MIT code style: prettier


    Hasura Schema/Metadata API SDK. Written in TypeScript!

    • ✅ 100% in TypeScript
    • 🏋️ Uses Axios under the hood

    Installation

    yarn

    • yarn add @sean-11x/hasura-sdk

    npm

    • npm install @sean-11x/hasura-sdk

    Usage

    import Hasura from '@sean-11x/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!

    API Support
    Run SQL Yes
    Tables/Views Yes
    Custom SQL Functions No
    Relationships No
    Computed Fields No
    Permissions No
    Event Triggers Yes
    Scheduled Triggers Yes
    Remote Schemas No
    Query Collections No
    Custom Types No
    Actions No
    Manage Metadata No

    Give us a star!

    Every star helps build a little more