Skip to content

Commit

Permalink
Revert "Merge pull request apollographql#46 from apollographql/ParseP…
Browse files Browse the repository at this point in the history
…rint"

This reverts commit f7cf4c2, reversing
changes made to c5332e0.
  • Loading branch information
jnwng committed Feb 28, 2017
1 parent 41b6076 commit 7413172
Show file tree
Hide file tree
Showing 6 changed files with 3,535 additions and 26 deletions.
33 changes: 11 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var parser = require('graphql/language/parser');

var parse = parser.parse;
var parse = require('./parser').parse;

// Strip insignificant whitespace
// Note that this could do a lot more, such as reorder fields etc.
Expand Down Expand Up @@ -40,7 +38,8 @@ function processFragments(ast) {
var sourceKey = cacheKeyFromLoc(fragmentDefinition.loc);

// We know something about this fragment
if (fragmentSourceMap.hasOwnProperty(fragmentName) && !fragmentSourceMap[fragmentName][sourceKey]) {
if (fragmentSourceMap.hasOwnProperty(fragmentName) &&
!fragmentSourceMap[fragmentName][sourceKey]) {

// this is a problem because the app developer is trying to register another fragment with
// the same name as one previously registered. So, we tell them about it.
Expand Down Expand Up @@ -74,13 +73,11 @@ function disableFragmentWarnings() {
printFragmentWarnings = false;
}

function stripLoc(doc, removeLocAtThisLevel) {
function stripLoc (doc, removeLocAtThisLevel) {
var docType = Object.prototype.toString.call(doc);

if (docType === '[object Array]') {
return doc.map(function (d) {
return stripLoc(d, removeLocAtThisLevel);
});
return doc.map(function(d) { return stripLoc(d, removeLocAtThisLevel); });
}

if (docType !== '[object Object]') {
Expand All @@ -93,12 +90,6 @@ function stripLoc(doc, removeLocAtThisLevel) {
delete doc.loc;
}

// https://github.com/apollographql/graphql-tag/issues/40
if (doc.loc) {
delete doc.loc.startToken;
delete doc.loc.endToken;
}

var keys = Object.keys(doc);
var key;
var value;
Expand Down Expand Up @@ -149,13 +140,13 @@ function gql(/* arguments */) {
var result = literals[0];

for (var i = 1; i < args.length; i++) {
if (args[i] && args[i].kind && args[i].kind === 'Document') {
result += args[i].loc.source.body;
} else {
result += args[i];
}
if (args[i] && args[i].kind && args[i].kind === 'Document') {
result += args[i].loc.source.body;
} else {
result += args[i];
}

result += literals[i];
result += literals[i];
}

return parseDocument(result);
Expand All @@ -165,7 +156,5 @@ function gql(/* arguments */) {
gql.default = gql;
gql.resetCaches = resetCaches;
gql.disableFragmentWarnings = disableFragmentWarnings;
gql.print = require('graphql/language/printer');
gql.parse = parse;

module.exports = gql;
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"chai": "^3.5.0",
"graphql": "^0.9.1",
"graphql": "^0.9.0",
"mocha": "^2.5.3",
"webpack": "^1.13.1"
},
"peerDependencies": {
"graphql": "^0.9.x"
}
}
Loading

0 comments on commit 7413172

Please sign in to comment.