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

@graphql-toolkit/graphql-file-loader

Package Overview
Dependencies
Maintainers
3
Versions
686
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.6.8-alpha-ffaed82.0 to 0.6.8

21

dist/commonjs/load-from-gql-file.js

@@ -5,2 +5,5 @@ "use strict";

const path_1 = require("path");
const fs_1 = require("fs");
const isValidPath = require("is-valid-path");
const graphql_import_1 = require("graphql-import");
const GQL_EXTENSIONS = ['.gql', '.graphql', '.graphqls'];

@@ -12,13 +15,19 @@ class GraphQLFileLoader {

async canLoad(pointer, options) {
const extension = path_1.extname(pointer).toLowerCase();
return GQL_EXTENSIONS.includes(extension);
if (isValidPath(pointer)) {
const extension = path_1.extname(pointer).toLowerCase();
if (GQL_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;
}
async load(pointer, options) {
const { readFileSync } = eval(`require('fs')`);
const normalizedFilePath = path_1.isAbsolute(pointer) ? pointer : path_1.resolve(options.cwd || process.cwd(), pointer);
const content = readFileSync(normalizedFilePath, 'utf-8').trim();
const content = fs_1.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(normalizedFilePath);
const importedSchema = graphql_import_1.importSchema(normalizedFilePath);
return {

@@ -25,0 +34,0 @@ location: pointer,

import { parse, Source as GraphQLSource } from 'graphql';
import { extname, isAbsolute, resolve } from 'path';
import { readFileSync, existsSync } from 'fs';
import * as isValidPath from 'is-valid-path';
import { importSchema } from 'graphql-import';
const GQL_EXTENSIONS = ['.gql', '.graphql', '.graphqls'];

@@ -9,7 +12,14 @@ export class GraphQLFileLoader {

async canLoad(pointer, options) {
const extension = extname(pointer).toLowerCase();
return GQL_EXTENSIONS.includes(extension);
if (isValidPath(pointer)) {
const extension = extname(pointer).toLowerCase();
if (GQL_EXTENSIONS.includes(extension)) {
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || process.cwd(), pointer);
if (existsSync(normalizedFilePath)) {
return true;
}
}
}
return false;
}
async load(pointer, options) {
const { readFileSync } = eval(`require('fs')`);
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || process.cwd(), pointer);

@@ -19,3 +29,2 @@ const content = readFileSync(normalizedFilePath, 'utf-8').trim();

if (!options.skipGraphQLImport && /^\#.*import /i.test(content.trimLeft())) {
const { importSchema } = eval(`require('graphql-import')`);
const importedSchema = importSchema(normalizedFilePath);

@@ -22,0 +31,0 @@ return {

{
"name": "@graphql-toolkit/graphql-file-loader",
"version": "0.6.8-alpha-ffaed82.0+ffaed82",
"version": "0.6.8",
"description": "A set of utils for faster development of GraphQL tools",

@@ -25,7 +25,8 @@ "repository": "git@github.com:dotansimha/graphql-toolkit.git",

"graphql": "14.5.8",
"typescript": "3.6.4"
"typescript": "3.7.2"
},
"dependencies": {
"@graphql-toolkit/common": "0.6.8-alpha-ffaed82.0+ffaed82",
"graphql-import": "0.7.1"
"@graphql-toolkit/common": "0.6.8",
"graphql-import": "0.7.1",
"tslib": "1.10.0"
},

@@ -35,3 +36,3 @@ "publishConfig": {

},
"gitHead": "ffaed82b6bc78c9abb8a6897f27bc969d929b547"
"gitHead": "42f1597a036ccd8a247e633a17e02ad03656aa1d"
}

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