Skip to main content

API Reference

This page provides detailed information about the GQLPT Client SDK API.

GQLPTClient

The main class for interacting with GQLPT.

Constructor

constructor(options: GQLPTClientOptions)

Options

  • typeDefs: string (optional) - GraphQL schema as a string
  • url: string (optional) - URL of a GraphQL endpoint
  • schema: GraphQLSchema (optional) - A GraphQL schema object
  • headers: Record string (optional) - Headers to send with GraphQL requests
  • adapter: Adapter - An instance of an AI adapter (e.g., AdapterOpenAI, AdapterAnthropic)

Methods

connect()

async connect(): Promise<void>

Connects to the GraphQL server and introspects the schema if a URL is provided.

generateQueryAndVariables(plainText: string)

async generateQueryAndVariables(plainText: string): Promise<{
query: string;
variables?: Record<string, unknown>;
}>

Generates a GraphQL query and variables from a plain text description.

generateAndSend(plainText: string, options?)

async generateAndSend<Q extends string>(
plainText: Q,
options?: {
urlOverride?: string;
headersOverride?: Record<string, string>;
}
): Promise<Q extends keyof T ? T[Q] : any>

Generates a GraphQL query from plain text and sends it to the GraphQL server.