graphqljs-rails 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f51792a33f2ea91c0213ca2fa2bb45dbe0d31b85
|
4
|
+
data.tar.gz: 667d91c17943cd90ed0d168beb4bdd1f64f7997b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f342192505401aa8fea582019cd8cb54196e91c2eee8d99b1b1fec7444d3ebc03a3e289df9f9832d01f06633be553fb36e12f2ad87655f974c2ce9439a49a8
|
7
|
+
data.tar.gz: a0781279a5a7ae43dd4502086802431adcba063d63c9f2adcc78311ae5a83af138f06716d7b0ba09f204acec1c4ea43c52832fda324fae789edfa6915c181793
|
@@ -267,7 +267,7 @@
|
|
267
267
|
return result
|
268
268
|
}
|
269
269
|
var caller = sender(this.prefix + " " + query + " " + this.suffix)
|
270
|
-
if (arguments.length > 1) {
|
270
|
+
if (arguments.length > 1 && arguments[1] != null) {
|
271
271
|
return caller.apply(null, Array.prototype.slice.call(arguments, 1))
|
272
272
|
} else {
|
273
273
|
return caller
|
@@ -280,11 +280,11 @@
|
|
280
280
|
{method: 'subscribe', type: 'subscription'}
|
281
281
|
]
|
282
282
|
helpers.forEach(function (m) {
|
283
|
-
that[m.method] = function (query, options) {
|
283
|
+
that[m.method] = function (query, variables, options) {
|
284
284
|
if (that.options.alwaysAutodeclare === true || (options && options.declare === true)) {
|
285
|
-
return helper.call({prefix: m.type + " (@autodeclare) {", suffix: "}"}, query)
|
285
|
+
return helper.call({prefix: m.type + " (@autodeclare) {", suffix: "}"}, query, variables)
|
286
286
|
} else {
|
287
|
-
return helper.call({prefix: m.type, suffix: ""}, query)
|
287
|
+
return helper.call({prefix: m.type, suffix: ""}, query, variables)
|
288
288
|
}
|
289
289
|
}
|
290
290
|
that[m.method].run = function (query, options) {
|
@@ -1 +1 @@
|
|
1
|
-
!function(){function a(){var b={},c=!1,d=0,e=arguments.length;"[object Boolean]"==Object.prototype.toString.call(arguments[0])&&(c=arguments[0],d++);for(var f=function(d){for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(c&&"[object Object]"==Object.prototype.toString.call(d[e])?b[e]=a(!0,b[e],d[e]):b[e]=d[e])};e>d;d++){var g=arguments[d];f(g)}return b}function b(
|
1
|
+
!function(){function a(){var b={},c=!1,d=0,e=arguments.length;"[object Boolean]"==Object.prototype.toString.call(arguments[0])&&(c=arguments[0],d++);for(var f=function(d){for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(c&&"[object Object]"==Object.prototype.toString.call(d[e])?b[e]=a(!0,b[e],d[e]):b[e]=d[e])};e>d;d++){var g=arguments[d];f(g)}return b}function b(b,c,d,e,f){var g="query="+escape(e.query)+"&variables="+escape(JSON.stringify(e.variables));if("undefined"!=typeof XMLHttpRequest){var h=new XMLHttpRequest;h.open(b,c,!0),h.setRequestHeader("Content-type","application/x-www-form-urlencoded"),h.setRequestHeader("Accept","application/json");for(var i in d)h.setRequestHeader(i,d[i]);h.onerror=function(){f(h,h.status)},h.onload=function(){f(JSON.parse(h.responseText),h.status)},h.send(g)}else if("function"==typeof require){var j=require("http"),k=require("url"),l=k.parse(c),m=j.request({protocol:l.protocol,hostname:l.hostname,port:l.port,path:l.path,method:"POST",headers:a({"Content-type":"application/x-www-form-urlencoded",Accept:"application/json"},d)},function(a){var b="";a.setEncoding("utf8"),a.on("data",function(a){b+=a}),a.on("end",function(){f(JSON.parse(b),a.statusCode)})});m.write(g),m.end()}}function c(a){return"[object Array]"==Object.prototype.toString.call(a)&&a.raw}function d(a,b){if(!(this instanceof d)){var c=new d(a,b,!0),e=c._sender;for(var f in c)"function"==typeof c[f]&&(e[f]=c[f].bind(c),c[f].declare&&(e[f].declare=c[f].declare.bind(c)),c[f].run&&(e[f].run=c[f].run.bind(c)));return e}if(arguments[2]!==!0)throw new Error("You cannot create GraphQLClient instance. Please call GraphQLClient as function.");b||(b={}),b.fragments||(b.fragments={}),this.options=b,this._fragments=this.buildFragments(b.fragments),this._sender=this.createSenderFunction(a),this.createHelpers(this._sender)}FRAGMENT_SEPERATOR="_",d.AUTODECLARE_PATTERN=/\(@autodeclare\)|\(@autotype\)/,d.FRAGMENT_PATTERN=/\.\.\.\s*([A-Za-z0-9\.\_]+)/g,d.prototype.flatten=function(a){var b,c=arguments[1]||"",d=arguments[2]||{};for(b in a)a.hasOwnProperty(b)&&("object"==typeof a[b]?this.flatten(a[b],c+b+FRAGMENT_SEPERATOR,d):d[c+b]=a[b]);return d},d.prototype.fragmentPath=function(a,b){var c=new Function("fragments","return fragments."+b.replace(/\./g,FRAGMENT_SEPERATOR)),d=c(a);if("on"!=b&&(!d||"string"!=typeof d))throw new Error("Fragment "+b+" not found");return d},d.prototype.collectFragments=function(a,b){var c=this,e=d.FRAGMENT_PATTERN,f=[];return(a.match(e)||[]).forEach(function(a){var d=a.replace(e,function(a,b){return b}),a=c.fragmentPath(b,d);if(a){var g=new RegExp(e.source.replace(/\((.*)\)/,d));if(a.match(g))throw new Error("Recursive fragment usage detected on "+d+".");f.push(a);var h=f.filter(function(a){return a.match(new RegExp("fragment "+d))});h.length>0&&e.test(a)&&c.collectFragments(a,b).forEach(function(a){f.unshift(a)})}}),f},d.prototype.processQuery=function(a,b){var c=d.FRAGMENT_PATTERN,e=this.collectFragments(a,b);return a=a.replace(c,function(a,b){return"... "+b.split(".").join(FRAGMENT_SEPERATOR)}),[a].concat(e.filter(function(b){return!a.match(b)})).join("\n")},d.prototype.autoDeclare=function(a,b){var c={string:"String",number:"Int","boolean":"Boolean"};return a.replace(d.AUTODECLARE_PATTERN,function(){var a=[];for(var d in b){var e=b[d],f=d.split("!"),g=f[1]||c[typeof e];g&&a.push("$"+f[0]+": "+g+"!")}return a=a.join(", "),a?"("+a+")":""})},d.prototype.cleanAutoDeclareAnnotations=function(a){a||(a={});var b={};for(var c in a){var d=a[c],e=c.split("!");b[e[0]]=d}return b},d.prototype.buildFragments=function(a){var b=this;a=this.flatten(a||{});var c={};for(var d in a){var e=a[d];"object"==typeof e?c[d]=b.buildFragments(e):c[d]="\nfragment "+d+" "+e}return c},d.prototype.buildQuery=function(a,b){return this.autoDeclare(this.processQuery(a,this._fragments,b),b)},d.prototype.createSenderFunction=function(d){var e=this;return function(f){if(c(f))return e.run(e.ql.apply(e,arguments));var g=function(c,g){g||(g={}),c||(c={});var h=e.buildQuery(f,c);return headers=a(e.options.headers||{},g.headers||{}),new Promise(function(a,f){b(e.options.method||"post",d,headers,{query:h,variables:e.cleanAutoDeclareAnnotations(c)},function(b,c){200==c?b.errors?f(b.errors):b.data&&a(b.data):f(b)})})};return arguments.length>1?g.apply(null,Array.prototype.slice.call(arguments,1)):g}},d.prototype.createHelpers=function(a){function b(b){if(c(b)){d.__prefix=this.prefix,d.__suffix=this.suffix;var e=d.run(d.ql.apply(d,arguments));return d.__prefix="",d.__suffix="",e}var f=a(this.prefix+" "+b+" "+this.suffix);return arguments.length>1&&null!=arguments[1]?f.apply(null,Array.prototype.slice.call(arguments,1)):f}var d=this,e=[{method:"mutate",type:"mutation"},{method:"query",type:"query"},{method:"subscribe",type:"subscription"}];e.forEach(function(a){d[a.method]=function(c,e,f){return d.options.alwaysAutodeclare===!0||f&&f.declare===!0?b.call({prefix:a.type+" (@autodeclare) {",suffix:"}"},c,e):b.call({prefix:a.type,suffix:""},c,e)},d[a.method].run=function(b,c){return d[a.method](b,c)({})}}),this.run=function(b){return a(b,{})}},d.prototype.fragments=function(){return this._fragments},d.prototype.getOptions=function(){return this.options},d.prototype.fragment=function(b){if("string"==typeof b){var c=this._fragments[b.replace(/\./g,FRAGMENT_SEPERATOR)];if(!c)throw"Fragment "+b+" not found!";return c.trim()}return this.options.fragments=a(!0,this.options.fragments,b),this._fragments=this.buildFragments(this.options.fragments),this._fragments},d.prototype.ql=function(a){fragments=Array.prototype.slice.call(arguments,1),fragments=fragments.map(function(a){return"string"==typeof a?a.match(/fragment\s+([^\s]*)\s/)[1]:void 0});var b="string"==typeof a?a:a.reduce(function(a,b,c){return a+fragments[c-1]+b});return b=this.buildQuery(b),b=((this.__prefix||"")+" "+b+" "+(this.__suffix||"")).trim()},function(a,b){"function"==typeof define&&define.amd?define(function(){return a.graphql=b(d)}):"object"==typeof module&&module.exports?module.exports=b(a.GraphQLClient):a.graphql=b(a.GraphQLClient)}(this,function(){return d})}();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphqljs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fatih Kadir Akın
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|