Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@settlemint/sdk-hasura

Package Overview
Dependencies
Maintainers
0
Versions
1671
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@settlemint/sdk-hasura

Hasura and PostgreSQL integration module for SettleMint SDK, enabling database operations and GraphQL queries

  • 1.0.8-main543d1195
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by9.78%
Maintainers
0
Weekly downloads
 
Created
Source

SettleMint logo

SettleMint SDK

https://settlemint.com
Integrate SettleMint into your application with ease.

CI status License npm stars

Documentation   •   NPM   •   Issues

Table of Contents

About

The SettleMint Hasura SDK provides a seamless way to interact with Hasura GraphQL APIs for managing application data. It enables you to easily query and mutate data stored in your SettleMint-powered PostgreSQL databases through a type-safe GraphQL interface.

For detailed information about using Hasura with the SettleMint platform, check out our official documentation.

API Reference

Functions

createHasuraClient()

createHasuraClient<Setup>(options, clientOptions?): object

Defined in: sdk/hasura/src/hasura.ts:111

Creates a Hasura GraphQL client with proper type safety using gql.tada

Type Parameters
Type Parameter
Setup extends AbstractSetupSchema
Parameters
ParameterTypeDescription
optionsOmit<{ accessToken: string; adminSecret: string; instance: string; runtime: "server"; } | { runtime: "browser"; }, "runtime"> & Record<string, unknown>Configuration options for the client: - For server-side: instance URL, access token and admin secret - For browser-side: no additional configuration needed
clientOptions?RequestConfigOptional GraphQL client configuration options
Returns

object

An object containing: - client: The configured GraphQL client instance - graphql: The initialized gql.tada function for type-safe queries

NameTypeDefined in
clientGraphQLClientsdk/hasura/src/hasura.ts:115
graphqlinitGraphQLTada<Setup>sdk/hasura/src/hasura.ts:116
Throws

Will throw an error if the options fail validation against ClientOptionsSchema

Example
import { createHasuraClient } from '@settlemint/sdk-hasura';
import type { introspection } from "@schemas/hasura-env";

// Server-side usage
const { client, graphql } = createHasuraClient<{
  introspection: introspection;
  disableMasking: true;
  scalars: {
    DateTime: Date;
    JSON: Record<string, unknown>;
    Bytes: string;
    Int8: string;
    BigInt: string;
    BigDecimal: string;
    Timestamp: string;
  };
}>({
  instance: process.env.SETTLEMINT_HASURA_ENDPOINT,
  accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
  adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,
});

// Browser-side usage
const { client, graphql } = createHasuraClient<{
  introspection: introspection;
  disableMasking: true;
  scalars: {
    DateTime: Date;
    JSON: Record<string, unknown>;
    Bytes: string;
    Int8: string;
    BigInt: string;
    BigDecimal: string;
    Timestamp: string;
  };
}>({});

// Making GraphQL queries
const query = graphql(`
  query GetUsers {
    users {
      id
      name
      email
    }
  }
`);

const result = await client.request(query);

createPostgresPool()

createPostgresPool(databaseUrl): Pool

Defined in: sdk/hasura/src/postgres.ts:83

Creates a PostgreSQL connection pool with error handling and retry mechanisms

Parameters
ParameterTypeDescription
databaseUrlstringThe PostgreSQL connection URL
Returns

Pool

A configured PostgreSQL connection pool

Throws

Will throw an error if called from browser runtime

Example
import { createPostgresPool } from '@settlemint/sdk-hasura';

const pool = createPostgresPool(process.env.SETTLEMINT_HASURA_DATABASE_URL);

// The pool will automatically handle connection errors and retries
const client = await pool.connect();
try {
  const result = await client.query('SELECT NOW()');
  console.log(result.rows[0]);
} finally {
  client.release();
}

Type Aliases

ClientOptions

ClientOptions: { accessToken: string; adminSecret: string; instance: string; runtime: "server"; } | { runtime: "browser"; }

Defined in: sdk/hasura/src/hasura.ts:33

Type definition for client options derived from the ClientOptionsSchema.


RequestConfig

RequestConfig: ConstructorParameters<typeof GraphQLClient>[1]

Defined in: sdk/hasura/src/hasura.ts:10

Type definition for GraphQL client configuration options

Variables

ClientOptionsSchema

const ClientOptionsSchema: ZodDiscriminatedUnion<ClientOptions>

Defined in: sdk/hasura/src/hasura.ts:18

Schema for validating client options for the Hasura client. Defines two possible runtime configurations:

  1. Server-side with instance URL, access token and admin secret
  2. Browser-side with no additional configuration needed

Contributing

We welcome contributions from the community! Please check out our Contributing guide to learn how you can help improve the SettleMint SDK through bug reports, feature requests, documentation updates, or code contributions.

License

The SettleMint SDK is released under the FSL Software License. See the LICENSE file for more details.

Keywords

FAQs

Package last updated on 20 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc