graphql-tag
Advanced tools
Comparing version 0.1.14 to 0.1.15
50
index.js
@@ -5,34 +5,34 @@ var parse = require('./parser').parse; | ||
function stripLoc(doc) { | ||
var docType = Object.prototype.toString.call(doc); | ||
function stripLoc (doc) { | ||
var docType = Object.prototype.toString.call(doc); | ||
if (docType === '[object Array]') { | ||
return doc.map(stripLoc); | ||
} | ||
if (docType === '[object Array]') { | ||
return doc.map(stripLoc); | ||
} | ||
if (docType !== '[object Object]') { | ||
throw new Error('Unexpected input.'); | ||
} | ||
if (docType !== '[object Object]') { | ||
throw new Error('Unexpected input.'); | ||
} | ||
if (doc.loc) { | ||
delete doc.loc; | ||
} | ||
if (doc.loc) { | ||
delete doc.loc; | ||
} | ||
var keys = Object.keys(doc); | ||
var key; | ||
var value; | ||
var valueType; | ||
var keys = Object.keys(doc); | ||
var key; | ||
var value; | ||
var valueType; | ||
for (key in keys) { | ||
if (keys.hasOwnProperty(key)) { | ||
value = doc[keys[key]]; | ||
valueType = Object.prototype.toString.call(value); | ||
for (key in keys) { | ||
if (keys.hasOwnProperty(key)) { | ||
value = doc[keys[key]]; | ||
valueType = Object.prototype.toString.call(value); | ||
if (valueType === '[object Object]' || valueType === '[object Array]') { | ||
doc[keys[key]] = stripLoc(value); | ||
} | ||
} | ||
} | ||
if (valueType === '[object Object]' || valueType === '[object Array]') { | ||
doc[keys[key]] = stripLoc(value); | ||
} | ||
} | ||
} | ||
return doc; | ||
return doc; | ||
} | ||
@@ -39,0 +39,0 @@ |
{ | ||
"name": "graphql-tag", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "A JavaScript template literal tag that parses GraphQL queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -67,2 +67,27 @@ # graphql-tag | ||
### Webpack preprocessing | ||
This package also includes a [webpack loader](https://webpack.github.io/docs/loaders.html). There are many benefits over this approach, which saves GraphQL ASTs processing time on client-side, optimizes bundle size and enable queries to be separated from script over `.graphql` files. | ||
```js | ||
loaders: [ | ||
{ | ||
test: /\.(graphql|gql)$/, | ||
exclude: /node_modules/, | ||
loader: 'graphql-tag/loader' | ||
} | ||
] | ||
``` | ||
then: | ||
```js | ||
import query from './query.graphql'; | ||
console.log(query); | ||
// { | ||
// "kind": "Document", | ||
// ... | ||
``` | ||
### Parser and printer | ||
@@ -69,0 +94,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
186526
11
5310
104