graphiql-rails 1.8.0 → 1.10.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.
@@ -2,9 +2,19 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= GraphiQL::Rails.config.title || 'GraphiQL' %></title>
5
-
6
- <%= stylesheet_link_tag("graphiql/rails/application") %>
7
- <%= javascript_include_tag("graphiql/rails/application", nonce: true ) %>
5
+ <% if defined?(Propshaft) %>
6
+ <%= stylesheet_link_tag("graphiql/rails/graphiql-3.1.1") %>
7
+ <%= stylesheet_link_tag("graphiql/rails/application") %>
8
+ <%= javascript_include_tag("graphiql/rails/react-18.2.0", nonce: true ) %>
9
+ <%= javascript_include_tag("graphiql/rails/react-dom-18.2.0", nonce: true ) %>
10
+ <%= javascript_include_tag("graphiql/rails/graphiql-3.1.1", nonce: true ) %>
11
+ <%= javascript_include_tag("graphiql/rails/graphiql_show", nonce: true ) %>
12
+ <% elsif defined?(Sprockets) %>
13
+ <%= stylesheet_link_tag("graphiql/rails/application") %>
14
+ <%= javascript_include_tag("graphiql/rails/application", nonce: true ) %>
15
+ <% else %>
16
+ <% raise "GraphiQL::Rails requires either Propshaft or Sprockets. Use `$ bundle add propshaft` or `$ bundle add sprockets-rails` to add one of them to your app." %>
17
+ <% end %>
8
18
  </head>
9
19
  <body>
10
20
  <%= content_tag :div, 'Loading...', id: 'graphiql-container', data: {
@@ -12,7 +22,9 @@
12
22
  initial_query: GraphiQL::Rails.config.initial_query,
13
23
  logo: GraphiQL::Rails.config.logo,
14
24
  headers: GraphiQL::Rails.config.resolve_headers(self),
15
- query_params: GraphiQL::Rails.config.query_params
25
+ query_params: GraphiQL::Rails.config.query_params,
26
+ header_editor_enabled: GraphiQL::Rails.config.header_editor_enabled,
27
+ input_value_deprecation: GraphiQL::Rails.config.input_value_deprecation
16
28
  } %>
17
29
  </body>
18
30
  </html>
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  GraphiQL::Rails::Engine.routes.draw do
2
- get "/" => "editors#show"
2
+ get "/", to: "editors#show"
3
3
  end
@@ -7,7 +7,7 @@ module GraphiQL
7
7
  # @return [Hash<String => Proc>] Keys are headers to include in GraphQL requests, values are `->(view_context) { ... }` procs to determin values
8
8
  attr_accessor :headers
9
9
 
10
- attr_accessor :query_params, :initial_query, :csrf, :title, :logo
10
+ attr_accessor :query_params, :initial_query, :csrf, :title, :logo, :header_editor_enabled, :input_value_deprecation
11
11
 
12
12
  DEFAULT_HEADERS = {
13
13
  'Content-Type' => ->(_) { 'application/json' },
@@ -17,13 +17,14 @@ module GraphiQL
17
17
  "X-CSRF-Token" => -> (view_context) { view_context.form_authenticity_token }
18
18
  }
19
19
 
20
- def initialize(query_params: false, initial_query: nil, title: nil, logo: nil, csrf: true, headers: DEFAULT_HEADERS)
20
+ def initialize(query_params: false, initial_query: nil, title: nil, logo: nil, csrf: true, headers: DEFAULT_HEADERS, input_value_deprecation: false)
21
21
  @query_params = query_params
22
22
  @headers = headers.dup
23
23
  @initial_query = initial_query
24
24
  @title = title
25
25
  @logo = logo
26
26
  @csrf = csrf
27
+ @input_value_deprecation = input_value_deprecation
27
28
  end
28
29
 
29
30
  # Call defined procs, add CSRF token if specified
@@ -35,7 +36,8 @@ module GraphiQL
35
36
  end
36
37
 
37
38
  all_headers.each_with_object({}) do |(key, value), memo|
38
- memo[key] = value.call(view_context)
39
+ header_value = value.call(view_context)
40
+ memo[key] = header_value if !header_value.nil?
39
41
  end
40
42
  end
41
43
  end
