@graphql-tools/utils
Advanced tools
Comparing version 10.6.0 to 10.6.1-alpha-20241127191302-c4315873cd36b96c5f77bba782be9e542ef931a3
@@ -5,2 +5,11 @@ "use strict"; | ||
const graphql_1 = require("graphql"); | ||
function isURL(str) { | ||
try { | ||
const url = new URL(str); | ||
return !!url; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
} | ||
const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []); | ||
@@ -18,3 +27,3 @@ exports.asArray = asArray; | ||
// if the string is a SDL | ||
if (invalidDocRegex.test(str)) { | ||
if (invalidDocRegex.test(str) || isURL(str)) { | ||
return false; | ||
@@ -26,3 +35,9 @@ } | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
if (!e.message.includes('EOF') && | ||
str.replace(/(\#[^*]*)/g, '').trim() !== '' && | ||
str.includes(' ')) { | ||
throw new Error(`Failed to parse the GraphQL document. ${e.message}\n${str}`); | ||
} | ||
} | ||
return false; | ||
@@ -29,0 +44,0 @@ } |
import { parse } from 'graphql'; | ||
function isURL(str) { | ||
try { | ||
const url = new URL(str); | ||
return !!url; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
} | ||
export const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []); | ||
@@ -13,3 +22,3 @@ const invalidDocRegex = /\.[a-z0-9]+$/i; | ||
// if the string is a SDL | ||
if (invalidDocRegex.test(str)) { | ||
if (invalidDocRegex.test(str) || isURL(str)) { | ||
return false; | ||
@@ -21,3 +30,9 @@ } | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
if (!e.message.includes('EOF') && | ||
str.replace(/(\#[^*]*)/g, '').trim() !== '' && | ||
str.includes(' ')) { | ||
throw new Error(`Failed to parse the GraphQL document. ${e.message}\n${str}`); | ||
} | ||
} | ||
return false; | ||
@@ -24,0 +39,0 @@ } |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "10.6.0", | ||
"version": "10.6.1-alpha-20241127191302-c4315873cd36b96c5f77bba782be9e542ef931a3", | ||
"description": "Common package containing utils and types for GraphQL tools", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
516189
11196
2