elasticgraph-rack 0.18.0.3 → 0.18.0.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
  SHA256:
3
- metadata.gz: 1c8fb6ffaf5588851413969b543183b660ca1c2307caf897dac09622f925fabf
4
- data.tar.gz: 90b234468722c7673509215fb0742ef2e1b19d7d396770155b995bee09c3958e
3
+ metadata.gz: 1af5a7a0745d67b84546ebea7bbf38bd2d2fc4dffad88e80d60d3eb629255996
4
+ data.tar.gz: 8ed374c529b14ab86294ded8872631a6ef6406b5960e832ffd48c54e50ca8861
5
5
  SHA512:
6
- metadata.gz: 808f45becf5f610664c0b769c1ae5cf452e53526e0290fe85ef4a14fd1ae330718ecc4102ba25671edb00f4737fa2da9671990d9a7554260e6213b2e29d974c9
7
- data.tar.gz: 3df8bf804ae23a29a4e396efcb3975e2ef6f019100b563aac78599c0801a4d98213348a6622a53713c19d64bd28eda932afa7651baeb9976ba24a341c9688289
6
+ metadata.gz: 6bbf103f1e1730803217b2a537bfec0fefdd2a935977a9240196a533cb4eec1877e5f811efba325bb557a8752838e2a3dcde273aec6b65d213add2f2067d64ed
7
+ data.tar.gz: 264c26920757fae4b762d141f18f83812700d81331daa653d0bd8718f843b577af683f54d550fd1309b521f0288afdc6c17f0362ab773a416c6a807352341f57
@@ -7,14 +7,27 @@
7
7
  # frozen_string_literal: true
8
8
 
9
9
  require "elastic_graph/rack/graphql_endpoint"
10
+ require "rack/builder"
10
11
  require "rack/static"
11
12
 
12
13
  module ElasticGraph
13
14
  module Rack
14
- # A Rack app that exposes both a GraphQL endpoint and an admin UI using GraphiQL:
15
+ # A [Rack](https://github.com/rack/rack) application that serves both an ElasticGraph GraphQL endpoint
16
+ # and a [GraphiQL IDE](https://github.com/graphql/graphiql). This can be used for local development,
17
+ # mounted in a [Rails](https://rubyonrails.org/) application, or run in any other Rack-compatible context.
15
18
  #
16
- # https://github.com/graphql/graphiql/tree/graphiql%402.4.0
19
+ # @example Simple config.ru to run GraphiQL as a Rack application, targeting an ElasticGraph endpoint
20
+ # require "elastic_graph/graphql"
21
+ # require "elastic_graph/rack/graphiql"
22
+ #
23
+ # graphql = ElasticGraph::GraphQL.from_yaml_file("config/settings/development.yaml")
24
+ # run ElasticGraph::Rack::GraphiQL.new(graphql)
17
25
  module GraphiQL
26
+ # Builds a [Rack](https://github.com/rack/rack) application that serves both an ElasticGraph GraphQL endpoint
27
+ # and a [GraphiQL IDE](https://github.com/graphql/graphiql).
28
+ #
29
+ # @param graphql [ElasticGraph::GraphQL] ElasticGraph GraphQL instance
30
+ # @return [Rack::Builder] built Rack application
18
31
  def self.new(graphql)
19
32
  graphql_endpoint = ElasticGraph::Rack::GraphQLEndpoint.new(graphql)
20
33
 
@@ -11,14 +11,27 @@ require "rack"
11
11
 
12
12
  module ElasticGraph
13
13
  module Rack
14
- # A simple Rack wrapper around an ElasticGraph endpoint. This can be used for local development,
15
- # or mounted in a Rails app, or run in any other rack-compatible context.
14
+ # A simple [Rack](https://github.com/rack/rack) wrapper around an ElasticGraph GraphQL endpoint.
15
+ # This can be used for local development, mounted in a [Rails](https://rubyonrails.org/) application,
16
+ # or run in any other Rack-compatible context.
17
+ #
18
+ # @example Simple config.ru to run an ElasticGraph endpoint as a Rack application
19
+ # require "elastic_graph/graphql"
20
+ # require "elastic_graph/rack/graphql_endpoint"
21
+ #
22
+ # graphql = ElasticGraph::GraphQL.from_yaml_file("config/settings/development.yaml")
23
+ # run ElasticGraph::Rack::GraphQLEndpoint.new(graphql)
16
24
  class GraphQLEndpoint
25
+ # @param graphql [ElasticGraph::GraphQL] ElasticGraph GraphQL instance
17
26
  def initialize(graphql)
18
27
  @logger = graphql.logger
19
28
  @graphql_http_endpoint = graphql.graphql_http_endpoint
20
29
  end
21
30
 
31
+ # Responds to a Rack request.
32
+ #
33
+ # @param env [Hash<String, Object>] Rack env
34
+ # @return [Array(Integer, Hash<String, String>, Array<String>)]
22
35
  def call(env)
