Config file reference

CLI reference

The CLI for the GraphQL SDK Generator only requires one parameter: the path to the configuration file. All other configurations are defined within the file passed to the CLI.

graphql-sdk-generator -c config.json 

File Config

The following are the available options that can be included in the config.json file:

{
  "url": "https://your-end-point",
  "sdkName": "custom-sdk-name",
  "fileType": "ts",
  "debug": true, 
  "baseDirectory": "custom-directory-path-name",
  "directoryName": "custom-name",
  "depth": 2,
  "toGenerateSchemaFile": false,
  "headers": {
    "x-api-key": "api-key",
    ...more headers
  }
  
}

Each option allows for customization, making the generated SDK more tailored to your needs. Simply adjust the values in the config.json file to fit your project.

NameTypeDefaultDescription

url

string

-

The GraphQL endpoint URL from which the schema will be fetched. This option is required.

sdkName

string

-

Custom name for the SDK folder where the generated code will be stored. This option is required.

fileType

string

-

The file type for the generated SDK. Options are 'ts' for TypeScript or 'js' for JavaScript. This option is required.

debug

boolean

false

Enables debugging, providing detailed logs for each step of the generation process.

baseDirectory

string

./

Specifies the base path where the SDK files and folders will be generated.

directoryName

string

graphqlSDKGenerator

Custom name for the directory where the SDK files will be generated.

depth

integer

2

Defines the depth level for generating nested GraphQL documents.

toGenerateSchemaFile

boolean

false

Determines whether to retain .graphql files. These are not needed by the generated code.

headers

object

{}

Custom headers to be included when fetching the schema from the GraphQL endpoint.

Last updated