@graphql-markdown/utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -11,0 +11,0 @@ "main": "src/index.js", |
@@ -7,3 +7,3 @@ /* istanbul ignore file */ | ||
return format(content, { parser }); | ||
} catch (e) { | ||
} catch (error) { | ||
console.debug("Prettier is not found"); | ||
@@ -10,0 +10,0 @@ } |
@@ -38,6 +38,2 @@ const { | ||
const DefaultLoaders = { | ||
GraphQLFileLoader: "@graphql-tools/graphql-file-loader", | ||
}; | ||
async function loadSchema(schemaLocation, options) { | ||
@@ -67,5 +63,3 @@ let rootTypes = undefined; | ||
function getDocumentLoaders(extraLoaders = {}) { | ||
const loadersList = { ...DefaultLoaders, ...extraLoaders }; | ||
function getDocumentLoaders(loadersList = {}) { | ||
const loaders = []; | ||
@@ -75,18 +69,17 @@ const loaderOptions = {}; | ||
Object.entries(loadersList).forEach(([className, graphqlDocumentLoader]) => { | ||
try { | ||
if (typeof graphqlDocumentLoader === "string") { | ||
const { [className]: Loader } = require(graphqlDocumentLoader); | ||
loaders.push(new Loader()); | ||
} else { | ||
if (!graphqlDocumentLoader.module) { | ||
throw new Error( | ||
`Wrong format for plugin loader "${className}", it should be {module: String, options?: Object}`, | ||
); | ||
} | ||
const { [className]: Loader } = require(graphqlDocumentLoader.module); | ||
loaders.push(new Loader()); | ||
Object.assign(loaderOptions, graphqlDocumentLoader.options); | ||
if (typeof graphqlDocumentLoader === "string") { | ||
const { [className]: Loader } = require(graphqlDocumentLoader); | ||
loaders.push(new Loader()); | ||
} else { | ||
if ( | ||
typeof graphqlDocumentLoader.module !== "string" || | ||
graphqlDocumentLoader.module == null | ||
) { | ||
throw new Error( | ||
`Wrong format for plugin loader "${className}", it should be {module: String, options?: Object}`, | ||
); | ||
} | ||
} catch (error) { | ||
console.warn(graphqlDocumentLoader, error.message); | ||
const { [className]: Loader } = require(graphqlDocumentLoader.module); | ||
loaders.push(new Loader()); | ||
Object.assign(loaderOptions, graphqlDocumentLoader.options); | ||
} | ||
@@ -98,3 +91,2 @@ }); | ||
} | ||
return { loaders, loaderOptions }; | ||
@@ -114,3 +106,3 @@ } | ||
function getDefaultValue({ type, defaultValue }) { | ||
if (defaultValue === null || typeof defaultValue === "undefined") { | ||
if (typeof defaultValue === "undefined" || defaultValue === null) { | ||
return undefined; | ||
@@ -145,3 +137,3 @@ } | ||
function getTypeFromSchema(schema, type) { | ||
if (typeof schema == "undefined" || schema == null) { | ||
if (typeof schema === "undefined" || schema == null) { | ||
return undefined; | ||
@@ -174,3 +166,3 @@ } | ||
if ( | ||
typeof queryType == "undefined" || | ||
typeof queryType === "undefined" || | ||
queryType == null || | ||
@@ -177,0 +169,0 @@ !hasMethod(queryType, "getFields") |
15474
481