@@ -1,5 +1,5 @@
1
1
  module GraphiQL
2
2
  module Rails
3
- VERSION = "1.8.0"
3
+ VERSION = "1.10.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiql-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: sprockets-rails
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
27
  - !ruby/object:Gem::Dependency
42
28
  name: rails
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -145,13 +131,12 @@ extensions: []
145
131
  extra_rdoc_files: []
146
132
  files:
147
133
  - app/assets/javascripts/graphiql/rails/application.js
148
- - app/assets/javascripts/graphiql/rails/fetch-0.10.1.js
149
- - app/assets/javascripts/graphiql/rails/graphiql-1.4.2.js
134
+ - app/assets/javascripts/graphiql/rails/graphiql-3.1.1.js
150
135
  - app/assets/javascripts/graphiql/rails/graphiql_show.js
151
- - app/assets/javascripts/graphiql/rails/react-16.14.0.js
152
- - app/assets/javascripts/graphiql/rails/react-dom-16.14.0.js
136
+ - app/assets/javascripts/graphiql/rails/react-18.2.0.js
137
+ - app/assets/javascripts/graphiql/rails/react-dom-18.2.0.js
153
138
  - app/assets/stylesheets/graphiql/rails/application.css
154
- - app/assets/stylesheets/graphiql/rails/graphiql-1.4.2.css
139
+ - app/assets/stylesheets/graphiql/rails/graphiql-3.1.1.css
155
140
  - app/controllers/graphiql/rails/editors_controller.rb
156
141
  - app/views/graphiql/rails/editors/show.html.erb
157
142
  - config/routes.rb