23
36
  rack_request = ::Rack::Request.new(env)
24
37
 
@@ -0,0 +1,19 @@
1
+ # Copyright 2024 Block, Inc.
2
+ #
3
+ # Use of this source code is governed by an MIT-style
4
+ # license that can be found in the LICENSE file or at
5
+ # https://opensource.org/licenses/MIT.
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module ElasticGraph
10
+ # Adapts an ElasticGraph GraphQL endpoint to run as a [Rack](https://github.com/rack/rack) application.
11
+ # This allows an ElasticGraph GraphQL endpoint to run inside any [Rack-compatible web
12
+ # framework](https://github.com/rack/rack#supported-web-frameworks), including [Ruby on Rails](https://rubyonrails.org/),
13
+ # or as a stand-alone application. Two configurations are supported:
14
+ #
15
+ # * Use {Rack::GraphQLEndpoint} to serve a GraphQL endpoint.
16
+ # * Use {Rack::GraphiQL} to serve a GraphQL endpoint and the [GraphiQL IDE](https://github.com/graphql/graphiql).
17
+ module Rack
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0.3
4
+ version: 0.18.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
+ - Ben VandenBos
9
+ - Square Engineering
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2024-09-05 00:00:00.000000000 Z
13
+ date: 2024-09-20 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: rubocop-factory_bot
@@ -224,14 +226,14 @@ dependencies:
224
226
  requirements:
225
227
  - - '='
226
228
  - !ruby/object:Gem::Version
227
- version: 0.18.0.3
229
+ version: 0.18.0.5
228
230
  type: :runtime
229
231
  prerelease: false
230
232
  version_requirements: !ruby/object:Gem::Requirement
231
233
  requirements:
232
234
  - - '='
233
235
  - !ruby/object:Gem::Version
234
- version: 0.18.0.3
236
+ version: 0.18.0.5
235
237
  - !ruby/object:Gem::Dependency
236
238
  name: rack
237
239
  requirement: !ruby/object:Gem::Requirement
@@ -252,56 +254,56 @@ dependencies:
252
254
  requirements:
253
255
  - - '='
254
256
  - !ruby/object:Gem::Version
255
- version: 0.18.0.3
257
+ version: 0.18.0.5
256
258
  type: :development
257
259
  prerelease: false
258
260
  version_requirements: !ruby/object:Gem::Requirement
259
261
  requirements:
260
262
  - - '='
261
263
  - !ruby/object:Gem::Version
262
- version: 0.18.0.3
264
+ version: 0.18.0.5
263
265
  - !ruby/object:Gem::Dependency
264
266
  name: elasticgraph-elasticsearch
265
267
  requirement: !ruby/object:Gem::Requirement
266
268
  requirements:
267
269
  - - '='
268
270
  - !ruby/object:Gem::Version
269
- version: 0.18.0.3
271
+ version: 0.18.0.5
270
272
  type: :development
271
273
  prerelease: false
272
274
  version_requirements: !ruby/object:Gem::Requirement
273
275
  requirements:
274
276
  - - '='
275
277
  - !ruby/object:Gem::Version
276
- version: 0.18.0.3
278
+ version: 0.18.0.5
277
279
  - !ruby/object:Gem::Dependency
278
280
  name: elasticgraph-opensearch
279
281
  requirement: !ruby/object:Gem::Requirement
280
282
  requirements:
281
283
  - - '='
282
284
  - !ruby/object:Gem::Version
283
- version: 0.18.0.3
285
+ version: 0.18.0.5
284
286
  type: :development
285
287
  prerelease: false
286
288
  version_requirements: !ruby/object:Gem::Requirement
287
289
  requirements:
288
290
  - - '='
289
291
  - !ruby/object:Gem::Version
290
- version: 0.18.0.3
292
+ version: 0.18.0.5
291
293
  - !ruby/object:Gem::Dependency
292
294
  name: elasticgraph-indexer
293
295
  requirement: !ruby/object:Gem::Requirement
294
296
  requirements:
295
297
  - - '='
296
298
  - !ruby/object:Gem::Version
297
- version: 0.18.0.3
299
+ version: 0.18.0.5
298
300
  type: :development
299
301
  prerelease: false
300
302
  version_requirements: !ruby/object:Gem::Requirement
301
303
  requirements:
302
304
  - - '='
303
305
  - !ruby/object:Gem::Version
304
- version: 0.18.0.3
306
+ version: 0.18.0.5
305
307
  - !ruby/object:Gem::Dependency
306
308
  name: rack-test
307
309
  requirement: !ruby/object:Gem::Requirement
@@ -326,6 +328,7 @@ files:
326
328
  - LICENSE.txt
327
329
  - README.md
328
330
  - elasticgraph-rack.gemspec
331
+ - lib/elastic_graph/rack.rb
329
332
  - lib/elastic_graph/rack/graphiql.rb
330
333
  - lib/elastic_graph/rack/graphiql/README.md
331
334
  - lib/elastic_graph/rack/graphiql/index.html