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

graphql-markdown

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-markdown - npm Package Compare versions

Comparing version 5.2.0 to 6.0.0

7

package.json
{
"name": "graphql-markdown",
"version": "5.2.0",
"version": "6.0.0",
"description": "Generate documentation for your GraphQL schema in Markdown",

@@ -37,5 +37,7 @@ "main": "src/index.js",

},
"peerDependencies": {
"graphql": "^14.0.2 || ^15.0.0"
},
"dependencies": {
"deep-diff": "^1.0.2",
"graphql": "^14.0.2",
"lodash.isplainobject": "^4.0.6",

@@ -57,2 +59,3 @@ "minimist": "^1.2.0",

"graphbrainz": "^8.1.0",
"graphql": "^14.0.2",
"husky": "^1.1.0",

@@ -59,0 +62,0 @@ "jest": "^23.6.0",

@@ -17,2 +17,3 @@ <div align="center">

```console
$ yarn add graphql-markdown --dev
$ npm install graphql-markdown --save-dev

@@ -28,3 +29,5 @@ ```

Installing the package adds a `graphql-markdown` script. Point it at a schema
and the output will be written to stdout.
and the output will be written to stdout. You must install `graphql` alongside
this package according to the
[compatible versions specified in `peerDependencies`](./package.json).

@@ -56,7 +59,8 @@ The schema may be retrieved from a GraphQL endpoint:

If `--update-file` is given, the generated Markdown will be output to the given
file between the `<!-- START graphql-markdown -->` and `<!-- END graphql-markdown -->`
comment markers instead of printed to STDOUT. If the file does not exist, it
will be created (and will include the comment markers for future updates). Use
this if you’d like to embed the rendered Markdown as just one part of a larger
document (see also the `--heading-level` option).
file between the `<!-- START graphql-markdown -->` and
`<!-- END graphql-markdown -->` comment markers instead of printed to STDOUT. If
the file does not exist, it will be created (and will include the comment
markers for future updates). Use this if you’d like to embed the rendered
Markdown as just one part of a larger document (see also the `--heading-level`
option).

@@ -115,12 +119,13 @@ #### Options

* **`title`**: The title of the document, defaults to “Schema Types”.
* **`prologue`**: Markdown content to include after the title.
* **`epilogue`**: Markdown content to include after everything else.
* **`printer`**: A function to handle each line of output, defaults to `console.log`.
* **`skipTableOfContents`**: When set, rendering of "Table of contents" section
- **`title`**: The title of the document, defaults to “Schema Types”.
- **`prologue`**: Markdown content to include after the title.
- **`epilogue`**: Markdown content to include after everything else.
- **`printer`**: A function to handle each line of output, defaults to
`console.log`.
- **`skipTableOfContents`**: When set, rendering of "Table of contents" section
is skipped.
* **`headingLevel`**: The initial level at which to render Markdown headings in
- **`headingLevel`**: The initial level at which to render Markdown headings in
the output, defaults to 1. Use this if you are using `updateSchema` to embed
the output in a larger document with other sections.
* **`unknownTypeURL`**: A string or function to determine the URL for linking to
- **`unknownTypeURL`**: A string or function to determine the URL for linking to
types that aren’t found in the schema being rendered. This may be the case if

@@ -152,3 +157,3 @@ you’re rendering the result of `diffSchema()`, for example. String values will

* **`processTypeDiff`**: A function to add or modify fields on each type that
- **`processTypeDiff`**: A function to add or modify fields on each type that
will be output.

@@ -158,8 +163,7 @@

Output is optimized for display on GitHub, using GitHub Flavored Markdown. Due to the
complexity of the tables in the generated document, much of the table output is raw HTML
(as allowed by Markdown).
Output is optimized for display on GitHub, using GitHub Flavored Markdown. Due
to the complexity of the tables in the generated document, much of the table
output is raw HTML (as allowed by Markdown).
[example]: https://github.com/exogen/graphbrainz/blob/master/docs/types.md
[graphbrainz]: https://github.com/exogen/graphbrainz

@@ -23,5 +23,7 @@ 'use strict'

const graphql = options.graphql || DEFAULT_GRAPHQL
return graphql.graphql(schema, graphql.introspectionQuery).then(result => {
return result.data
})
return graphql
.graphql(schema, graphql.getIntrospectionQuery())
.then(result => {
return result.data
})
}

@@ -39,3 +41,3 @@

},
body: JSON.stringify({ query: graphql.introspectionQuery })
body: JSON.stringify({ query: graphql.getIntrospectionQuery() })
})

@@ -42,0 +44,0 @@ .then(res => res.json())

@@ -142,2 +142,3 @@ 'use strict'

const interfaces = types.filter(type => type.kind === 'INTERFACE')
const unions = types.filter(type => type.kind === 'UNION')

@@ -149,2 +150,3 @@ sortBy(objects, 'name')

sortBy(interfaces, 'name')
sortBy(unions, 'name')

@@ -198,2 +200,8 @@ if (!skipTitle) {

}
if (unions.length) {
printer(' * [Unions](#unions)')
unions.forEach(type => {
printer(` * [${type.name}](#${type.name.toLowerCase()})`)
})
}
printer('\n</details>')

@@ -300,2 +308,36 @@ }

if (unions.length) {
printer(`\n${'#'.repeat(headingLevel + 1)} Unions`)
unions.forEach(type => {
printer(`\n${'#'.repeat(headingLevel + 2)} ${type.name}\n`)
if (type.description) {
printer(`${type.description}\n`)
}
printer('<table>')
printer('<thead>')
printer('<th align="left">Type</th>')
printer('<th align="left">Description</th>')
printer('</thead>')
printer('<tbody>')
type.possibleTypes.forEach(objType => {
const obj = objects.find(o => objType.name === o.name)
const desc = objType.description || (obj && obj.description)
printer('<tr>')
printer(
`<td valign="top"><strong>${renderType(objType, {
getTypeURL
})}</strong></td>`
)
if (desc) {
printer(`<td valign="top">${desc}</td>`)
} else {
printer('<td></td>')
}
printer('</tr>')
})
printer('</tbody>')
printer('</table>')
})
}
if (epilogue) {

@@ -302,0 +344,0 @@ printer(`\n${epilogue}`)

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