Loading Config#
loadConfig#
This function is the starting point for using GraphQL Config. It looks for a config file in predefined search places in the currently working directory.
A basic usage example (async):
import { loadConfig } from 'graphql-config'
async function main() {
const config = await loadConfig({ ... }) // an instance of GraphQLConfig
}
Synchronous version:
import { loadConfigSync } from 'graphql-config'
function main() {
const config = loadConfigSync({ ... }) // an instance of GraphQLConfig
}
Options#
filepath
#
type: string
An exact path of a config file.
rootDir
#
type: string
A path of a directory where GraphQL Config should look for a file (uses process.cwd() by default).
configName
#
type: string
A name of the config file. It's graphql
by default. Using relay
as a config name instructs GraphQL Config to look for all the variations of possible config file names where one of them is relay.config.js
.
extensions
#
type: GraphQLExtensionDeclaration[]
An array of GraphQLExtensionDeclaration
objects, place to register extensions.
throwOnMissing
#
type: boolean
GraphQL Config throws an error where there's no config file by default.
throwOnEmpty
#
type: boolean
GraphQL Config by default throws an error if there's a config file but the file is empty.