graphql-tools-monorepo / loaders/json-file/src / JsonFileLoader

Class: JsonFileLoader

loaders/json-file/src.JsonFileLoader

This loader loads documents and type definitions from JSON files.

The JSON file can be the result of an introspection query made against a schema:

const schema = await loadSchema('schema-introspection.json', {
  loaders: [
    new JsonFileLoader()
  ]
});

Or it can be a DocumentNode object representing a GraphQL document or type definitions:

const documents = await loadDocuments('queries/*.json', {
  loaders: [
    new GraphQLFileLoader()
  ]
});

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new JsonFileLoader(): JsonFileLoader

Returns

JsonFileLoader

Methods

canLoad

canLoad(pointer, options): Promise<boolean>

Parameters

NameType
pointerstring
optionsJsonFileLoaderOptions

Returns

Promise<boolean>

Defined in

packages/loaders/json-file/src/index.ts:55


canLoadSync

canLoadSync(pointer, options): boolean

Parameters

NameType
pointerstring
optionsJsonFileLoaderOptions

Returns

boolean

Defined in

packages/loaders/json-file/src/index.ts:73


handleFileContent

handleFileContent(normalizedFilePath, rawSDL, options): Source

Parameters

NameType
normalizedFilePathstring
rawSDLstring
optionsJsonFileLoaderOptions

Returns

Source

Defined in

packages/loaders/json-file/src/index.ts:175


load

load(pointer, options): Promise<Source[]>

Parameters

NameType
pointerstring
optionsJsonFileLoaderOptions

Returns

Promise<Source[]>

Implementation of

Loader.load

Defined in

packages/loaders/json-file/src/index.ts:103


loadSync

loadSync(pointer, options): Source[]

Parameters

NameType
pointerstring
optionsJsonFileLoaderOptions

Returns

Source[]

Implementation of

Loader.loadSync

Defined in

packages/loaders/json-file/src/index.ts:140


resolveGlobs

resolveGlobs(glob, options): Promise<string[]>

Parameters

NameType
globstring
optionsJsonFileLoaderOptions

Returns

Promise<string[]>

Defined in

packages/loaders/json-file/src/index.ts:91


resolveGlobsSync

resolveGlobsSync(glob, options): string[]

Parameters

NameType
globstring
optionsJsonFileLoaderOptions

Returns

string[]

Defined in

packages/loaders/json-file/src/index.ts:97