Skip to content

Commit

Permalink
Merge pull request #41 from DragosRotaru/master
Browse files Browse the repository at this point in the history
added use strict; to fix issue #39
  • Loading branch information
jnwng authored Jan 31, 2017
2 parents 682a200 + 8e6016f commit 0efb0b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions loader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

const gql = require('./');

// Takes `source` (the source GraphQL query string)
Expand All @@ -6,7 +8,7 @@ const gql = require('./');
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];
Expand All @@ -25,6 +27,6 @@ module.exports = function(source) {
const doc = gql`${source}`;
const outputCode = `var doc = ${JSON.stringify(doc)};`;
const importOutputCode = expandImports(source, doc);

return outputCode + "\n" + importOutputCode + "\n" + `module.exports = doc;`;
};

0 comments on commit 0efb0b3

Please sign in to comment.