Skip to Content
GraphQL-Config

GraphQLProjectConfig

The GraphQLProjectConfig represents projects defined in the GraphQL Config file.

A basic usage:

import { loadConfig } from 'graphql-config' async function main() { const config = await loadConfig({ ... }) // an instance of GraphQLConfig const project = config.getDefault() // an instance of GraphQLProjectConfig }

API

name

type: string

Project’s name.

filepath

type: string

An exact path of a config file.

dirpath

type: string

A path of a directory where GraphQL Config was found.

extensions

type: IExtensions

A raw key-value object representing extensions.

schema

type: SchemaPointer

Value defined in schema property, in the config file.

documents

type: DocumentPointer

Value defined in documents property, in the config file.

include

type: string | string[]

Value defined in include property, in the config file.

exclude

type: string | string[]

Value defined in exclude property, in the config file.

projects

type: { [projectName: string]: GraphQLProjectConfig }

A key-value object where the key is a project’s name but the value contains GraphQLProjectConfig object.

hasExtension()

type: hasExtension(name: string): boolean

Checks if the project contains the extension.

getDefault()

type: getDefault(): GraphQLProjectConfig | never

Returns a default project.

extension()

type: extension<T = any>(name: string): T

Allows accessing extension’s configuration + schema, documents, include and exclude values are also added to the object.

getSchema()

type: getSchema(): Promise<GraphQLSchema>

type: getSchema(out: 'DocumentNode'): Promise<DocumentNode>

type: getSchema(out: 'GraphQLSchema'): Promise<GraphQLSchema>

Allows accessing GraphQLSchema object based on provided information (in schema property of project’s configuration).

getSchemaSync()

type: getSchemaSync(): GraphQLSchema

type: getSchemaSync(out: 'DocumentNode'): DocumentNode

type: getSchemaSync(out: 'GraphQLSchema'): GraphQLSchema

Allows accessing GraphQLSchema object based on provided information (in schema property of project’s configuration).

getDocuments()

type: getDocuments(): Promise<Source[]>

Access Operations and Fragments wrapped with Source class based on provided information (in documents property of project’s configuration).

getDocumentsSync()

type: getDocumentsSync(): Source[]

Access Operations and Fragments wrapped with Source class based on provided information (in documents property of project’s configuration).

match()

type: match(filepath: string): boolean

Checks if the file belongs to the project. It considers schema, documents, include and exclude options to see if the file path matches one of those values.

Last updated on