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

graphql-tag

Package Overview
Dependencies
Maintainers
5
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-tag - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

26

loader.js
const gql = require('./');
// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
// the imported definitions.
function expandImports(source, doc) {
const lines = source.split('\n');
let outputCode = "";
lines.some((line) => {
if (line[0] === '#' && line.slice(1).split(' ')[0] === 'import') {
const importFile = line.slice(1).split(' ')[1];
const parseDocument = `require(${importFile})`;
const appendDef = `doc.definitions = doc.definitions.concat(${parseDocument}.definitions);`;
outputCode += appendDef + "\n";
}
return (line.length !== 0 && line[0] !== '#');
});
return outputCode;
}
module.exports = function(source) {
this.cacheable();
return `module.exports = ${JSON.stringify(gql`${source}`)};`;
const doc = gql`${source}`;
const outputCode = `const doc = ${JSON.stringify(doc)};`;
const importOutputCode = expandImports(source, doc);
return outputCode + "\n" + importOutputCode + "\n" + `module.exports = doc;`;
};

2

package.json
{
"name": "graphql-tag",
"version": "1.1.2",
"version": "1.1.3",
"description": "A JavaScript template literal tag that parses GraphQL queries",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -92,2 +92,5 @@ # graphql-tag

Testing environments that don't support Webpack require additional configuration. For [Jest](https://facebook.github.io/jest/) use [jest-transform-graphql](https://github.com/remind101/jest-transform-graphql).
### Parser and printer

@@ -94,0 +97,0 @@

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