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

graphql-tag

Package Overview
Dependencies
Maintainers
6
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 2.5.0 to 2.6.0

95

CHANGELOG.md
# Change log
### v2.6.0
* Support multiple query definitions when using Webpack loader [jfaust](https://github.com/jfaust) in
[PR #122](https://github.com/apollographql/graphql-tag/pull/122)
### v2.5.0
- Update graphql to ^0.11.0, add graphql@^0.11.0 to peerDependencies [pleunv](https://github.com/pleunv) in [PR #124](https://github.com/apollographql/graphql-tag/pull/124)
* Update graphql to ^0.11.0, add graphql@^0.11.0 to peerDependencies [pleunv](https://github.com/pleunv) in
[PR #124](https://github.com/apollographql/graphql-tag/pull/124)
### v2.4.{1,2}
- Temporarily reverting [PR #99](https://github.com/apollographql/graphql-tag/pull/99) to investigate issues with bundling
* Temporarily reverting [PR #99](https://github.com/apollographql/graphql-tag/pull/99) to investigate issues with
bundling
### v2.4.0
- Add support for descriptors [jamiter](https://github.com/jamiter) in [PR #99](https://github.com/apollographql/graphql-tag/pull/99)
* Add support for descriptors [jamiter](https://github.com/jamiter) in
[PR #99](https://github.com/apollographql/graphql-tag/pull/99)
### v2.3.0
- Add flow support [michalkvasnicak](https://github.com/michalkvasnicak) in [PR #98](https://github.com/apollographql/graphql-tag/pull/98)
* Add flow support [michalkvasnicak](https://github.com/michalkvasnicak) in
[PR #98](https://github.com/apollographql/graphql-tag/pull/98)
### v2.2.2
- Make parsing line endings kind agnostic [vlasenko](https://github.com/vlasenko) in [PR #95](https://github.com/apollographql/graphql-tag/pull/95)
* Make parsing line endings kind agnostic [vlasenko](https://github.com/vlasenko) in
[PR #95](https://github.com/apollographql/graphql-tag/pull/95)
### v2.2.1
- Fix #61: split('/n') does not work on Windows [dnalborczyk](https://github.com/dnalborczyk) in [PR #89](https://github.com/apollographql/graphql-tag/pull/89)
* Fix #61: split('/n') does not work on Windows [dnalborczyk](https://github.com/dnalborczyk) in
[PR #89](https://github.com/apollographql/graphql-tag/pull/89)
### v2.2.0
- Bumping `graphql` peer dependency to ^0.10.0 [dotansimha](https://github.com/dotansimha) in [PR #85](https://github.com/apollographql/graphql-tag/pull/85)
* Bumping `graphql` peer dependency to ^0.10.0 [dotansimha](https://github.com/dotansimha) in
[PR #85](https://github.com/apollographql/graphql-tag/pull/85)
### v2.1.0
- Add support for calling `gql` as a function [matthewerwin](https://github.com/matthewerwin) in [PR #66](https://github.com/apollographql/graphql-tag/pull/66)
- Including yarn.lock file [PowerKiKi](https://github.com/PowerKiKi) in [PR #72](https://github.com/apollographql/graphql-tag/pull/72)
- Ignore duplicate fragments when using the Webpack loader [czert](https://github.com/czert) in [PR #52](https://github.com/apollographql/graphql-tag/pull/52)
- Fixing `graphql-tag/loader` by properly stringifying GraphQL Source [jnwng](https://github.com/jnwng) in [PR #65](https://github.com/apollographql/graphql-tag/pull/65)
* Add support for calling `gql` as a function [matthewerwin](https://github.com/matthewerwin) in
[PR #66](https://github.com/apollographql/graphql-tag/pull/66)
* Including yarn.lock file [PowerKiKi](https://github.com/PowerKiKi) in
[PR #72](https://github.com/apollographql/graphql-tag/pull/72)
* Ignore duplicate fragments when using the Webpack loader [czert](https://github.com/czert) in
[PR #52](https://github.com/apollographql/graphql-tag/pull/52)
* Fixing `graphql-tag/loader` by properly stringifying GraphQL Source [jnwng](https://github.com/jnwng) in
[PR #65](https://github.com/apollographql/graphql-tag/pull/65)
### v2.0.0
Restore dependence on `graphql` module [abhiaiyer91](https://github.com/abhiaiyer91) in [PR #46](https://github.com/apollographql/graphql-tag/pull/46) addressing [#6](https://github.com/apollographql/graphql-tag/issues/6)
- Added `graphql` as a [peerDependency](https://github.com/apollographql/graphql-tag/commit/ac061dd16440e75c166c85b4bff5ba06c79c9356)
Restore dependence on `graphql` module [abhiaiyer91](https://github.com/abhiaiyer91) in
[PR #46](https://github.com/apollographql/graphql-tag/pull/46) addressing
[#6](https://github.com/apollographql/graphql-tag/issues/6)
* Added `graphql` as a
[peerDependency](https://github.com/apollographql/graphql-tag/commit/ac061dd16440e75c166c85b4bff5ba06c79c9356)
### v1.3.2
- Add typescript definitions for the bundledPrinter [PR #63](https://github.com/apollographql/graphql-tag/pull/63)
* Add typescript definitions for the bundledPrinter [PR #63](https://github.com/apollographql/graphql-tag/pull/63)
### v1.3.1
- Making sure not to log deprecation warnings for internal use of deprecated module [jnwng](https://github.com/jnwng) addressing [#54](https://github.com/apollographql/graphql-tag/issues/54#issuecomment-283301475)
* Making sure not to log deprecation warnings for internal use of deprecated module [jnwng](https://github.com/jnwng)
addressing [#54](https://github.com/apollographql/graphql-tag/issues/54#issuecomment-283301475)
### v1.3.0
- Bump bundled `graphql` packages to v0.9.1 [jnwng](https://github.com/jnwng) in [PR #55](https://github.com/apollographql/graphql-tag/pull/55).
- Deprecate the `graphql/language/parser` and `graphql/language/printer` exports [jnwng](https://github.com/jnwng) in [PR #55](https://github.com/apollographql/graphql-tag/pull/55)
* Bump bundled `graphql` packages to v0.9.1 [jnwng](https://github.com/jnwng) in
[PR #55](https://github.com/apollographql/graphql-tag/pull/55).
* Deprecate the `graphql/language/parser` and `graphql/language/printer` exports [jnwng](https://github.com/jnwng) in
[PR #55](https://github.com/apollographql/graphql-tag/pull/55)
### v1.2.4
Restore Node < 6 compatibility. [DragosRotaru](https://github.com/DragosRotaru) in [PR #41](https://github.com/apollographql/graphql-tag/pull/41) addressing [#39](https://github.com/apollographql/graphql-tag/issues/39)
Restore Node < 6 compatibility. [DragosRotaru](https://github.com/DragosRotaru) in
[PR #41](https://github.com/apollographql/graphql-tag/pull/41) addressing
[#39](https://github.com/apollographql/graphql-tag/issues/39)
### v1.2.1
Fixed an issue with fragment imports. [PR #35](https://github.com/apollostack/graphql-tag/issues/35).

@@ -51,3 +91,4 @@

Added ability to import other GraphQL documents with fragments using `#import` comments. [PR #33](https://github.com/apollostack/graphql-tag/pull/33)
Added ability to import other GraphQL documents with fragments using `#import` comments.
[PR #33](https://github.com/apollostack/graphql-tag/pull/33)

@@ -71,3 +112,3 @@ ### v1.1.2

disableFragmentWarnings()
disableFragmentWarnings();
```

@@ -81,3 +122,3 @@

- Allow embedding fragments inside document strings, as in
* Allow embedding fragments inside document strings, as in

@@ -88,5 +129,5 @@ ```js

const fragment = gql`
fragment Foo on Bar {
field
}
fragment Foo on Bar {
field
}
`;

@@ -99,3 +140,3 @@

${Foo}
`
`;
```

@@ -107,7 +148,7 @@

- Add caching to Webpack loader. [PR #16](https://github.com/apollostack/graphql-tag/pull/16)
* Add caching to Webpack loader. [PR #16](https://github.com/apollostack/graphql-tag/pull/16)
### v0.1.15
- Add Webpack loader to `graphql-tag/loader`.
* Add Webpack loader to `graphql-tag/loader`.

@@ -114,0 +155,0 @@ ### v0.1.14

@@ -45,9 +45,131 @@ "use strict";

const doc = gql`${source}`;
const outputCode = `
let headerCode = `
var doc = ${JSON.stringify(doc)};
doc.loc.source = ${JSON.stringify(doc.loc.source)};
`;
let outputCode = "";
// Allow multiple query/mutation definitions in a file. This parses out dependencies
// at compile time, and then uses those at load time to create minimal query documents
// We cannot do the latter at compile time due to how the #import code works.
let operationCount = doc.definitions.reduce(function(accum, op) {
if (op.kind === "OperationDefinition") {
return accum + 1;
}
return accum;
}, 0);
if (operationCount <= 1) {
outputCode += `
module.exports = doc;
`
} else {
outputCode +=`
// Collect any fragment/type references from a node, adding them to the refs Set
function collectFragmentReferences(node, refs) {
if (node.kind === "FragmentSpread") {
refs.add(node.name.value);
} else if (node.kind === "VariableDefinition") {
var type = node.type;
if (type.kind === "NamedType") {
refs.add(type.name.value);
}
}
if (node.selectionSet) {
node.selectionSet.selections.forEach(function(selection) {
collectFragmentReferences(selection, refs);
});
}
if (node.variableDefinitions) {
node.variableDefinitions.forEach(function(def) {
collectFragmentReferences(def, refs);
});
}
if (node.definitions) {
node.definitions.forEach(function(def) {
collectFragmentReferences(def, refs);
});
}
}
var definitionRefs = {};
(function extractReferences() {
doc.definitions.forEach(function(def) {
if (def.name) {
var refs = new Set();
collectFragmentReferences(def, refs);
definitionRefs[def.name.value] = refs;
}
});
})();
function findOperation(doc, name) {
return doc.definitions.find(function(op) {
return op.name ? op.name.value == name : false;
});
}
function oneQuery(doc, operationName) {
// Copy the DocumentNode, but clear out the definitions
var newDoc = Object.assign({}, doc);
var op = findOperation(doc, operationName);
newDoc.definitions = [op];
// Now, for the operation we're running, find any fragments referenced by
// it or the fragments it references
var opRefs = definitionRefs[operationName] || new Set();
var allRefs = new Set();
var newRefs = new Set(opRefs);
while (newRefs.size > 0) {
var prevRefs = newRefs;
newRefs = new Set();
prevRefs.forEach(function(refName) {
if (!allRefs.has(refName)) {
allRefs.add(refName);
var childRefs = definitionRefs[refName] || new Set();
childRefs.forEach(function(childRef) {
newRefs.add(childRef);
});
}
});
}
allRefs.forEach(function(refName) {
var op = findOperation(doc, refName);
if (op) {
newDoc.definitions.push(op);
}
});
return newDoc;
}
module.exports = doc;
`
for (const op of doc.definitions) {
if (op.kind === "OperationDefinition") {
if (!op.name) {
throw "Query/mutation names are required for a document with multiple definitions";
}
const opName = op.name.value;
outputCode += `
module.exports["${opName}"] = oneQuery(doc, "${opName}");
`
}
}
}
const importOutputCode = expandImports(source, doc);
const allCode = headerCode + os.EOL + importOutputCode + os.EOL + outputCode + os.EOL;
return outputCode + os.EOL + importOutputCode + os.EOL + `module.exports = doc;`;
return allCode;
};
{
"name": "graphql-tag",
"version": "2.5.0",
"version": "2.6.0",
"description": "A JavaScript template literal tag that parses GraphQL queries",

@@ -5,0 +5,0 @@ "main": "./lib/graphql-tag.umd.js",

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