Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
graphql-print
Advanced tools
Print any GraphQL AST node, pretty or minified, with or without comments
graphql-print
The printer that GraphQL always deserved.
✅ Pretty and minified printing
✅ Print comments
✅ Configure line length
✅ Choose custom indentation
Note that graphql
is a peer dependency of this package and needs to be installed as well.
npm i graphql graphql-print
This package supports printing any valid GraphQL AST node, as well as printing a list of nodes.
By default, the printer outputs a pretty-printed version of the given AST nodes, but it can be configured in different ways. The following table shows the supported options.
Option | Type | Default | Description |
---|---|---|---|
minified | boolean | false | Returns a minified version of the AST, optimizing for shortest string length |
preserveComments | boolean | false | All comments are stripped from the AST by default but can be perserved using this option |
maxLineLength | number | 80 | The printer tries to output lists of nodes in a single line where possible and only breaks lists items into individual lines when they become too long. This option controls the threshold for when a line should be broken up into multiple ones. |
indentationStep | string | " " | By default the printer uses two spaces for indentation, this option allows you to configure that. (Note that passing any characters other than ignored tokens will result in a string that does not represent the original AST anymore and might potentially be invalid.) |
import { parse } from "graphql";
import { print } from "graphql-print";
const ast = parse(`
query MyQuery {
# select a field
myField(myArg: 42, myOtherArg: null)
}
`);
console.log(print(ast));
/**
* Will print the following:
*
* query MyQuery {
* myField(myArg: 42, myOtherArg: null)
* }
*/
console.log(print(ast, { minified: true }));
/**
* Will print the following:
*
* query MyQuery{myField(myArg:42,myOtherArg:null)}
*/
console.log(print(ast, { preserveComments: true }));
/**
* Will print the following:
*
* query MyQuery {
* # select a field
* myField(myArg: 42, myOtherArg: null)
* }
*/
console.log(print(ast, { maxLineLength: 20 }));
/**
* Will print the following:
*
* query MyQuery {
* myField(
* myArg: 42
* myOtherArg: null
* )
* }
*/
FAQs
Print any GraphQL AST node, pretty or minified, with or without comments
The npm package graphql-print receives a total of 27 weekly downloads. As such, graphql-print popularity was classified as not popular.
We found that graphql-print demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.