elasticgraph-rack 1.0.0.rc2 → 1.0.0.rc4
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 +4 -4
- data/README.md +8 -34
- data/lib/elastic_graph/rack.rb +1 -4
- metadata +18 -27
- data/lib/elastic_graph/rack/graphiql/README.md +0 -40
- data/lib/elastic_graph/rack/graphiql/index.html +0 -90
- data/lib/elastic_graph/rack/graphiql.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b5340adefa2dd623ceb91cae41a79e05d29fd1971371623b861d45606813906
|
4
|
+
data.tar.gz: 4e03c7c7700efc695c6861e36b89ecf1df4dc42bf9395f26e4205f3d08e345e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec5f00f804032b609f2437d9396d63f46fe0a744c688a8dabc23df90aacfba8a1a665548d968ff7850a0760e9f1bf6b422d354fd058cf9c7b7e6ea1e763d273
|
7
|
+
data.tar.gz: 14b4e63009a6479bd5381349d8723d498921b72fc9dfe4cc7090e53bb1ac7f634ad71c59aefc51269e7008b24b5e43fbcc67d8dd247effe1c5709582e37e4c5e
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# ElasticGraph::Rack
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
but could also be used to serve an ElasticGraph application from any Rack
|
6
|
-
compatible web server.
|
3
|
+
Serves an ElasticGraph application using [Rack](https://github.com/rack/rack).
|
4
|
+
Can be used to serve an ElasticGraph application from any Rack compatible web server.
|
7
5
|
|
8
6
|
## Dependency Diagram
|
9
7
|
|
@@ -20,46 +18,22 @@ graph LR;
|
|
20
18
|
rack["rack"];
|
21
19
|
elasticgraph-rack --> rack;
|
22
20
|
class rack externalGemStyle;
|
23
|
-
elasticgraph-
|
24
|
-
elasticgraph-
|
25
|
-
class elasticgraph-
|
21
|
+
elasticgraph-graphiql["elasticgraph-graphiql"];
|
22
|
+
elasticgraph-graphiql --> elasticgraph-rack;
|
23
|
+
class elasticgraph-graphiql otherEgGemStyle;
|
26
24
|
click rack href "https://rubygems.org/gems/rack" "Open on RubyGems.org" _blank;
|
27
25
|
```
|
28
26
|
|
29
|
-
##
|
27
|
+
## Usage
|
30
28
|
|
31
|
-
|
32
|
-
example of using it in a Rack `config.ru` file:
|
29
|
+
Use this gem with any rack-compatible server. Here's an example `config.ru`:
|
33
30
|
|
34
31
|
```ruby
|
35
32
|
require 'elastic_graph/graphql'
|
36
33
|
require 'elastic_graph/rack/graphql_endpoint'
|
37
34
|
|
38
|
-
graphql = ElasticGraph::GraphQL.from_yaml_file("
|
35
|
+
graphql = ElasticGraph::GraphQL.from_yaml_file("config/settings/local.yaml")
|
39
36
|
run ElasticGraph::Rack::GraphQLEndpoint.new(graphql)
|
40
37
|
```
|
41
38
|
|
42
39
|
Run this with `rackup` (after installing the `rackup` gem) or any other rack-compatible server.
|
43
|
-
|
44
|
-
## Serving a GraphiQL UI
|
45
|
-
|
46
|
-
This gem also provides a simple GraphiQL UI using the CDN-hosted GraphiQL assets.
|
47
|
-
Here's an example `config.ru` to boot that:
|
48
|
-
|
49
|
-
``` ruby
|
50
|
-
require 'elastic_graph/graphql'
|
51
|
-
require 'elastic_graph/rack/graphiql'
|
52
|
-
|
53
|
-
graphql = ElasticGraph::GraphQL.from_yaml_file("path/to/config.yaml")
|
54
|
-
run ElasticGraph::Rack::GraphiQL.new(graphql)
|
55
|
-
```
|
56
|
-
|
57
|
-
Run this with `rackup` (after installing the `rackup` gem) or any other rack-compatible server.
|
58
|
-
|
59
|
-
## License
|
60
|
-
|
61
|
-
elasticgraph-rack is released under the [MIT License](https://opensource.org/licenses/MIT).
|
62
|
-
|
63
|
-
[Part of the distributed code](lib/elastic_graph/rack/graphiql/index.html)
|
64
|
-
comes from the [GraphiQL project](https://github.com/graphql/graphiql), also licensed under the
|
65
|
-
MIT License, Copyright (c) GraphQL Contributors.
|
data/lib/elastic_graph/rack.rb
CHANGED
@@ -10,10 +10,7 @@ module ElasticGraph
|
|
10
10
|
# Adapts an ElasticGraph GraphQL endpoint to run as a [Rack](https://github.com/rack/rack) application.
|
11
11
|
# This allows an ElasticGraph GraphQL endpoint to run inside any [Rack-compatible web
|
12
12
|
# framework](https://github.com/rack/rack#supported-web-frameworks), including [Ruby on Rails](https://rubyonrails.org/),
|
13
|
-
# or as a stand-alone application.
|
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).
|
13
|
+
# or as a stand-alone application.
|
17
14
|
module Rack
|
18
15
|
end
|
19
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -17,90 +17,84 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.0.0.
|
20
|
+
version: 1.0.0.rc4
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.0.0.
|
27
|
+
version: 1.0.0.rc4
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '3.
|
35
|
-
- - ">="
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 3.1.16
|
34
|
+
version: '3.2'
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
39
|
- - "~>"
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: '3.
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.1.16
|
41
|
+
version: '3.2'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: elasticgraph-admin
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
45
|
requirements:
|
52
46
|
- - '='
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.0.
|
48
|
+
version: 1.0.0.rc4
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
53
|
- - '='
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0.
|
55
|
+
version: 1.0.0.rc4
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: elasticgraph-elasticsearch
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
65
59
|
requirements:
|
66
60
|
- - '='
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.0.
|
62
|
+
version: 1.0.0.rc4
|
69
63
|
type: :development
|
70
64
|
prerelease: false
|
71
65
|
version_requirements: !ruby/object:Gem::Requirement
|
72
66
|
requirements:
|
73
67
|
- - '='
|
74
68
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0.
|
69
|
+
version: 1.0.0.rc4
|
76
70
|
- !ruby/object:Gem::Dependency
|
77
71
|
name: elasticgraph-opensearch
|
78
72
|
requirement: !ruby/object:Gem::Requirement
|
79
73
|
requirements:
|
80
74
|
- - '='
|
81
75
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0.
|
76
|
+
version: 1.0.0.rc4
|
83
77
|
type: :development
|
84
78
|
prerelease: false
|
85
79
|
version_requirements: !ruby/object:Gem::Requirement
|
86
80
|
requirements:
|
87
81
|
- - '='
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0.
|
83
|
+
version: 1.0.0.rc4
|
90
84
|
- !ruby/object:Gem::Dependency
|
91
85
|
name: elasticgraph-indexer
|
92
86
|
requirement: !ruby/object:Gem::Requirement
|
93
87
|
requirements:
|
94
88
|
- - '='
|
95
89
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0.
|
90
|
+
version: 1.0.0.rc4
|
97
91
|
type: :development
|
98
92
|
prerelease: false
|
99
93
|
version_requirements: !ruby/object:Gem::Requirement
|
100
94
|
requirements:
|
101
95
|
- - '='
|
102
96
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0.0.
|
97
|
+
version: 1.0.0.rc4
|
104
98
|
email:
|
105
99
|
- myron@squareup.com
|
106
100
|
executables: []
|
@@ -110,19 +104,16 @@ files:
|
|
110
104
|
- LICENSE.txt
|
111
105
|
- README.md
|
112
106
|
- lib/elastic_graph/rack.rb
|
113
|
-
- lib/elastic_graph/rack/graphiql.rb
|
114
|
-
- lib/elastic_graph/rack/graphiql/README.md
|
115
|
-
- lib/elastic_graph/rack/graphiql/index.html
|
116
107
|
- lib/elastic_graph/rack/graphql_endpoint.rb
|
117
108
|
homepage: https://block.github.io/elasticgraph/
|
118
109
|
licenses:
|
119
110
|
- MIT
|
120
111
|
metadata:
|
121
112
|
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
122
|
-
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.
|
123
|
-
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.
|
113
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.rc4
|
114
|
+
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.rc4/
|
124
115
|
homepage_uri: https://block.github.io/elasticgraph/
|
125
|
-
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.
|
116
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.rc4/elasticgraph-rack
|
126
117
|
gem_category: local
|
127
118
|
rdoc_options: []
|
128
119
|
require_paths:
|
@@ -141,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
132
|
- !ruby/object:Gem::Version
|
142
133
|
version: '0'
|
143
134
|
requirements: []
|
144
|
-
rubygems_version: 3.6.
|
135
|
+
rubygems_version: 3.6.9
|
145
136
|
specification_version: 4
|
146
|
-
summary:
|
137
|
+
summary: Serves an ElasticGraph application using Rack.
|
147
138
|
test_files: []
|
@@ -1,40 +0,0 @@
|
|
1
|
-
## GraphiQL for ElasticGraph
|
2
|
-
|
3
|
-
This directory provides the GraphiQL in browser UI for working with ElasticGraph
|
4
|
-
applications.
|
5
|
-
|
6
|
-
The `index.html` file is copied from:
|
7
|
-
|
8
|
-
https://github.com/graphql/graphiql/blob/graphiql%402.4.0/examples/graphiql-cdn/index.html
|
9
|
-
|
10
|
-
However, we've applied some slight changes to make it work for ElasticGraph.
|
11
|
-
|
12
|
-
```diff
|
13
|
-
diff --git a/elasticgraph-rack/lib/elastic_graph/rack/graphiql/index.html b/elasticgraph-rack/lib/elastic_graph/rack/graphiql/index.html
|
14
|
-
index 55cf5d05..a672ead9 100644
|
15
|
-
--- a/elasticgraph-rack/lib/elastic_graph/rack/graphiql/index.html
|
16
|
-
+++ b/elasticgraph-rack/lib/elastic_graph/rack/graphiql/index.html
|
17
|
-
@@ -8,7 +8,7 @@
|
18
|
-
<!DOCTYPE html>
|
19
|
-
<html lang="en">
|
20
|
-
<head>
|
21
|
-
- <title>GraphiQL</title>
|
22
|
-
+ <title>ElasticGraph GraphiQL</title>
|
23
|
-
<style>
|
24
|
-
body {
|
25
|
-
height: 100%;
|
26
|
-
@@ -58,7 +58,7 @@
|
27
|
-
ReactDOM.render(
|
28
|
-
React.createElement(GraphiQL, {
|
29
|
-
fetcher: GraphiQL.createFetcher({
|
30
|
-
- url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
|
31
|
-
+ url: '/graphql',
|
32
|
-
}),
|
33
|
-
defaultEditorToolsVisibility: true,
|
34
|
-
}),
|
35
|
-
```
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
[index.html](index.html) comes from the [GraphiQL project](https://github.com/graphql/graphiql),
|
40
|
-
licensed under the MIT License, Copyright (c) GraphQL Contributors.
|
@@ -1,90 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
* Copyright (c) 2021 GraphQL Contributors
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the GraphiQL license found at:
|
6
|
-
* https://github.com/graphql/graphiql/blob/graphiql%404.0.0/LICENSE
|
7
|
-
-->
|
8
|
-
<!doctype html>
|
9
|
-
<html lang="en">
|
10
|
-
<head>
|
11
|
-
<meta charset="UTF-8" />
|
12
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
13
|
-
<title>ElasticGraph GraphiQL</title>
|
14
|
-
<style>
|
15
|
-
body {
|
16
|
-
margin: 0;
|
17
|
-
overflow: hidden; /* in Firefox */
|
18
|
-
}
|
19
|
-
|
20
|
-
#graphiql {
|
21
|
-
height: 100dvh;
|
22
|
-
}
|
23
|
-
|
24
|
-
.loading {
|
25
|
-
height: 100%;
|
26
|
-
display: flex;
|
27
|
-
align-items: center;
|
28
|
-
justify-content: center;
|
29
|
-
font-size: 4rem;
|
30
|
-
}
|
31
|
-
</style>
|
32
|
-
<link
|
33
|
-
rel="stylesheet"
|
34
|
-
href="https://esm.sh/graphiql@4.0.0/dist/style.css"
|
35
|
-
/>
|
36
|
-
<link
|
37
|
-
rel="stylesheet"
|
38
|
-
href="https://esm.sh/@graphiql/plugin-explorer@4.0.0/dist/style.css"
|
39
|
-
/>
|
40
|
-
<!-- Note: the ?standalone flag bundles the module along with all of its `dependencies`, excluding `peerDependencies`, into a single JavaScript file. -->
|
41
|
-
<script type="importmap">
|
42
|
-
{
|
43
|
-
"imports": {
|
44
|
-
"react": "https://esm.sh/react@19.1.0",
|
45
|
-
"react/jsx-runtime": "https://esm.sh/react@19.1.0/jsx-runtime",
|
46
|
-
|
47
|
-
"react-dom": "https://esm.sh/react-dom@19.1.0",
|
48
|
-
"react-dom/client": "https://esm.sh/react-dom@19.1.0/client",
|
49
|
-
|
50
|
-
"graphiql": "https://esm.sh/graphiql@4.0.0?standalone&external=react,react/jsx-runtime,react-dom,@graphiql/react",
|
51
|
-
"@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer@4.0.0?standalone&external=react,react/jsx-runtime,react-dom,@graphiql/react,graphql",
|
52
|
-
"@graphiql/react": "https://esm.sh/@graphiql/react@0.30.0?standalone&external=react,react/jsx-runtime,react-dom,graphql,@graphiql/toolkit",
|
53
|
-
|
54
|
-
"@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit@0.11.2?standalone&external=graphql",
|
55
|
-
"graphql": "https://esm.sh/graphql@16.11.0"
|
56
|
-
}
|
57
|
-
}
|
58
|
-
</script>
|
59
|
-
<script type="module">
|
60
|
-
// Import React and ReactDOM
|
61
|
-
import React from 'react';
|
62
|
-
import ReactDOM from 'react-dom/client';
|
63
|
-
// Import GraphiQL and the Explorer plugin
|
64
|
-
import { GraphiQL } from 'graphiql';
|
65
|
-
import { createGraphiQLFetcher } from '@graphiql/toolkit';
|
66
|
-
import { explorerPlugin } from '@graphiql/plugin-explorer';
|
67
|
-
|
68
|
-
const fetcher = createGraphiQLFetcher({
|
69
|
-
url: '/graphql',
|
70
|
-
});
|
71
|
-
const explorer = explorerPlugin();
|
72
|
-
|
73
|
-
function App() {
|
74
|
-
return React.createElement(GraphiQL, {
|
75
|
-
fetcher,
|
76
|
-
plugins: [explorer],
|
77
|
-
});
|
78
|
-
}
|
79
|
-
|
80
|
-
const container = document.getElementById('graphiql');
|
81
|
-
const root = ReactDOM.createRoot(container);
|
82
|
-
root.render(React.createElement(App));
|
83
|
-
</script>
|
84
|
-
</head>
|
85
|
-
<body>
|
86
|
-
<div id="graphiql">
|
87
|
-
<div class="loading">Loading…</div>
|
88
|
-
</div>
|
89
|
-
</body>
|
90
|
-
</html>
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# Copyright 2024 - 2025 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
|
-
require "elastic_graph/rack/graphql_endpoint"
|
10
|
-
require "rack/builder"
|
11
|
-
require "rack/static"
|
12
|
-
|
13
|
-
module ElasticGraph
|
14
|
-
module Rack
|
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.
|
18
|
-
#
|
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)
|
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
|
31
|
-
def self.new(graphql)
|
32
|
-
graphql_endpoint = ElasticGraph::Rack::GraphQLEndpoint.new(graphql)
|
33
|
-
|
34
|
-
::Rack::Builder.new do
|
35
|
-
use ::Rack::Static, urls: {"/" => "index.html"}, root: ::File.join(__dir__, "graphiql")
|
36
|
-
|
37
|
-
map "/graphql" do
|
38
|
-
run graphql_endpoint
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|