graphqljs-rails 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +22 -0
- data/Rakefile +17 -0
- data/app/assets/javascripts/graphql.js +312 -0
- data/app/assets/javascripts/graphql.min.js +1 -0
- data/graphqljs-rails.gemspec +26 -0
- data/lib/graphqljs/rails.rb +8 -0
- data/lib/graphqljs/rails/version.rb +5 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9309a2cf6087b9f0f529f061d242395a82fbbfc6
|
4
|
+
data.tar.gz: 859314eb6cb84de2aa8ad5418e91c290168b2dd2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22ef99d4bc6fefcfaf9c6fbb95af1f6b157e3aee1aae7a5470cd56b9b9efc5c7c34ab467398e1db074109dff7439d324b1939b8e78c4658400ec9b488bf877e3
|
7
|
+
data.tar.gz: 18cd5720bd59953bcfabb8d6d6c46000a292cf1991f8c3bc50201c11b9b8243fbe33a97d33073597aad7d4462bc72900a7fd46ae1c64acf301fe1ad8e0fc1efe
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Fatih Kadir Akın
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# GraphQL.js for Rails
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'graphqljs-rails', '<version>'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
And install it to your `application.js`:
|
16
|
+
|
17
|
+
//= require graphql
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
22
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
task :update do
|
5
|
+
sh("rm -rf ./tmp")
|
6
|
+
sh("git clone git@github.com:f/graphql.js ./tmp/graphql.js")
|
7
|
+
sh("mv -f ./tmp/graphql.js/*.js ./app/assets/javascripts/")
|
8
|
+
js_version = JSON.parse(File.read("./tmp/graphql.js/package.json"))["version"]
|
9
|
+
version_file = File.read("lib/graphqljs/rails/version.rb").gsub(/VERSION\s*=.*$/, "VERSION = \"#{js_version}\"")
|
10
|
+
File.write("lib/graphqljs/rails/version.rb", version_file)
|
11
|
+
sh("rm -rf ./tmp")
|
12
|
+
sh("git add -A")
|
13
|
+
sh("git commit -m v#{js_version}")
|
14
|
+
sh("git tag v#{js_version}")
|
15
|
+
sh("git push origin master --tags")
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,312 @@
|
|
1
|
+
(function () {
|
2
|
+
function __extend() {
|
3
|
+
var extended = {}, deep = false, i = 0, length = arguments.length
|
4
|
+
if (Object.prototype.toString.call( arguments[0] ) == '[object Boolean]') {
|
5
|
+
deep = arguments[0]
|
6
|
+
i++
|
7
|
+
}
|
8
|
+
var merge = function (obj) {
|
9
|
+
for (var prop in obj) {
|
10
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
11
|
+
if (deep && Object.prototype.toString.call(obj[prop]) == '[object Object]') {
|
12
|
+
extended[prop] = __extend(true, extended[prop], obj[prop])
|
13
|
+
} else {
|
14
|
+
extended[prop] = obj[prop]
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
for (; i < length; i++) {
|
21
|
+
var obj = arguments[i]
|
22
|
+
merge(obj)
|
23
|
+
}
|
24
|
+
|
25
|
+
return extended
|
26
|
+
}
|
27
|
+
|
28
|
+
function __request(method, url, headers, data, callback) {
|
29
|
+
var xhr = new XMLHttpRequest()
|
30
|
+
xhr.open(method, url, true)
|
31
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
|
32
|
+
xhr.setRequestHeader('Accept', 'application/json')
|
33
|
+
for (var key in headers) {
|
34
|
+
xhr.setRequestHeader(key, headers[key])
|
35
|
+
}
|
36
|
+
xhr.onerror = function () {
|
37
|
+
callback(xhr, xhr.status)
|
38
|
+
}
|
39
|
+
xhr.onload = function () {
|
40
|
+
callback(JSON.parse(xhr.responseText), xhr.status)
|
41
|
+
}
|
42
|
+
xhr.send("query=" + escape(data.query) + "&variables=" + escape(JSON.stringify(data.variables)))
|
43
|
+
}
|
44
|
+
|
45
|
+
function __isTagCall(strings) {
|
46
|
+
return Object.prototype.toString.call(strings) == '[object Array]' && strings.raw
|
47
|
+
}
|
48
|
+
|
49
|
+
function GraphQLClient(url, options) {
|
50
|
+
if (!(this instanceof GraphQLClient)) {
|
51
|
+
var client = new GraphQLClient(url, options, true)
|
52
|
+
var _lazy = client._sender
|
53
|
+
for (var m in client) {
|
54
|
+
if (typeof client[m] == 'function') {
|
55
|
+
_lazy[m] = client[m].bind(client)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
return _lazy
|
59
|
+
} else if (arguments[2] !== true) {
|
60
|
+
throw "You cannot create GraphQLClient instance. Please call GraphQLClient as function."
|
61
|
+
}
|
62
|
+
if (!options)
|
63
|
+
options = {}
|
64
|
+
|
65
|
+
if (!options.fragments)
|
66
|
+
options.fragments = {}
|
67
|
+
|
68
|
+
this.options = options
|
69
|
+
this._fragments = this.buildFragments(options.fragments)
|
70
|
+
this._sender = this.createSenderFunction(url)
|
71
|
+
this.createHelpers(this._sender)
|
72
|
+
}
|
73
|
+
|
74
|
+
// "fragment auth.login" will be "fragment auth_login"
|
75
|
+
FRAGMENT_SEPERATOR = "_"
|
76
|
+
|
77
|
+
// The autotype keyword.
|
78
|
+
GraphQLClient.AUTOTYPE_PATTERN = /\(@autotype\)/
|
79
|
+
|
80
|
+
GraphQLClient.FRAGMENT_PATTERN = /\.\.\.\s*([A-Za-z0-9\.\_]+)/g
|
81
|
+
|
82
|
+
// Flattens nested object
|
83
|
+
/*
|
84
|
+
* {a: {b: {c: 1, d: 2}}} => {"a.b.c": 1, "a.b.d": 2}
|
85
|
+
*/
|
86
|
+
GraphQLClient.prototype.flatten = function (object) {
|
87
|
+
var prefix = arguments[1] || "", out = arguments[2] || {}, name
|
88
|
+
for (name in object) {
|
89
|
+
if (object.hasOwnProperty(name)) {
|
90
|
+
typeof object[name] == "object"
|
91
|
+
? this.flatten(object[name], prefix + name + FRAGMENT_SEPERATOR, out)
|
92
|
+
: out[prefix + name] = object[name]
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return out
|
96
|
+
}
|
97
|
+
|
98
|
+
// Gets path from object
|
99
|
+
/*
|
100
|
+
* {a: {b: {c: 1, d: 2}}}, "a.b.c" => 1
|
101
|
+
*/
|
102
|
+
GraphQLClient.prototype.fragmentPath = function (fragments, path) {
|
103
|
+
var getter = new Function("fragments", "return fragments." + path.replace(/\./g, FRAGMENT_SEPERATOR))
|
104
|
+
var obj = getter(fragments)
|
105
|
+
if (path != "on" && (!obj || typeof obj != "string")) {
|
106
|
+
throw "Fragment " + path + " not found"
|
107
|
+
}
|
108
|
+
return obj
|
109
|
+
}
|
110
|
+
|
111
|
+
GraphQLClient.prototype.collectFragments = function (query, fragments) {
|
112
|
+
var that = this
|
113
|
+
var fragmentRegexp = GraphQLClient.FRAGMENT_PATTERN
|
114
|
+
var collectedFragments = []
|
115
|
+
;(query.match(fragmentRegexp)||[]).forEach(function (fragment) {
|
116
|
+
var path = fragment.replace(fragmentRegexp, function (_, $m) {return $m})
|
117
|
+
var fragment = that.fragmentPath(fragments, path)
|
118
|
+
var pathRegexp = new RegExp(fragmentRegexp.source.replace(/\((.*)\)/, path))
|
119
|
+
if (fragment.match(pathRegexp)) {
|
120
|
+
throw "Recursive fragment usage detected on " + path + "."
|
121
|
+
}
|
122
|
+
collectedFragments.push(fragment)
|
123
|
+
// Collect sub fragments
|
124
|
+
if (collectedFragments.filter(function (alreadyCollected) { return alreadyCollected.match(new RegExp("fragment " + path)) }).length > 0 && fragmentRegexp.test(fragment)) {
|
125
|
+
that.collectFragments(fragment, fragments).forEach(function (fragment) {
|
126
|
+
collectedFragments.unshift(fragment)
|
127
|
+
})
|
128
|
+
}
|
129
|
+
})
|
130
|
+
return collectedFragments
|
131
|
+
}
|
132
|
+
|
133
|
+
GraphQLClient.prototype.processQuery = function (query, fragments) {
|
134
|
+
var fragmentRegexp = GraphQLClient.FRAGMENT_PATTERN
|
135
|
+
var collectedFragments = this.collectFragments(query, fragments)
|
136
|
+
query = query.replace(fragmentRegexp, function (_, $m) {
|
137
|
+
return "... " + $m.split(".").join(FRAGMENT_SEPERATOR)
|
138
|
+
})
|
139
|
+
return [query].concat(collectedFragments.filter(function (fragment) {
|
140
|
+
// Remove already used fragments
|
141
|
+
return !query.match(fragment)
|
142
|
+
})).join("\n")
|
143
|
+
}
|
144
|
+
|
145
|
+
GraphQLClient.prototype.autoType = function (query, variables) {
|
146
|
+
var typeMap = {
|
147
|
+
string: "String",
|
148
|
+
number: "Int",
|
149
|
+
boolean: "Boolean"
|
150
|
+
}
|
151
|
+
return query.replace(GraphQLClient.AUTOTYPE_PATTERN, function () {
|
152
|
+
var types = []
|
153
|
+
for (var key in variables) {
|
154
|
+
var value = variables[key]
|
155
|
+
var keyAndType = key.split("!")
|
156
|
+
var type = (keyAndType[1] || typeMap[typeof(value)])
|
157
|
+
if (type) {
|
158
|
+
types.push("$" + keyAndType[0] + ": " + type + "!")
|
159
|
+
}
|
160
|
+
}
|
161
|
+
types = types.join(", ")
|
162
|
+
return "("+ types +")"
|
163
|
+
})
|
164
|
+
}
|
165
|
+
|
166
|
+
GraphQLClient.prototype.cleanAutoTypeAnnotations = function (variables) {
|
167
|
+
if (!variables) variables = {}
|
168
|
+
var newVariables = {}
|
169
|
+
for (var key in variables) {
|
170
|
+
var value = variables[key]
|
171
|
+
var keyAndType = key.split("!")
|
172
|
+
newVariables[keyAndType[0]] = value
|
173
|
+
}
|
174
|
+
return newVariables
|
175
|
+
}
|
176
|
+
|
177
|
+
GraphQLClient.prototype.buildFragments = function (fragments) {
|
178
|
+
var that = this
|
179
|
+
fragments = this.flatten(fragments || {})
|
180
|
+
var fragmentObject = {}
|
181
|
+
for (var name in fragments) {
|
182
|
+
var fragment = fragments[name]
|
183
|
+
if (typeof fragment == "object") {
|
184
|
+
fragmentObject[name] = that.buildFragments(fragment)
|
185
|
+
} else {
|
186
|
+
fragmentObject[name] = "\nfragment " + name + " " + fragment
|
187
|
+
}
|
188
|
+
}
|
189
|
+
return fragmentObject
|
190
|
+
}
|
191
|
+
|
192
|
+
GraphQLClient.prototype.buildQuery = function (query, variables) {
|
193
|
+
return this.autoType(this.processQuery(query, this._fragments, variables), variables)
|
194
|
+
}
|
195
|
+
|
196
|
+
GraphQLClient.prototype.createSenderFunction = function (url) {
|
197
|
+
var that = this
|
198
|
+
return function (query) {
|
199
|
+
if (__isTagCall(query)) {
|
200
|
+
return that.run(that.ql.apply(that, arguments))
|
201
|
+
}
|
202
|
+
var caller = function (variables, requestOptions) {
|
203
|
+
if (!requestOptions) requestOptions = {}
|
204
|
+
if (!variables) variables = {}
|
205
|
+
var fragmentedQuery = that.buildQuery(query, variables)
|
206
|
+
headers = __extend((that.options.headers||{}), (requestOptions.headers||{}))
|
207
|
+
|
208
|
+
return new Promise(function (resolve, reject) {
|
209
|
+
__request(that.options.method || "post", url, headers, {
|
210
|
+
query: fragmentedQuery,
|
211
|
+
variables: that.cleanAutoTypeAnnotations(variables)
|
212
|
+
}, function (response, status) {
|
213
|
+
if (status == 200) {
|
214
|
+
if (response.errors) {
|
215
|
+
reject(response.errors)
|
216
|
+
} else if (response.data) {
|
217
|
+
resolve(response.data)
|
218
|
+
}
|
219
|
+
} else {
|
220
|
+
reject(response)
|
221
|
+
}
|
222
|
+
})
|
223
|
+
})
|
224
|
+
}
|
225
|
+
if (arguments.length > 1) {
|
226
|
+
return caller.apply(null, Array.prototype.slice.call(arguments, 1))
|
227
|
+
}
|
228
|
+
return caller
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
GraphQLClient.prototype.createHelpers = function (sender) {
|
233
|
+
var that = this
|
234
|
+
function helper(query) {
|
235
|
+
if (__isTagCall(query)) {
|
236
|
+
that.__prefix = this.prefix
|
237
|
+
var result = that.run(that.ql.apply(that, arguments))
|
238
|
+
that.__prefix = ""
|
239
|
+
return result
|
240
|
+
}
|
241
|
+
var caller = sender(this.prefix + " " + query)
|
242
|
+
if (arguments.length > 1) {
|
243
|
+
return caller.apply(null, Array.prototype.slice.call(arguments, 1))
|
244
|
+
} else {
|
245
|
+
return caller
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
this.mutate = helper.bind({prefix: "mutation"})
|
250
|
+
this.query = helper.bind({prefix: "query"})
|
251
|
+
this.subscribe = helper.bind({prefix: "subscription"})
|
252
|
+
|
253
|
+
var helperMethods = ['mutate', 'query', 'subscribe']
|
254
|
+
helperMethods.forEach(function (m) {
|
255
|
+
that[m].run = function (query) {
|
256
|
+
return that[m](query, {})
|
257
|
+
}
|
258
|
+
})
|
259
|
+
this.run = function (query) {
|
260
|
+
return sender(query, {})
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
GraphQLClient.prototype.fragments = function () {
|
265
|
+
return this._fragments
|
266
|
+
}
|
267
|
+
|
268
|
+
GraphQLClient.prototype.getOptions = function () {
|
269
|
+
return this.options
|
270
|
+
}
|
271
|
+
|
272
|
+
GraphQLClient.prototype.fragment = function (fragment) {
|
273
|
+
if (typeof fragment == 'string') {
|
274
|
+
var _fragment = this._fragments[fragment.replace(/\./g, FRAGMENT_SEPERATOR)]
|
275
|
+
if (!_fragment) {
|
276
|
+
throw "Fragment " + fragment + " not found!"
|
277
|
+
}
|
278
|
+
return _fragment.trim()
|
279
|
+
} else {
|
280
|
+
this.options.fragments = __extend(true, this.options.fragments, fragment)
|
281
|
+
this._fragments = this.buildFragments(this.options.fragments)
|
282
|
+
return this._fragments
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
GraphQLClient.prototype.ql = function (strings) {
|
287
|
+
var that = this
|
288
|
+
fragments = Array.prototype.slice.call(arguments, 1)
|
289
|
+
fragments = fragments.map(function (fragment) {
|
290
|
+
return fragment.match(/fragment\s+([^\s]*)\s/)[1]
|
291
|
+
})
|
292
|
+
var query = this.buildQuery(strings.reduce(function (acc, seg, i) {
|
293
|
+
return acc + fragments[i - 1] + seg
|
294
|
+
}))
|
295
|
+
query = ((this.__prefix||"") + " " + query).trim()
|
296
|
+
return query
|
297
|
+
}
|
298
|
+
|
299
|
+
;(function (root, factory) {
|
300
|
+
if (typeof define === 'function' && define.amd) {
|
301
|
+
define(function () {
|
302
|
+
return (root.graphql = factory(GraphQLClient))
|
303
|
+
});
|
304
|
+
} else if (typeof module === 'object' && module.exports) {
|
305
|
+
module.exports = factory(root.GraphQLClient)
|
306
|
+
} else {
|
307
|
+
root.graphql = factory(root.GraphQLClient)
|
308
|
+
}
|
309
|
+
}(this, function () {
|
310
|
+
return GraphQLClient
|
311
|
+
}))
|
312
|
+
})()
|
@@ -0,0 +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(a,b,c,d,e){var f=new XMLHttpRequest;f.open(a,b,!0),f.setRequestHeader("Content-type","application/x-www-form-urlencoded"),f.setRequestHeader("Accept","application/json");for(var g in c)f.setRequestHeader(g,c[g]);f.onerror=function(){e(f,f.status)},f.onload=function(){e(JSON.parse(f.responseText),f.status)},f.send("query="+escape(d.query)+"&variables="+escape(JSON.stringify(d.variables)))}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));return e}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="_",d.AUTOTYPE_PATTERN=/\(@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"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),g=new RegExp(e.source.replace(/\((.*)\)/,d));if(a.match(g))throw"Recursive fragment usage detected on "+d+".";f.push(a),f.filter(function(a){return a.match(new RegExp("fragment "+d))}).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.autoType=function(a,b){var c={string:"String",number:"Int","boolean":"Boolean"};return a.replace(d.AUTOTYPE_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+")"})},d.prototype.cleanAutoTypeAnnotations=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.autoType(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.cleanAutoTypeAnnotations(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;var e=d.run(d.ql.apply(d,arguments));return d.__prefix="",e}var f=a(this.prefix+" "+b);return arguments.length>1?f.apply(null,Array.prototype.slice.call(arguments,1)):f}var d=this;this.mutate=b.bind({prefix:"mutation"}),this.query=b.bind({prefix:"query"}),this.subscribe=b.bind({prefix:"subscription"});var e=["mutate","query","subscribe"];e.forEach(function(a){d[a].run=function(b){return d[a](b,{})}}),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 a.match(/fragment\s+([^\s]*)\s/)[1]});var b=this.buildQuery(a.reduce(function(a,b,c){return a+fragments[c-1]+b}));return b=((this.__prefix||"")+" "+b).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})}();
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'graphqljs/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "graphqljs-rails"
|
8
|
+
spec.version = GraphQLJS::Rails::VERSION
|
9
|
+
spec.authors = ["Fatih Kadir Akın"]
|
10
|
+
spec.email = ["fatihkadirakin@gmail.com"]
|
11
|
+
spec.summary = %q{GraphQL.js integration for Rails}
|
12
|
+
spec.homepage = "https://github.com/f/graphql.js"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'railties'
|
21
|
+
spec.add_runtime_dependency 'actionpack'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rails", "~> 4.0.0"
|
25
|
+
end
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: graphqljs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fatih Kadir Akın
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.0.0
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- fatihkadirakin@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- app/assets/javascripts/graphql.js
|
98
|
+
- app/assets/javascripts/graphql.min.js
|
99
|
+
- graphqljs-rails.gemspec
|
100
|
+
- lib/graphqljs/rails.rb
|
101
|
+
- lib/graphqljs/rails/version.rb
|
102
|
+
homepage: https://github.com/f/graphql.js
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.6.10
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: GraphQL.js integration for Rails
|
126
|
+
test_files: []
|