@graphql-tools/graphql-file-loader
Advanced tools
Comparing version 6.0.7-alpha-258b8cb.0 to 6.0.7-alpha-3f2c64a.0
@@ -24,3 +24,3 @@ 'use strict'; | ||
const normalizedFilePath = path.isAbsolute(pointer) ? pointer : path.resolve(options.cwd, pointer); | ||
return new Promise(resolve => fsExtra.exists(normalizedFilePath, resolve)); | ||
return fsExtra.pathExists(normalizedFilePath); | ||
} | ||
@@ -34,3 +34,3 @@ } | ||
const normalizedFilePath = path.isAbsolute(pointer) ? pointer : path.resolve(options.cwd, pointer); | ||
return fsExtra.existsSync(normalizedFilePath); | ||
return fsExtra.pathExistsSync(normalizedFilePath); | ||
} | ||
@@ -43,9 +43,3 @@ } | ||
const rawSDL = await fsExtra.readFile(normalizedFilePath, { encoding: 'utf8' }); | ||
if (isGraphQLImportFile(rawSDL)) { | ||
return { | ||
location: pointer, | ||
document: _import.processImport(pointer, options.cwd), | ||
}; | ||
} | ||
return utils.parseGraphQLSDL(pointer, rawSDL.trim(), options); | ||
return this.handleFileContent(rawSDL, pointer, options); | ||
} | ||
@@ -56,3 +50,6 @@ loadSync(pointer, options) { | ||
const rawSDL = fsExtra.readFileSync(normalizedFilePath, { encoding: 'utf8' }); | ||
if (isGraphQLImportFile(rawSDL)) { | ||
return this.handleFileContent(rawSDL, pointer, options); | ||
} | ||
handleFileContent(rawSDL, pointer, options) { | ||
if (!options.skipGraphQLImport && isGraphQLImportFile(rawSDL)) { | ||
return { | ||
@@ -59,0 +56,0 @@ location: pointer, |
import { Source, UniversalLoader, DocumentPointerSingle, SchemaPointerSingle, SingleFileOptions } from '@graphql-tools/utils'; | ||
export interface GraphQLFileLoaderOptions extends SingleFileOptions { | ||
skipGraphQLImport?: boolean; | ||
} | ||
@@ -10,2 +11,10 @@ export declare class GraphQLFileLoader implements UniversalLoader<GraphQLFileLoaderOptions> { | ||
loadSync(pointer: SchemaPointerSingle | DocumentPointerSingle, options: GraphQLFileLoaderOptions): Source; | ||
handleFileContent(rawSDL: string, pointer: string, options: GraphQLFileLoaderOptions): { | ||
location: string; | ||
document: import("graphql").DocumentNode; | ||
rawSDL: string; | ||
} | { | ||
location: string; | ||
document: import("graphql").DocumentNode; | ||
}; | ||
} |
import { isValidPath, parseGraphQLSDL } from '@graphql-tools/utils'; | ||
import { isAbsolute, resolve } from 'path'; | ||
import { exists, existsSync, readFile, readFileSync } from 'fs-extra'; | ||
import { pathExists, pathExistsSync, readFile, readFileSync } from 'fs-extra'; | ||
import { cwd } from 'process'; | ||
@@ -20,3 +20,3 @@ import { processImport } from '@graphql-tools/import'; | ||
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd, pointer); | ||
return new Promise(resolve => exists(normalizedFilePath, resolve)); | ||
return pathExists(normalizedFilePath); | ||
} | ||
@@ -30,3 +30,3 @@ } | ||
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd, pointer); | ||
return existsSync(normalizedFilePath); | ||
return pathExistsSync(normalizedFilePath); | ||
} | ||
@@ -39,9 +39,3 @@ } | ||
const rawSDL = await readFile(normalizedFilePath, { encoding: 'utf8' }); | ||
if (isGraphQLImportFile(rawSDL)) { | ||
return { | ||
location: pointer, | ||
document: processImport(pointer, options.cwd), | ||
}; | ||
} | ||
return parseGraphQLSDL(pointer, rawSDL.trim(), options); | ||
return this.handleFileContent(rawSDL, pointer, options); | ||
} | ||
@@ -52,3 +46,6 @@ loadSync(pointer, options) { | ||
const rawSDL = readFileSync(normalizedFilePath, { encoding: 'utf8' }); | ||
if (isGraphQLImportFile(rawSDL)) { | ||
return this.handleFileContent(rawSDL, pointer, options); | ||
} | ||
handleFileContent(rawSDL, pointer, options) { | ||
if (!options.skipGraphQLImport && isGraphQLImportFile(rawSDL)) { | ||
return { | ||
@@ -55,0 +52,0 @@ location: pointer, |
{ | ||
"name": "@graphql-tools/graphql-file-loader", | ||
"version": "6.0.7-alpha-258b8cb.0", | ||
"version": "6.0.7-alpha-3f2c64a.0", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -10,4 +10,4 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@graphql-tools/import": "6.0.7-alpha-258b8cb.0", | ||
"@graphql-tools/utils": "6.0.7-alpha-258b8cb.0", | ||
"@graphql-tools/import": "6.0.7-alpha-3f2c64a.0", | ||
"@graphql-tools/utils": "6.0.7-alpha-3f2c64a.0", | ||
"fs-extra": "9.0.0", | ||
@@ -14,0 +14,0 @@ "tslib": "~2.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
131
16202
+ Added@graphql-tools/import@6.0.7-alpha-3f2c64a.0(transitive)
+ Added@graphql-tools/utils@6.0.7-alpha-3f2c64a.0(transitive)
- Removed@graphql-tools/import@6.0.7-alpha-258b8cb.0(transitive)
- Removed@graphql-tools/utils@6.0.7-alpha-258b8cb.0(transitive)