@graphql-markdown/printer-legacy
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@graphql-markdown/utils": "1.0.1" | ||
"@graphql-markdown/utils": "1.1.0" | ||
}, | ||
@@ -29,0 +29,0 @@ "directories": { |
100
src/index.js
const { | ||
isEnumType, | ||
isUnionType, | ||
isObjectType, | ||
isScalarType, | ||
isOperation, | ||
getDefaultValue, | ||
getTypeName, | ||
getFields, | ||
isDirectiveType, | ||
isParametrizedField, | ||
isInterfaceType, | ||
getNamedType, | ||
isInputType, | ||
isListType, | ||
isNonNullType, | ||
isLeafType, | ||
getRelationOfReturn, | ||
getRelationOfField, | ||
getRelationOfImplementation, | ||
} = require("@graphql-markdown/utils").graphql; | ||
const { | ||
string: { toSlug, escapeMDX }, | ||
object: { hasProperty, hasMethod }, | ||
url: { pathUrl }, | ||
} = require("@graphql-markdown/utils").scalars; | ||
graphql: { | ||
isEnumType, | ||
isUnionType, | ||
isObjectType, | ||
isScalarType, | ||
isOperation, | ||
getDefaultValue, | ||
getTypeName, | ||
getFields, | ||
isDirectiveType, | ||
isParametrizedField, | ||
isInterfaceType, | ||
getNamedType, | ||
isInputType, | ||
isListType, | ||
isNonNullType, | ||
isLeafType, | ||
getRelationOfReturn, | ||
getRelationOfField, | ||
getRelationOfImplementation, | ||
hasDirective, | ||
}, | ||
} = require("@graphql-markdown/utils"); | ||
@@ -45,5 +45,6 @@ const { | ||
linkRoot = "/", | ||
{ groups, printTypeOptions } = { | ||
{ groups, printTypeOptions, skipDocDirective } = { | ||
groups: undefined, | ||
printTypeOptions: undefined, | ||
skipDocDirective: undefined, | ||
}, | ||
@@ -58,2 +59,3 @@ ) { | ||
this.typeBadges = printTypeOptions?.typeBadges ?? true; | ||
this.skipDocDirective = skipDocDirective ?? undefined; | ||
} | ||
@@ -109,2 +111,6 @@ | ||
if (hasDirective(type, this.skipDocDirective)) { | ||
return fallback; | ||
} | ||
const graphLQLNamedType = getNamedType(type); | ||
@@ -382,5 +388,25 @@ | ||
printCodeDirectiveLocation(type) { | ||
if ( | ||
typeof type.locations === "undefined" || | ||
type.locations == null || | ||
type.locations.length === 0 | ||
) { | ||
return ""; | ||
} | ||
let code = ` on `; | ||
const separator = `\r\n | `; | ||
if (type.locations.length > 1) { | ||
code += separator; | ||
} | ||
code += type.locations.join(separator).trim(); | ||
return code; | ||
} | ||
printCodeDirective(type) { | ||
let code = `directive @${getTypeName(type)}`; | ||
code += this.printCodeArguments(type); | ||
code += this.printCodeDirectiveLocation(type); | ||
@@ -486,2 +512,3 @@ return code; | ||
let metadata; | ||
switch (true) { | ||
@@ -498,3 +525,3 @@ case isScalarType(type): | ||
case isInterfaceType(type): | ||
case isInputType(type): | ||
case isInputType(type): { | ||
metadata = this.printSection(getFields(type), "Fields", { | ||
@@ -507,18 +534,21 @@ parentType: type.name, | ||
return metadata; | ||
case isDirectiveType(type): | ||
case isOperation(type): | ||
} | ||
case isDirectiveType(type): { | ||
metadata = this.printSection(type.args, "Arguments", { | ||
parentType: type.name, | ||
}); | ||
return metadata; | ||
} | ||
case isOperation(type): { | ||
metadata = this.printSection(type.args, "Arguments", { | ||
parentType: type.name, | ||
}); | ||
const queryType = getTypeName(type.type).replace(/[![\]]*/g, ""); | ||
metadata += this.printSection([this.schema.getType(queryType)], "Type"); | ||
if (isOperation(type)) { | ||
const queryType = getTypeName(type.type).replace(/[![\]]*/g, ""); | ||
metadata += this.printSection( | ||
[this.schema.getType(queryType)], | ||
"Type", | ||
); | ||
} | ||
return metadata; | ||
} | ||
default: | ||
return metadata; | ||
} | ||
return metadata; | ||
} | ||
@@ -525,0 +555,0 @@ |
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
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
19594
553
+ Added@graphql-markdown/utils@1.1.0(transitive)
- Removed@graphql-markdown/utils@1.0.1(transitive)