graphqljs-rails 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f6fc4dfe6d26aad4d498a116ec59f4d1107701d
4
- data.tar.gz: fceef4b7e201b89e7345bf92d8f10c6260304ef8
3
+ metadata.gz: b8dcbc11517a11c6193c3ae78da41960b699606a
4
+ data.tar.gz: 574e2fa33a6e727565602d8433d8666713b4ef72
5
5
  SHA512:
6
- metadata.gz: 036fc1147d670c2b4c5415b35df4a48b8cf138fdcb2c17adb714ffd4ce6350ad99949b324b9abbbb9446e9836dc18fec9b303905e73d0ec0842b0ee173c08056
7
- data.tar.gz: c50ff6e5918cddd376119131021d4b2a79aedc56dc88b48a669ee6f870e265962312f3d8d1d07a99f4de4876945d8312d1b64da127a8d7e8de6a968a8e132563
6
+ metadata.gz: 076e1c68cc2114556f7f60744b0f389fbb72427cd892c00a42c338f610dc2ba28482b95a1612a79edea9af9c0f75e63cd4193ef0bc10be3182401c021235bcce
7
+ data.tar.gz: b25c5851d6d955fa9493550b956286f933d369315cf0236ee50bed75ac394350866bcfa116058a71a61d2741098ca9f1918fb0d42ffa1aea3d3b0d5f6947c931
@@ -290,13 +290,13 @@
290
290
  helpers.forEach(function (m) {
291
291
  that[m.method] = function (query, options) {
292
292
  if (that.options.alwaysAutodeclare === true || (options && options.declare === true)) {
293
- return helper.call({prefix: m.type + " (@autodeclare) {", suffix: "}"}, query)
293
+ return helper.call({prefix: m.type + " (@autodeclare) {", suffix: "}"}, query, {})
294
294
  } else {
295
- return helper.call({prefix: m.type, suffix: ""}, query)
295
+ return helper.call({prefix: m.type, suffix: ""}, query, {})
296
296
  }
297
297
  }
298
- that[m.method].run = function (query) {
299
- return that[m.method](query, {})
298
+ that[m.method].run = function (query, options) {
299
+ return that[m.method](query, options)
300
300
  }
301
301
  })
302
302
  this.run = function (query) {
@@ -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(){if(window.XMLHttpRequest)return new window.XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(a){return null}}function c(c,d,e,f,g){var h="query="+escape(f.query)+"&variables="+escape(JSON.stringify(f.variables));if("undefined"!=typeof XMLHttpRequest){var i=b();i.open(c,d,!0),i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.setRequestHeader("Accept","application/json");for(var j in e)i.setRequestHeader(j,e[j]);i.onerror=function(){g(i,i.status)},i.onload=function(){g(JSON.parse(i.responseText),i.status)},i.send(h)}else if("function"==typeof require){var k=require("http"),l=require("url"),m=l.parse(d),n=k.request({protocol:m.protocol,hostname:m.hostname,port:m.port,path:m.path,method:"POST",headers:a({"Content-type":"application/x-www-form-urlencoded",Accept:"application/json"},e)},function(a){var b="";a.setEncoding("utf8"),a.on("data",function(a){b+=a}),a.on("end",function(){g(JSON.parse(b),a.statusCode)})});n.write(h),n.end()}}function d(a){return"[object Array]"==Object.prototype.toString.call(a)&&a.raw}function e(a,b){if(!(this instanceof e)){var c=new e(a,b,!0),d=c._sender;for(var f in c)"function"==typeof c[f]&&(d[f]=c[f].bind(c),c[f].declare&&(d[f].declare=c[f].declare.bind(c)),c[f].run&&(d[f].run=c[f].run.bind(c)));return d}if(arguments[2]!==!0)throw"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="_",e.AUTODECLARE_PATTERN=/\(@autodeclare\)|\(@autotype\)/,e.FRAGMENT_PATTERN=/\.\.\.\s*([A-Za-z0-9\.\_]+)/g,e.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},e.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"Fragment "+b+" not found";return d},e.prototype.collectFragments=function(a,b){var c=this,d=e.FRAGMENT_PATTERN,f=[];return(a.match(d)||[]).forEach(function(a){var e=a.replace(d,function(a,b){return b}),a=c.fragmentPath(b,e);if(a){var g=new RegExp(d.source.replace(/\((.*)\)/,e));if(a.match(g))throw"Recursive fragment usage detected on "+e+".";f.push(a);var h=f.filter(function(a){return a.match(new RegExp("fragment "+e))});h.length>0&&d.test(a)&&c.collectFragments(a,b).forEach(function(a){f.unshift(a)})}}),f},e.prototype.processQuery=function(a,b){var c=e.FRAGMENT_PATTERN,d=this.collectFragments(a,b);return a=a.replace(c,function(a,b){return"... "+b.split(".").join(FRAGMENT_SEPERATOR)}),[a].concat(d.filter(function(b){return!a.match(b)})).join("\n")},e.prototype.autoDeclare=function(a,b){var c={string:"String",number:"Int","boolean":"Boolean"};return a.replace(e.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+")":""})},e.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},e.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},e.prototype.buildQuery=function(a,b){return this.autoDeclare(this.processQuery(a,this._fragments,b),b)},e.prototype.createSenderFunction=function(b){var e=this;return function(f){if(d(f))return e.run(e.ql.apply(e,arguments));var g=function(d,g){g||(g={}),d||(d={});var h=e.buildQuery(f,d);return headers=a(e.options.headers||{},g.headers||{}),new Promise(function(a,f){c(e.options.method||"post",b,headers,{query:h,variables:e.cleanAutoDeclareAnnotations(d)},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}},e.prototype.createHelpers=function(a){function b(b){if(d(b)){c.__prefix=this.prefix,c.__suffix=this.suffix;var e=c.run(c.ql.apply(c,arguments));return c.__prefix="",c.__suffix="",e}var f=a(this.prefix+" "+b+" "+this.suffix);return arguments.length>1?f.apply(null,Array.prototype.slice.call(arguments,1)):f}var c=this,e=[{method:"mutate",type:"mutation"},{method:"query",type:"query"},{method:"subscribe",type:"subscription"}];e.forEach(function(a){c[a.method]=function(d,e){return c.options.alwaysAutodeclare===!0||e&&e.declare===!0?b.call({prefix:a.type+" (@autodeclare) {",suffix:"}"},d):b.call({prefix:a.type,suffix:""},d)},c[a.method].run=function(b){return c[a.method](b,{})}}),this.run=function(b){return a(b,{})}},e.prototype.fragments=function(){return this._fragments},e.prototype.getOptions=function(){return this.options},e.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},e.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(e)}):"object"==typeof module&&module.exports?module.exports=b(a.GraphQLClient):a.graphql=b(a.GraphQLClient)}(this,function(){return e})}();
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(){if(window.XMLHttpRequest)return new window.XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(a){return null}}function c(c,d,e,f,g){var h="query="+escape(f.query)+"&variables="+escape(JSON.stringify(f.variables));if("undefined"!=typeof XMLHttpRequest){var i=b();i.open(c,d,!0),i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.setRequestHeader("Accept","application/json");for(var j in e)i.setRequestHeader(j,e[j]);i.onerror=function(){g(i,i.status)},i.onload=function(){g(JSON.parse(i.responseText),i.status)},i.send(h)}else if("function"==typeof require){var k=require("http"),l=require("url"),m=l.parse(d),n=k.request({protocol:m.protocol,hostname:m.hostname,port:m.port,path:m.path,method:"POST",headers:a({"Content-type":"application/x-www-form-urlencoded",Accept:"application/json"},e)},function(a){var b="";a.setEncoding("utf8"),a.on("data",function(a){b+=a}),a.on("end",function(){g(JSON.parse(b),a.statusCode)})});n.write(h),n.end()}}function d(a){return"[object Array]"==Object.prototype.toString.call(a)&&a.raw}function e(a,b){if(!(this instanceof e)){var c=new e(a,b,!0),d=c._sender;for(var f in c)"function"==typeof c[f]&&(d[f]=c[f].bind(c),c[f].declare&&(d[f].declare=c[f].declare.bind(c)),c[f].run&&(d[f].run=c[f].run.bind(c)));return d}if(arguments[2]!==!0)throw"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="_",e.AUTODECLARE_PATTERN=/\(@autodeclare\)|\(@autotype\)/,e.FRAGMENT_PATTERN=/\.\.\.\s*([A-Za-z0-9\.\_]+)/g,e.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},e.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"Fragment "+b+" not found";return d},e.prototype.collectFragments=function(a,b){var c=this,d=e.FRAGMENT_PATTERN,f=[];return(a.match(d)||[]).forEach(function(a){var e=a.replace(d,function(a,b){return b}),a=c.fragmentPath(b,e);if(a){var g=new RegExp(d.source.replace(/\((.*)\)/,e));if(a.match(g))throw"Recursive fragment usage detected on "+e+".";f.push(a);var h=f.filter(function(a){return a.match(new RegExp("fragment "+e))});h.length>0&&d.test(a)&&c.collectFragments(a,b).forEach(function(a){f.unshift(a)})}}),f},e.prototype.processQuery=function(a,b){var c=e.FRAGMENT_PATTERN,d=this.collectFragments(a,b);return a=a.replace(c,function(a,b){return"... "+b.split(".").join(FRAGMENT_SEPERATOR)}),[a].concat(d.filter(function(b){return!a.match(b)})).join("\n")},e.prototype.autoDeclare=function(a,b){var c={string:"String",number:"Int","boolean":"Boolean"};return a.replace(e.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+")":""})},e.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},e.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},e.prototype.buildQuery=function(a,b){return this.autoDeclare(this.processQuery(a,this._fragments,b),b)},e.prototype.createSenderFunction=function(b){var e=this;return function(f){if(d(f))return e.run(e.ql.apply(e,arguments));var g=function(d,g){g||(g={}),d||(d={});var h=e.buildQuery(f,d);return headers=a(e.options.headers||{},g.headers||{}),new Promise(function(a,f){c(e.options.method||"post",b,headers,{query:h,variables:e.cleanAutoDeclareAnnotations(d)},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}},e.prototype.createHelpers=function(a){function b(b){if(d(b)){c.__prefix=this.prefix,c.__suffix=this.suffix;var e=c.run(c.ql.apply(c,arguments));return c.__prefix="",c.__suffix="",e}var f=a(this.prefix+" "+b+" "+this.suffix);return arguments.length>1?f.apply(null,Array.prototype.slice.call(arguments,1)):f}var c=this,e=[{method:"mutate",type:"mutation"},{method:"query",type:"query"},{method:"subscribe",type:"subscription"}];e.forEach(function(a){c[a.method]=function(d,e){return c.options.alwaysAutodeclare===!0||e&&e.declare===!0?b.call({prefix:a.type+" (@autodeclare) {",suffix:"}"},d,{}):b.call({prefix:a.type,suffix:""},d,{})},c[a.method].run=function(b,d){return c[a.method](b,d)}}),this.run=function(b){return a(b,{})}},e.prototype.fragments=function(){return this._fragments},e.prototype.getOptions=function(){return this.options},e.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},e.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(e)}):"object"==typeof module&&module.exports?module.exports=b(a.GraphQLClient):a.graphql=b(a.GraphQLClient)}(this,function(){return e})}();
@@ -1,5 +1,5 @@
1
1
  module GraphQLJS
2
2
  module Rails
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
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.0
4
+ version: 0.4.1
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-17 00:00:00.000000000 Z
11
+ date: 2017-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties