0.0.33 • Published 3 years ago

@deepcase/hasura v0.0.33

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

deepcase hasura

npm version example develop deepcase

api

import { HasuraApi } from '@deepcase/hasura/api';

const api = new HasuraApi({
  path: 'hasura.domain.com',
  ssl: true,
  secret: 'adminsecretkey'
});

sql template literal for ide highlighting

import { sql } from '@deepcase/hasura/sql';

await api.sql(sqlSELECT * FROM mytable);

[hasura api reference](https://hasura.io/docs/1.0/graphql/core/api-reference/schema-metadata-api/index.html)
```ts
await api.query({
  type: 'track_table',
  args: {
    schema: 'public',
    name: 'mytable',
  }
});

client

import { generateApolloClient } from '@deepcase/hasura/client';
import gql from 'graphql-tag';
const client = generateApolloClient({ // all options are optional
  ws: true, // need to socket for subscriptions // recommended
  secret: 'adminSecretForRoot', // admin secret for root access // not need when token exists
  token: 'tokenFromCookiesOrLocalStorage', // token for auth webhook auth // ignored when secret exists
  ssl: true; // auto http/https ws/wss protocol
  path: 'hasura.domain.com/path', // link to hasura location
  headers: {}, // custom additional fields into headers
  initialStore: {},
  relative: false, // optional
});
client.query({ query: gql`{ links { id }}` }).then(result => console.log(result))

If you need to specify an absolute path as protocol://domain.zone/path to hasura, you must pass these two options: path and ssl

const client = generateApolloClient({ // all options are optional
  ssl: true;
  path: 'hasura.domain.com/path',
});

If you need to specify relative path as /path to hasura, you must enable the relative mode with the relative option. In this case, the ssl option is ignored in http client, but used in ws. This can be useful when your build is with some proxy.

const client = generateApolloClient({ // all options are optional
  relative: true,
  path: 'hasura.domain.com/path',
});

You can also specify relative not locally in your code, but using an ENV variable DEEP_FOUNDATION_HASURA_RELATIVE or NEXT_PUBLIC_DEEP_FOUNDATION_HASURA_RELATIVE.

export DEEP_FOUNDATION_HASURA_RELATIVE = 1;

OR

export NEXT_PUBLIC_DEEP_FOUNDATION_HASURA_RELATIVE = 1;
0.0.31

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.20

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago