@aaronhayes/hasura-sdk 中文文档教程

发布于 4年前 浏览 22 项目主页 更新于 3年前

Hasura SDK

Hasura Schema and Metadata Node SDK

npm versionlicense: MIT 代码风格:更漂亮


Hasura 架构/元数据 API SDK。 用打字稿写的!

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

Installation

yarn

  • yarn add @aaronhayes/hasura-sdk

npm

  • npm install @aaronhayes/hasura-sdk

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

我们目前仅支持一小部分 Hasura API。 请放心,我们正在努力添加更多 - 如果您需要某些东西,请务必创建一个问题!

APISupport
Run SQLYes
Tables/ViewsYes
Custom SQL FunctionsNo
RelationshipsNo
Computed FieldsNo
PermissionsNo
Event TriggersYes
Scheduled TriggersYes
Remote SchemasNo
Query CollectionsNo
Custom TypesNo
ActionsNo
Manage MetadataNo

Give us a star!

每一颗星星都有助于建立更多

Hasura SDK

Hasura Schema and Metadata Node SDK

npm versionlicense: MIT code style: prettier


Hasura Schema/Metadata API SDK. Written in TypeScript!

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

Installation

yarn

  • yarn add @aaronhayes/hasura-sdk

npm

  • npm install @aaronhayes/hasura-sdk

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
Run SQLYes
Tables/ViewsYes
Custom SQL FunctionsNo
RelationshipsNo
Computed FieldsNo
PermissionsNo
Event TriggersYes
Scheduled TriggersYes
Remote SchemasNo
Query CollectionsNo
Custom TypesNo
ActionsNo
Manage MetadataNo

Give us a star!

Every star helps build a little more

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文