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

@settlemint/sdk-thegraph

Package Overview
Dependencies
Maintainers
0
Versions
1634
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@settlemint/sdk-thegraph

TheGraph integration module for SettleMint SDK, enabling querying and indexing of blockchain data through subgraphs

  • 1.0.8-pr76314f00
  • pr
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
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 TheGraph SDK provides a seamless way to interact with TheGraph APIs for blockchain data indexing and querying. It enables you to easily create and manage subgraphs, define schemas, and query indexed blockchain data using GraphQL from your SettleMint-powered blockchain networks.

The SDK offers a type-safe interface for all TheGraph operations, with comprehensive error handling and validation. It integrates smoothly with modern TypeScript applications while providing a simple and intuitive developer experience.

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

API Reference

Functions

createTheGraphClient()

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

Defined in: sdk/thegraph/src/thegraph.ts:121

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

Type Parameters
Type Parameter
Setup extends AbstractSetupSchema
Parameters
ParameterTypeDescription
optionsOmit<{ accessToken: string; instances: string[]; runtime: "server"; subgraphName: string; } | { runtime: "browser"; subgraphName: string; }, "runtime"> & Record<string, unknown>Configuration options for the client: - For server-side: instance URLs, access token and subgraph name - For browser-side: just subgraph name
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/thegraph/src/thegraph.ts:125
graphqlinitGraphQLTada<Setup>sdk/thegraph/src/thegraph.ts:126
Throws

Will throw an error if the options fail validation against ClientOptionsSchema

Example
import { createTheGraphClient } from '@settlemint/sdk-thegraph';
import type { introspection } from '@schemas/the-graph-env-starterkits';

// Server-side usage
const { client, graphql } = createTheGraphClient<{
  introspection: introspection;
  disableMasking: true;
  scalars: {
    DateTime: Date;
    JSON: Record<string, unknown>;
    Bytes: string;
    Int8: string;
    BigInt: string;
    BigDecimal: string;
    Timestamp: string;
  };
}>({
  instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),
  accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
  subgraphName: 'starterkits'
});

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

// Making GraphQL queries
const query = graphql(`
  query SearchAssets {
    assets {
      id
      name
      symbol
    }
  }
`);

const result = await client.request(query);

Type Aliases

ClientOptions

ClientOptions: { accessToken: string; instances: string[]; runtime: "server"; subgraphName: string; } | { runtime: "browser"; subgraphName: string; }

Defined in: sdk/thegraph/src/thegraph.ts:34

Type definition for client options derived from the ClientOptionsSchema


RequestConfig

RequestConfig: ConstructorParameters<typeof GraphQLClient>[1]

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

Type definition for GraphQL client configuration options

Variables

ClientOptionsSchema

const ClientOptionsSchema: ZodDiscriminatedUnion<ClientOptions>

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

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

  1. Server-side with instance URLs, access token and subgraph name
  2. Browser-side with just subgraph name

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 18 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