@graphql-toolkit/graphql-file-loader
Advanced tools
Comparing version 0.6.1-alpha-cee1e98.4 to 0.6.2-alpha.0
import { Source, UniversalLoader, DocumentPointerSingle, SchemaPointerSingle } from '@graphql-toolkit/common'; | ||
export declare type GraphQLFileLoaderOptions = { | ||
skipGraphQLImport: boolean; | ||
cwd?: string; | ||
}; | ||
@@ -5,0 +6,0 @@ export declare class GraphQLFileLoader implements UniversalLoader<GraphQLFileLoaderOptions> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const graphql_1 = require("graphql"); | ||
const path_1 = require("path"); | ||
const graphql_1 = require("graphql"); | ||
const GQL_EXTENSIONS = ['.gql', '.graphql', '.graphqls']; | ||
@@ -16,7 +16,8 @@ class GraphQLFileLoader { | ||
const { readFileSync } = eval(`require('fs')`); | ||
const content = readFileSync(pointer, 'utf-8').trim(); | ||
const normalizedFilePath = path_1.isAbsolute(pointer) ? pointer : path_1.resolve(options.cwd || process.cwd(), pointer); | ||
const content = readFileSync(normalizedFilePath, 'utf-8').trim(); | ||
if (content && content !== '') { | ||
if (!options.skipGraphQLImport && /^\#.*import /i.test(content.trimLeft())) { | ||
const { importSchema } = eval(`require('graphql-import')`); | ||
const importedSchema = importSchema(pointer); | ||
const importedSchema = importSchema(normalizedFilePath); | ||
return { | ||
@@ -23,0 +24,0 @@ location: pointer, |
import { Source, UniversalLoader, DocumentPointerSingle, SchemaPointerSingle } from '@graphql-toolkit/common'; | ||
export declare type GraphQLFileLoaderOptions = { | ||
skipGraphQLImport: boolean; | ||
cwd?: string; | ||
}; | ||
@@ -5,0 +6,0 @@ export declare class GraphQLFileLoader implements UniversalLoader<GraphQLFileLoaderOptions> { |
@@ -1,3 +0,3 @@ | ||
import { extname } from 'path'; | ||
import { parse, Source as GraphQLSource } from 'graphql'; | ||
import { extname, isAbsolute, resolve } from 'path'; | ||
const GQL_EXTENSIONS = ['.gql', '.graphql', '.graphqls']; | ||
@@ -14,7 +14,8 @@ export class GraphQLFileLoader { | ||
const { readFileSync } = eval(`require('fs')`); | ||
const content = readFileSync(pointer, 'utf-8').trim(); | ||
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || process.cwd(), pointer); | ||
const content = readFileSync(normalizedFilePath, 'utf-8').trim(); | ||
if (content && content !== '') { | ||
if (!options.skipGraphQLImport && /^\#.*import /i.test(content.trimLeft())) { | ||
const { importSchema } = eval(`require('graphql-import')`); | ||
const importedSchema = importSchema(pointer); | ||
const importedSchema = importSchema(normalizedFilePath); | ||
return { | ||
@@ -21,0 +22,0 @@ location: pointer, |
{ | ||
"name": "@graphql-toolkit/graphql-file-loader", | ||
"version": "0.6.1-alpha-cee1e98.4+cee1e98", | ||
"version": "0.6.2-alpha.0+aab2758", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -28,3 +28,3 @@ "repository": "git@github.com:dotansimha/graphql-toolkit.git", | ||
"dependencies": { | ||
"@graphql-toolkit/common": "0.6.1-alpha-cee1e98.4+cee1e98", | ||
"@graphql-toolkit/common": "0.6.2-alpha.0+aab2758", | ||
"graphql-import": "0.7.1" | ||
@@ -35,3 +35,3 @@ }, | ||
}, | ||
"gitHead": "cee1e98ff0ec3e2a47176748797dbc816506533a" | ||
"gitHead": "aab275825969724eae67e2df0bb55472c90f7e43" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
9414
98