
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@settlemint/sdk-hasura
Advanced tools
Hasura and PostgreSQL integration module for SettleMint SDK, enabling database operations and GraphQL queries
✨ https://settlemint.com ✨
Integrate SettleMint into your application with ease.
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.
createHasuraClient<
Setup
>(options
,clientOptions?
,logger?
):object
Defined in: sdk/hasura/src/hasura.ts:82
Creates a Hasura GraphQL client with proper type safety using gql.tada
Type Parameter |
---|
Setup extends AbstractSetupSchema |
Parameter | Type | Description |
---|---|---|
options | { accessToken? : string ; adminSecret : string ; cache? : "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" ; instance : string ; } | Configuration options for the client |
options.accessToken? | string | - |
options.adminSecret? | string | - |
options.cache? | "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | - |
options.instance? | string | - |
clientOptions? | RequestConfig | Optional GraphQL client configuration options |
logger? | Logger | Optional logger to use for logging the requests |
object
An object containing: - client: The configured GraphQL client instance - graphql: The initialized gql.tada function for type-safe queries
Name | Type | Defined in |
---|---|---|
client | GraphQLClient | sdk/hasura/src/hasura.ts:87 |
graphql | initGraphQLTada <Setup > | sdk/hasura/src/hasura.ts:88 |
Will throw an error if the options fail validation against ClientOptionsSchema
import { createHasuraClient } from '@settlemint/sdk-hasura';
import type { introspection } from "@schemas/hasura-env";
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
const logger = createLogger();
const { client, graphql } = createHasuraClient<{
introspection: introspection;
disableMasking: true;
scalars: {
timestamp: string;
timestampz: string;
uuid: string;
date: string;
time: string;
jsonb: string;
numeric: string;
interval: string;
geometry: string;
geography: string;
};
}>({
instance: process.env.SETTLEMINT_HASURA_ENDPOINT,
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET,
}, {
fetch: requestLogger(logger, "hasura", fetch) as typeof fetch,
});
// Making GraphQL queries
const query = graphql(`
query GetUsers {
users {
id
name
email
}
}
`);
const result = await client.request(query);
createPostgresPool(
databaseUrl
):Pool
Defined in: sdk/hasura/src/postgres.ts:107
Creates a PostgreSQL connection pool with error handling and retry mechanisms
Parameter | Type | Description |
---|---|---|
databaseUrl | string | The PostgreSQL connection URL |
Pool
A configured PostgreSQL connection pool
Will throw an error if called from browser runtime
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();
}
ClientOptions =
z.infer
<typeofClientOptionsSchema
>
Defined in: sdk/hasura/src/hasura.ts:27
Type definition for client options derived from the ClientOptionsSchema.
RequestConfig =
ConstructorParameters
<typeofGraphQLClient
>[1
]
Defined in: sdk/hasura/src/hasura.ts:12
Type definition for GraphQL client configuration options
const
ClientOptionsSchema:ZodObject
<{accessToken
:ZodOptional
<ZodString
>;adminSecret
:ZodString
;cache
:ZodOptional
<ZodEnum
<{default
:"default"
;force-cache
:"force-cache"
;no-cache
:"no-cache"
;no-store
:"no-store"
;only-if-cached
:"only-if-cached"
;reload
:"reload"
; }>>;instance
:ZodUnion
<readonly [ZodString
,ZodString
]>; },$strip
>
Defined in: sdk/hasura/src/hasura.ts:17
Schema for validating client options for the Hasura client.
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.
The SettleMint SDK is released under the FSL Software License. See the LICENSE file for more details.
FAQs
Hasura and PostgreSQL integration module for SettleMint SDK, enabling database operations and GraphQL queries
The npm package @settlemint/sdk-hasura receives a total of 9,279 weekly downloads. As such, @settlemint/sdk-hasura popularity was classified as popular.
We found that @settlemint/sdk-hasura demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.