JSPM

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

Package Exports

  • hasura-gql-client
  • hasura-gql-client/dist/esm/index.js

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 (hasura-gql-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hasura-gql-client

npm version

WIP: Repository is under have development right now :-)

Typescript based Hasura GQL client.

  • 🚀 Blazing fast GraphQL
  • ⚡️ Lightning Fast
  • 🔑 Fully Typed APIs
  • 🛠️ Rich Features
  • 📦 Optimized Build
  • 🥴 No Graphql string mess

Installation

yarn add hasura-gql-client

or

npm i hasura-gql-client

Settings

import Client from 'hasura-gql-client';

interface TestUser {
    id: string;
    email: string;
    name: string;
}

interface Select {
    test_user: TestUser;
}

// Insert type
interface InsertTestUser {
    email: string;
    name: string;
}

interface Insert {
    test_user: InsertTestUser;
}

// Update type
interface UpdateTestUser {
    email?: string;
    name?: string;
}

interface Update {
    test_user: UpdateTestUser;
}

const client = new Client<Select, Insert, Update>({
    host: process.env.HOST ?? 'err',
    customHeaders: { 'x-hasura-admin-secret': process.env.X_HASURA_ADMIN_SECRET ?? 'err' },
    debug: true,
});

const start = async (): Promise<void> => {
    // select users
    const usersSelect = await client.select('test_user', ['id']);
    console.log(usersSelect[0]?.id);

    // insert
    const usersInsert = await client.insert('test_user', { email: 'foo@email.com', name: 'foo' }, ['id']);
    console.log(usersInsert[0].id);

    // update
    const usersUpdate = await client.update('test_user', { email: 'foo2@email.com' }, ['id']);
    console.log(usersUpdate[0].id);
};

See example folder for more details.