@@ -1,381 +0,0 @@
1
- (function() {
2
- 'use strict';
3
-
4
- if (self.fetch) {
5
- return
6
- }
7
-
8
- function normalizeName(name) {
9
- if (typeof name !== 'string') {
10
- name = String(name)
11
- }
12
- if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
13
- throw new TypeError('Invalid character in header field name')
14
- }
15
- return name.toLowerCase()
16
- }
17
-
18
- function normalizeValue(value) {
19
- if (typeof value !== 'string') {
20
- value = String(value)
21
- }
22
- return value
23
- }
24
-
25
- function Headers(headers) {
26
- this.map = {}
27
-
28
- if (headers instanceof Headers) {
29
- headers.forEach(function(value, name) {
30
- this.append(name, value)
31
- }, this)
32
-
33
- } else if (headers) {
34
- Object.getOwnPropertyNames(headers).forEach(function(name) {
35
- this.append(name, headers[name])
36
- }, this)
37
- }
38
- }
39
-
40
- Headers.prototype.append = function(name, value) {
41
- name = normalizeName(name)
42
- value = normalizeValue(value)
43
- var list = this.map[name]
44
- if (!list) {
45
- list = []
46
- this.map[name] = list
47
- }
48
- list.push(value)
49
- }
50
-
51
- Headers.prototype['delete'] = function(name) {
52
- delete this.map[normalizeName(name)]
53
- }
54
-
55
- Headers.prototype.get = function(name) {
56
- var values = this.map[normalizeName(name)]
57
- return values ? values[0] : null
58
- }
59
-
60
- Headers.prototype.getAll = function(name) {
61
- return this.map[normalizeName(name)] || []
62
- }
63
-
64
- Headers.prototype.has = function(name) {
65
- return this.map.hasOwnProperty(normalizeName(name))
66
- }
67
-
68
- Headers.prototype.set = function(name, value) {
69
- this.map[normalizeName(name)] = [normalizeValue(value)]
70
- }
71
-
72
- Headers.prototype.forEach = function(callback, thisArg) {
73
- Object.getOwnPropertyNames(this.map).forEach(function(name) {
74
- this.map[name].forEach(function(value) {
75
- callback.call(thisArg, value, name, this)
76
- }, this)
77
- }, this)
78
- }
79
-
80
- function consumed(body) {
81
- if (body.bodyUsed) {
82
- return Promise.reject(new TypeError('Already read'))
83
- }
84
- body.bodyUsed = true
85
- }
86
-
87
- function fileReaderReady(reader) {
88
- return new Promise(function(resolve, reject) {
89
- reader.onload = function() {
90
- resolve(reader.result)
91
- }
92
- reader.onerror = function() {
93
- reject(reader.error)
94
- }
95
- })
96
- }
97
-
98
- function readBlobAsArrayBuffer(blob) {
99
- var reader = new FileReader()
100
- reader.readAsArrayBuffer(blob)
101
- return fileReaderReady(reader)
102
- }
103
-
104
- function readBlobAsText(blob) {
105
- var reader = new FileReader()
106
- reader.readAsText(blob)
107
- return fileReaderReady(reader)
108
- }
109
-
110
- var support = {
111
- blob: 'FileReader' in self && 'Blob' in self && (function() {
112
- try {
113
- new Blob();
114
- return true
115
- } catch(e) {
116
- return false
117
- }
118
- })(),
119
- formData: 'FormData' in self,
120
- arrayBuffer: 'ArrayBuffer' in self
121
- }
122
-
123
- function Body() {
124
- this.bodyUsed = false
125
-
126
-
127
- this._initBody = function(body) {
128
- this._bodyInit = body
129
- if (typeof body === 'string') {
130
- this._bodyText = body
131
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
132
- this._bodyBlob = body
133
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
134
- this._bodyFormData = body
135
- } else if (!body) {
136
- this._bodyText = ''
137
- } else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
138
- // Only support ArrayBuffers for POST method.
139
- // Receiving ArrayBuffers happens via Blobs, instead.
140
- } else {
141
- throw new Error('unsupported BodyInit type')
142
- }
143
- }
144
-
145
- if (support.blob) {
146
- this.blob = function() {
147
- var rejected = consumed(this)
148
- if (rejected) {
149
- return rejected
150
- }
151
-
152
- if (this._bodyBlob) {
153
- return Promise.resolve(this._bodyBlob)
154
- } else if (this._bodyFormData) {
155
- throw new Error('could not read FormData body as blob')
156
- } else {
157
- return Promise.resolve(new Blob([this._bodyText]))
158
- }
159
- }
160
-
161
- this.arrayBuffer = function() {
162
- return this.blob().then(readBlobAsArrayBuffer)
163
- }
164
-
165
- this.text = function() {
166
- var rejected = consumed(this)
167
- if (rejected) {
168
- return rejected
169
- }
170
-
171
- if (this._bodyBlob) {
172
- return readBlobAsText(this._bodyBlob)
173
- } else if (this._bodyFormData) {
174
- throw new Error('could not read FormData body as text')
175
- } else {
176
- return Promise.resolve(this._bodyText)
177
- }
178
- }
179
- } else {
180
- this.text = function() {
181
- var rejected = consumed(this)
182
- return rejected ? rejected : Promise.resolve(this._bodyText)
183
- }
184
- }
185
-
186
- if (support.formData) {
187
- this.formData = function() {
188
- return this.text().then(decode)
189
- }
190
- }
191
-
192
- this.json = function() {
193
- return this.text().then(JSON.parse)
194
- }
195
-
196
- return this
197
- }
198
-
199
- // HTTP methods whose capitalization should be normalized
200
- var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']
201
-
202
- function normalizeMethod(method) {
203
- var upcased = method.toUpperCase()
204
- return (methods.indexOf(upcased) > -1) ? upcased : method
205
- }
206
-
207
- function Request(input, options) {
208
- options = options || {}
209
- var body = options.body
210
- if (Request.prototype.isPrototypeOf(input)) {
211
- if (input.bodyUsed) {
212
- throw new TypeError('Already read')
213
- }
214
- this.url = input.url
215
- this.credentials = input.credentials
216
- if (!options.headers) {
217
- this.headers = new Headers(input.headers)
218
- }
219
- this.method = input.method
220
- this.mode = input.mode
221
- if (!body) {
222
- body = input._bodyInit
223
- input.bodyUsed = true
224
- }
225
- } else {
226
- this.url = input
227
- }
228
-
229
- this.credentials = options.credentials || this.credentials || 'omit'
230
- if (options.headers || !this.headers) {
231
- this.headers = new Headers(options.headers)
232
- }
233
- this.method = normalizeMethod(options.method || this.method || 'GET')
234
- this.mode = options.mode || this.mode || null
235
- this.referrer = null
236
-
237
- if ((this.method === 'GET' || this.method === 'HEAD') && body) {
238
- throw new TypeError('Body not allowed for GET or HEAD requests')
239
- }
240
- this._initBody(body)
241
- }
242
-
243
- Request.prototype.clone = function() {
244
- return new Request(this)
245
- }
246
-
247
- function decode(body) {
248
- var form = new FormData()
249
- body.trim().split('&').forEach(function(bytes) {
250
- if (bytes) {
251
- var split = bytes.split('=')
252
- var name = split.shift().replace(/\+/g, ' ')
253
- var value = split.join('=').replace(/\+/g, ' ')
254
- form.append(decodeURIComponent(name), decodeURIComponent(value))
255
- }
256
- })
257
- return form
258
- }
259
-
260
- function headers(xhr) {
261
- var head = new Headers()
262
- var pairs = xhr.getAllResponseHeaders().trim().split('\n')
263
- pairs.forEach(function(header) {
264
- var split = header.trim().split(':')
265
- var key = split.shift().trim()
266
- var value = split.join(':').trim()
267
- head.append(key, value)
268
- })
269
- return head
270
- }
271
-
272
- Body.call(Request.prototype)
273
-
274
- function Response(bodyInit, options) {
275
- if (!options) {
276
- options = {}
277
- }
278
-
279
- this._initBody(bodyInit)
280
- this.type = 'default'
281
- this.status = options.status
282
- this.ok = this.status >= 200 && this.status < 300
283
- this.statusText = options.statusText
284
- this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers)
285
- this.url = options.url || ''
286
- }
287
-
288
- Body.call(Response.prototype)
289
-
290
- Response.prototype.clone = function() {
291
- return new Response(this._bodyInit, {
292
- status: this.status,
293
- statusText: this.statusText,
294
- headers: new Headers(this.headers),
295
- url: this.url
296
- })
297
- }
298
-
299
- Response.error = function() {
300
- var response = new Response(null, {status: 0, statusText: ''})
301
- response.type = 'error'
302
- return response
303
- }
304
-
305
- var redirectStatuses = [301, 302, 303, 307, 308]
306
-
307
- Response.redirect = function(url, status) {
308
- if (redirectStatuses.indexOf(status) === -1) {
309
- throw new RangeError('Invalid status code')
310
- }
311
-
312
- return new Response(null, {status: status, headers: {location: url}})
313
- }
314
-
315
- self.Headers = Headers;
316
- self.Request = Request;
317
- self.Response = Response;
318
-
319
- self.fetch = function(input, init) {
320
- return new Promise(function(resolve, reject) {
321
- var request
322
- if (Request.prototype.isPrototypeOf(input) && !init) {
323
- request = input
324
- } else {
325
- request = new Request(input, init)
326
- }
327
-
328
- var xhr = new XMLHttpRequest()
329
-
330
- function responseURL() {
331
- if ('responseURL' in xhr) {
332
- return xhr.responseURL
333
- }
334
-
335
- // Avoid security warnings on getResponseHeader when not allowed by CORS
336
- if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
337
- return xhr.getResponseHeader('X-Request-URL')
338
- }
339
-
340
- return;
341
- }
342
-
343
- xhr.onload = function() {
344
- var status = (xhr.status === 1223) ? 204 : xhr.status
345
- if (status < 100 || status > 599) {
346
- reject(new TypeError('Network request failed'))
347
- return
348
- }
349
- var options = {
350
- status: status,
351
- statusText: xhr.statusText,
352
- headers: headers(xhr),
353
- url: responseURL()
354
- }
355
- var body = 'response' in xhr ? xhr.response : xhr.responseText;
356
- resolve(new Response(body, options))
357
- }
358
-
359
- xhr.onerror = function() {
360
- reject(new TypeError('Network request failed'))
361
- }
362
-
363
- xhr.open(request.method, request.url, true)
364
-
365
- if (request.credentials === 'include') {
366
- xhr.withCredentials = true
367
- }
368
-
369
- if ('responseType' in xhr && support.blob) {
370
- xhr.responseType = 'blob'
371
- }
372
-
373
- request.headers.forEach(function(value, name) {
374
- xhr.setRequestHeader(name, value)
375
- })
376
-
377
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
378
- })
379
- }
380
- self.fetch.polyfill = true
381
- })();