elasticgraph-rack 1.0.0.rc1 → 1.0.0.rc3
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 +21 -23
- data/lib/elastic_graph/rack.rb +1 -4
- metadata +16 -33
- 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: 86c85a72e61b8a2865506bf66e41b8bd1f371212aa94e0f4b5d3680da3ea1ec3
|
4
|
+
data.tar.gz: 4cbd5d3b3973367820e8cc32998dc3682b5ca6876789f844e48305e08234daa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3948dc1d94660ce630e1fba86746b88151064ffc4d8a0bf50d6c7c7a36ea8a9d96246a16270cfe92c7c82a8bc803be64cbb4cd60b9be9add20e7c26b93b3139
|
7
|
+
data.tar.gz: 3333167137930e14e1380cd315068df3ef7c4900b3255613a610ef3f59cfa4f3aa403d4685b79f25336690efa7c2044f58bac84630127be1a22a2f831db48919
|
data/README.md
CHANGED
@@ -5,6 +5,27 @@ Intended primarily to make it easy to boot ElasticGraph applications locally,
|
|
5
5
|
but could also be used to serve an ElasticGraph application from any Rack
|
6
6
|
compatible web server.
|
7
7
|
|
8
|
+
## Dependency Diagram
|
9
|
+
|
10
|
+
```mermaid
|
11
|
+
graph LR;
|
12
|
+
classDef targetGemStyle fill:#FADBD8,stroke:#EC7063,color:#000,stroke-width:2px;
|
13
|
+
classDef otherEgGemStyle fill:#A9DFBF,stroke:#2ECC71,color:#000;
|
14
|
+
classDef externalGemStyle fill:#E0EFFF,stroke:#70A1D7,color:#2980B9;
|
15
|
+
elasticgraph-rack["elasticgraph-rack"];
|
16
|
+
class elasticgraph-rack targetGemStyle;
|
17
|
+
elasticgraph-graphql["elasticgraph-graphql"];
|
18
|
+
elasticgraph-rack --> elasticgraph-graphql;
|
19
|
+
class elasticgraph-graphql otherEgGemStyle;
|
20
|
+
rack["rack"];
|
21
|
+
elasticgraph-rack --> rack;
|
22
|
+
class rack externalGemStyle;
|
23
|
+
elasticgraph-graphiql["elasticgraph-graphiql"];
|
24
|
+
elasticgraph-graphiql --> elasticgraph-rack;
|
25
|
+
class elasticgraph-graphiql otherEgGemStyle;
|
26
|
+
click rack href "https://rubygems.org/gems/rack" "Open on RubyGems.org" _blank;
|
27
|
+
```
|
28
|
+
|
8
29
|
## Serving an ElasticGraph GraphQL Endpoint
|
9
30
|
|
10
31
|
`ElasticGraph::Rack::GraphQLEndpoint` is a Rack application. Here's an
|
@@ -19,26 +40,3 @@ run ElasticGraph::Rack::GraphQLEndpoint.new(graphql)
|
|
19
40
|
```
|
20
41
|
|
21
42
|
Run this with `rackup` (after installing the `rackup` gem) or any other rack-compatible server.
|
22
|
-
|
23
|
-
## Serving a GraphiQL UI
|
24
|
-
|
25
|
-
This gem also provides a simple GraphiQL UI using the CDN-hosted GraphiQL assets.
|
26
|
-
Here's an example `config.ru` to boot that:
|
27
|
-
|
28
|
-
``` ruby
|
29
|
-
require 'elastic_graph/graphql'
|
30
|
-
require 'elastic_graph/rack/graphiql'
|
31
|
-
|
32
|
-
graphql = ElasticGraph::GraphQL.from_yaml_file("path/to/config.yaml")
|
33
|
-
run ElasticGraph::Rack::GraphiQL.new(graphql)
|
34
|
-
```
|
35
|
-
|
36
|
-
Run this with `rackup` (after installing the `rackup` gem) or any other rack-compatible server.
|
37
|
-
|
38
|
-
## License
|
39
|
-
|
40
|
-
elasticgraph-rack is released under the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
[Part of the distributed code](lib/elastic_graph/rack/graphiql/index.html)
|
43
|
-
comes from the [GraphiQL project](https://github.com/graphql/graphiql), also licensed under the
|
44
|
-
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.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.0.0.
|
20
|
+
version: 1.0.0.rc3
|
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.rc3
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: '3.1'
|
35
35
|
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 3.1.
|
37
|
+
version: 3.1.16
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,77 +44,63 @@ dependencies:
|
|
44
44
|
version: '3.1'
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.1.
|
47
|
+
version: 3.1.16
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: elasticgraph-admin
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.0.
|
54
|
+
version: 1.0.0.rc3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0.
|
61
|
+
version: 1.0.0.rc3
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: elasticgraph-elasticsearch
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.0.
|
68
|
+
version: 1.0.0.rc3
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0.
|
75
|
+
version: 1.0.0.rc3
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: elasticgraph-opensearch
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0.
|
82
|
+
version: 1.0.0.rc3
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0.
|
89
|
+
version: 1.0.0.rc3
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: elasticgraph-indexer
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0.
|
96
|
+
version: 1.0.0.rc3
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0.0.
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: rack-test
|
106
|
-
requirement: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '2.2'
|
111
|
-
type: :development
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '2.2'
|
103
|
+
version: 1.0.0.rc3
|
118
104
|
email:
|
119
105
|
- myron@squareup.com
|
120
106
|
executables: []
|
@@ -124,19 +110,16 @@ files:
|
|
124
110
|
- LICENSE.txt
|
125
111
|
- README.md
|
126
112
|
- lib/elastic_graph/rack.rb
|
127
|
-
- lib/elastic_graph/rack/graphiql.rb
|
128
|
-
- lib/elastic_graph/rack/graphiql/README.md
|
129
|
-
- lib/elastic_graph/rack/graphiql/index.html
|
130
113
|
- lib/elastic_graph/rack/graphql_endpoint.rb
|
131
114
|
homepage: https://block.github.io/elasticgraph/
|
132
115
|
licenses:
|
133
116
|
- MIT
|
134
117
|
metadata:
|
135
118
|
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
136
|
-
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.
|
137
|
-
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.
|
119
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.rc3
|
120
|
+
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.rc3/
|
138
121
|
homepage_uri: https://block.github.io/elasticgraph/
|
139
|
-
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.
|
122
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.rc3/elasticgraph-rack
|
140
123
|
gem_category: local
|
141
124
|
rdoc_options: []
|
142
125
|
require_paths:
|
@@ -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
|