Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jale29/hasura-gql-client
Typescript based Hasura GQL client for NodeJS/TS/JS apps 🚀
https://github.com/jale29/hasura-gql-client
graphql graphql-api graphql-client graphql-js graphql-schema hasura hasura-graphql hasura-graphql-engine hasura-remote-schema
Last synced: 2 months ago
JSON representation
Typescript based Hasura GQL client for NodeJS/TS/JS apps 🚀
- Host: GitHub
- URL: https://github.com/jale29/hasura-gql-client
- Owner: JaLe29
- License: mit
- Created: 2022-11-09T06:47:40.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-03T21:24:07.000Z (8 months ago)
- Last Synced: 2024-10-11T13:04:17.791Z (2 months ago)
- Topics: graphql, graphql-api, graphql-client, graphql-js, graphql-schema, hasura, hasura-graphql, hasura-graphql-engine, hasura-remote-schema
- Language: TypeScript
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 💀💀💀💀💀 this project is not maintained anymore 💀💀💀💀💀
# hasura-gql-client
Typescript based Hasura GQL client for NodeJS/TS/JS apps.[![npm version](https://badge.fury.io/js/hasura-gql-client.svg)](https://badge.fury.io/js/hasura-gql-client)
- 🚀 Blazing fast GraphQL
- ⚡️ Lightning Fast
- 🔑 Fully Typed APIs
- 🛠️ Rich Features
- 📦 Optimized Build
- 🥴 No Graphql string mess## Installation
```ts
yarn add hasura-gql-client
```
or
```ts
npm i hasura-gql-client
```## Settings
```ts
import Client from 'hasura-gql-client';interface TestBook {
id: string;
name: string;
}interface TestUser {
id: string;
email: string;
books: TestBook[];
book: TestBook;
}interface Select {
test_user: TestUser;
test_book: TestBook;
}// Insert type
interface InsertTestUser {
email: string;
}interface InsertTestBook {
name: string;
}interface Insert {
test_user: InsertTestUser;
test_book: InsertTestBook;
}// Update type
interface UpdateTestUser {
email?: string;
}interface UpdateTestBook {
name: string;
}interface Update {
test_user: UpdateTestUser;
test_book: UpdateTestBook;
}const client = new Client({
host: process.env.HOST ?? 'err',
customHeaders: { 'x-hasura-admin-secret': process.env.X_HASURA_ADMIN_SECRET ?? 'err' },
debug: true,
});const start = async (): Promise => {
// select
const usersSelect2 = await client.select('test_user', ['id', 'book.name', 'books.id']);
console.log(usersSelect2[0]?.id);
console.log(usersSelect2[0]?.books[0].id);
console.log(usersSelect2[0]?.book.name);// insert
const usersInsert = await client.insert('test_user', { email: '[email protected]', name: 'foo' }, ['id']);
console.log(usersInsert[0].id);// update
const usersUpdate = await client.update('test_user', { email: '[email protected]' }, ['id']);
console.log(usersUpdate[0].id);
};start().catch(console.error);
```
See [example folder](https://github.com/JaLe29/hasura-gql-client/tree/master/example) for more details.