Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-toolkit/code-file-loader

Package Overview
Dependencies
Maintainers
3
Versions
695
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-toolkit/code-file-loader - npm Package Compare versions

Comparing version 0.6.8-alpha-a3fdc9c.4 to 0.6.8-alpha-aa0b7b9.7

4

dist/commonjs/extract-document-string-from-code-file.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const graphql_1 = require("graphql");
const graphql_tag_pluck_1 = require("graphql-tag-pluck");
function calculateOptions(options) {

@@ -34,4 +35,3 @@ if (!options || !options.tagPluck) {

try {
const { gqlPluckFromFile } = eval(`require('graphql-tag-pluck')`);
return (await gqlPluckFromFile(source.name, calculateOptions(options))) || null;
return (await graphql_tag_pluck_1.gqlPluckFromFile(source.name, calculateOptions(options))) || null;
}

@@ -38,0 +38,0 @@ catch (e) {

@@ -7,2 +7,4 @@ "use strict";

const common_1 = require("@graphql-toolkit/common");
const fs_1 = require("fs");
const isValidPath = require("is-valid-path");
function isSchemaText(obj) {

@@ -52,3 +54,3 @@ return typeof obj === 'string';

if (require && require.cache) {
filePath = eval(`require.resolve('${filePath}')`);
filePath = require.resolve(filePath);
if (require.cache[filePath]) {

@@ -58,3 +60,3 @@ delete require.cache[filePath];

}
const rawExports = await eval(`require('${filePath}');`);
const rawExports = await Promise.resolve().then(() => require(filePath));
if (rawExports) {

@@ -85,4 +87,3 @@ let rawExport = rawExports.default || rawExports.schema || rawExports;

async function tryToLoadFromCodeAst(filePath, options) {
const { readFileSync } = eval(`require('fs')`);
const content = readFileSync(filePath, 'utf-8');
const content = fs_1.readFileSync(filePath, 'utf-8');
const foundDoc = await extract_document_string_from_code_file_1.extractDocumentStringFromCodeFile(new graphql_1.Source(content, filePath), options || {});

@@ -102,4 +103,12 @@ if (foundDoc) {

async canLoad(pointer, options) {
const extension = path_1.extname(pointer).toLowerCase();
return CODE_FILE_EXTENSIONS.includes(extension);
if (isValidPath(pointer)) {
const extension = path_1.extname(pointer).toLowerCase();
if (CODE_FILE_EXTENSIONS.includes(extension)) {
const normalizedFilePath = path_1.isAbsolute(pointer) ? pointer : path_1.resolve(options.cwd || process.cwd(), pointer);
if (fs_1.existsSync(normalizedFilePath)) {
return true;
}
}
}
return false;
}

@@ -106,0 +115,0 @@ async load(pointer, options) {

import { parse } from 'graphql';
import { gqlPluckFromFile } from 'graphql-tag-pluck';
function calculateOptions(options) {

@@ -32,3 +33,2 @@ if (!options || !options.tagPluck) {

try {
const { gqlPluckFromFile } = eval(`require('graphql-tag-pluck')`);
return (await gqlPluckFromFile(source.name, calculateOptions(options))) || null;

@@ -35,0 +35,0 @@ }

@@ -5,2 +5,4 @@ import { GraphQLSchema, parse, buildClientSchema, Source as GraphQLSource } from 'graphql';

import { debugLog, printSchemaWithDirectives, asArray, fixWindowsPath } from '@graphql-toolkit/common';
import { readFileSync, existsSync } from 'fs';
import * as isValidPath from 'is-valid-path';
function isSchemaText(obj) {

@@ -50,3 +52,3 @@ return typeof obj === 'string';

if (require && require.cache) {
filePath = eval(`require.resolve('${filePath}')`);
filePath = require.resolve(filePath);
if (require.cache[filePath]) {

@@ -56,3 +58,3 @@ delete require.cache[filePath];

}
const rawExports = await eval(`require('${filePath}');`);
const rawExports = await import(filePath);
if (rawExports) {

@@ -83,3 +85,2 @@ let rawExport = rawExports.default || rawExports.schema || rawExports;

async function tryToLoadFromCodeAst(filePath, options) {
const { readFileSync } = eval(`require('fs')`);
const content = readFileSync(filePath, 'utf-8');

@@ -100,4 +101,12 @@ const foundDoc = await extractDocumentStringFromCodeFile(new GraphQLSource(content, filePath), options || {});

async canLoad(pointer, options) {
const extension = extname(pointer).toLowerCase();
return CODE_FILE_EXTENSIONS.includes(extension);
if (isValidPath(pointer)) {
const extension = extname(pointer).toLowerCase();
if (CODE_FILE_EXTENSIONS.includes(extension)) {
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || process.cwd(), pointer);
if (existsSync(normalizedFilePath)) {
return true;
}
}
}
return false;
}

@@ -104,0 +113,0 @@ async load(pointer, options) {

{
"name": "@graphql-toolkit/code-file-loader",
"version": "0.6.8-alpha-a3fdc9c.4+a3fdc9c",
"version": "0.6.8-alpha-aa0b7b9.7+aa0b7b9",
"description": "A set of utils for faster development of GraphQL tools",

@@ -24,3 +24,3 @@ "repository": "git@github.com:dotansimha/graphql-toolkit.git",

"devDependencies": {
"@types/jest": "24.0.21",
"@types/jest": "24.0.22",
"graphql": "14.5.8",

@@ -32,4 +32,6 @@ "jest": "24.9.0",

"dependencies": {
"@graphql-toolkit/common": "0.6.8-alpha-a3fdc9c.4+a3fdc9c",
"graphql-tag-pluck": "0.8.7"
"@graphql-toolkit/common": "0.6.8-alpha-aa0b7b9.7+aa0b7b9",
"graphql-tag-pluck": "0.8.7",
"is-valid-path": "0.1.1",
"tslib": "1.10.0"
},

@@ -39,3 +41,3 @@ "publishConfig": {

},
"gitHead": "a3fdc9cd16e3e2d7833d663fbbe3ab860162f668"
"gitHead": "aa0b7b913da8b728a64cbd28374276c45df406fc"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc