Skip to content

Commit 5459c81

Browse files
committed
fix
1 parent d3a41cd commit 5459c81

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

graphql.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
}
1717
}
1818
}
19-
19+
2020
for (; i < length; i++) {
2121
var obj = arguments[i]
2222
merge(obj)
2323
}
24-
24+
2525
return extended
2626
}
2727

2828
function __unique(array) {
29-
return array.filter( function onlyUnique(value, index, self) {
29+
return array.filter( function onlyUnique(value, index, self) {
3030
return self.indexOf(value) === index;
3131
})
3232
}
33-
33+
3434
function __request(method, url, headers, data, asJson, callback) {
3535
if (asJson) {
3636
var body = JSON.stringify({query: data.query, variables: data.variables});
@@ -70,11 +70,11 @@
7070
req.end()
7171
}
7272
}
73-
73+
7474
function __isTagCall(strings) {
7575
return Object.prototype.toString.call(strings) == '[object Array]' && strings.raw
7676
}
77-
77+
7878
function GraphQLClient(url, options) {
7979
if (!(this instanceof GraphQLClient)) {
8080
var client = new GraphQLClient(url, options, true)
@@ -92,24 +92,24 @@
9292
}
9393
if (!options)
9494
options = {}
95-
95+
9696
if (!options.fragments)
9797
options.fragments = {}
98-
98+
9999
this.options = options
100100
this._fragments = this.buildFragments(options.fragments)
101101
this._sender = this.createSenderFunction(url)
102102
this.createHelpers(this._sender)
103103
}
104-
104+
105105
// "fragment auth.login" will be "fragment auth_login"
106106
FRAGMENT_SEPERATOR = "_"
107-
107+
108108
// The autodeclare keyword.
109109
GraphQLClient.AUTODECLARE_PATTERN = /\(@autodeclare\)|\(@autotype\)/
110-
110+
111111
GraphQLClient.FRAGMENT_PATTERN = /\.\.\.\s*([A-Za-z0-9\.\_]+)/g
112-
112+
113113
// Flattens nested object
114114
/*
115115
* {a: {b: {c: 1, d: 2}}} => {"a.b.c": 1, "a.b.d": 2}
@@ -125,7 +125,7 @@
125125
}
126126
return out
127127
}
128-
128+
129129
// Gets path from object
130130
/*
131131
* {a: {b: {c: 1, d: 2}}}, "a.b.c" => 1
@@ -138,7 +138,7 @@
138138
}
139139
return obj
140140
}
141-
141+
142142
GraphQLClient.prototype.collectFragments = function (query, fragments) {
143143
var that = this
144144
var fragmentRegexp = GraphQLClient.FRAGMENT_PATTERN
@@ -165,7 +165,7 @@
165165
})
166166
return __unique(collectedFragments)
167167
}
168-
168+
169169
GraphQLClient.prototype.processQuery = function (query, fragments) {
170170
var fragmentRegexp = GraphQLClient.FRAGMENT_PATTERN
171171
var collectedFragments = this.collectFragments(query, fragments)
@@ -177,7 +177,7 @@
177177
return !query.match(fragment)
178178
})).join("\n")
179179
}
180-
180+
181181
GraphQLClient.prototype.autoDeclare = function (query, variables) {
182182
var typeMap = {
183183
string: "String",
@@ -198,7 +198,7 @@
198198
return types ? "("+ types +")" : ""
199199
})
200200
}
201-
201+
202202
GraphQLClient.prototype.cleanAutoDeclareAnnotations = function (variables) {
203203
if (!variables) variables = {}
204204
var newVariables = {}
@@ -209,7 +209,7 @@
209209
}
210210
return newVariables
211211
}
212-
212+
213213
GraphQLClient.prototype.buildFragments = function (fragments) {
214214
var that = this
215215
fragments = this.flatten(fragments || {})
@@ -224,11 +224,11 @@
224224
}
225225
return fragmentObject
226226
}
227-
227+
228228
GraphQLClient.prototype.buildQuery = function (query, variables) {
229229
return this.autoDeclare(this.processQuery(query, this._fragments, variables), variables)
230230
}
231-
231+
232232
GraphQLClient.prototype.createSenderFunction = function (url) {
233233
var that = this
234234
return function (query) {
@@ -240,12 +240,12 @@
240240
if (!variables) variables = {}
241241
var fragmentedQuery = that.buildQuery(query, variables)
242242
headers = __extend((that.options.headers||{}), (requestOptions.headers||{}))
243-
243+
244244
return new Promise(function (resolve, reject) {
245245
__request(that.options.method || "post", url, headers, {
246246
query: fragmentedQuery,
247247
variables: that.cleanAutoDeclareAnnotations(variables)
248-
}, !!this.options.asJSON, function (response, status) {
248+
}, !!that.options.asJSON, function (response, status) {
249249
if (status == 200) {
250250
if (response.errors) {
251251
reject(response.errors)
@@ -264,7 +264,7 @@
264264
return caller
265265
}
266266
}
267-
267+
268268
GraphQLClient.prototype.createHelpers = function (sender) {
269269
var that = this
270270
function helper(query) {
@@ -305,15 +305,15 @@
305305
return sender(query, {})
306306
}
307307
}
308-
308+
309309
GraphQLClient.prototype.fragments = function () {
310310
return this._fragments
311311
}
312-
312+
313313
GraphQLClient.prototype.getOptions = function () {
314314
return this.options
315315
}
316-
316+
317317
GraphQLClient.prototype.fragment = function (fragment) {
318318
if (typeof fragment == 'string') {
319319
var _fragment = this._fragments[fragment.replace(/\./g, FRAGMENT_SEPERATOR)]
@@ -327,7 +327,7 @@
327327
return this._fragments
328328
}
329329
}
330-
330+
331331
GraphQLClient.prototype.ql = function (strings) {
332332
var that = this
333333
fragments = Array.prototype.slice.call(arguments, 1)
@@ -343,7 +343,7 @@
343343
query = ((this.__prefix||"") + " " + query + " " + (this.__suffix||"")).trim()
344344
return query
345345
}
346-
346+
347347
;(function (root, factory) {
348348
if (typeof define === 'function' && define.amd) {
349349
define(function () {

graphql.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)