Skip to main content

API Reference

This page provides a detailed reference for all available options and commands in the GQLPT CLI.

Command Structure

The basic structure of a GQLPT CLI command is:

npx @gqlpt/cli generate <source> [options]

Arguments

ArgumentDescription
<source>Source directory to scan for GQLPT usage

Options

OptionAliasDescriptionDefault
--adapter-aThe type of adapter to use ('openai' or 'anthropic')'openai'
--key-kAPI key for the chosen adapter-
--output-oCustom output path for generated typesnode_modules/gqlpt/build/types.d.ts
--typeDefs-tPath to GraphQL schema definition file-
--url-uGraphQL server URL for schema introspection-
--headers-hHeaders to send to the GraphQL server (as JSON string)-
--raw-rOutput raw type definitions to stdout instead of writing to a filefalse
--help-Display help for command-
--generated-gOutput path for generated queriesnode_modules/gqlpt/build/generated.json
--rawgen-rgOutput raw generated queries to stdoutfalse

Environment Variables

The following environment variables can be used to set default values for the CLI options:

Environment VariableCorresponding OptionDescription
GQLPT_ADAPTER--adapterThe type of adapter to use
OPENAI_API_KEY--keyAPI key for OpenAI adapter
ANTHROPIC_API_KEY--keyAPI key for Anthropic adapter
GQLPT_OUTPUT_PATH--outputCustom output path for generated types
GQLPT_TYPE_DEFS--typeDefsPath to GraphQL schema definition file
GQLPT_URL--urlGraphQL server URL for schema introspection
GQLPT_HEADERS--headersHeaders to send to the GraphQL server
GQLPT_RAW--rawEnable raw output mode
GQLPT_GENERATED_PATH--generatedOutput path for generated queries
GQLPT_RAW_GENERATED--rawgenEnable raw generated queries output mode

Option Details

--adapter <adapter>

Specifies the AI adapter to use for generating type definitions. Available options are 'openai' and 'anthropic'.

--key <key>

The API key for the chosen adapter. This should be your OpenAI API key or Anthropic API key, depending on the selected adapter.

--output <path>

Specifies a custom output path for the generated TypeScript type definitions. If not provided, the default is `no

--generated <path>

Specifies a custom output path for the generated GraphQL queries. If not provided, the default is node_modules/gqlpt/build/generated.json.

--rawgen

When set, outputs the raw generated GraphQL queries to stdout instead of writing to a file. This is useful for debugging or integrating with other tools.