graphql_playground 0.0.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.
- checksums.yaml +7 -0
- data/README.md +53 -0
- data/lib/graphql_playground.rb +26 -0
- data/lib/templates/index.html.erb +69 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0c1e898b431a64c5ee65c1e03770450b83a90ac1fa914ec58b99eecb2e5f257f
|
|
4
|
+
data.tar.gz: a6aa590d07067bac2156488dce4ae20364b890939cda99b8bd372e7c48788aed
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5bc462eeedf9aa5860806477ffc1037f8aee8e94d79fb026829a307e609cca46a61ece007a8f6639831dbb71d896058a3b0d64c86aa56aae20f1609ecf19dca3
|
|
7
|
+
data.tar.gz: c7a385fffd648f0738f5bf6ebe4208f95b565b27e49d34ce310f74bb782ad981a4bb3f37c04ce898c5131395e29293a78d840b14b593cc609aea5375984ecf11
|
data/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
This gem is a simple middleware wrapper for [GraphQL Playground](https://github.com/prisma/graphql-playground), a GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
gem install graphql_playground
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
If you use rack, you can mount it like this
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'graphql_playground'
|
|
13
|
+
|
|
14
|
+
map '/playground' do
|
|
15
|
+
use GraphQLPlayground, endpoint: '/graphql' # endpoint to your graphql server endpoint
|
|
16
|
+
end
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example using graphql_server gem
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
# app.ru
|
|
23
|
+
require 'graphql_playground'
|
|
24
|
+
require 'graphql_server'
|
|
25
|
+
|
|
26
|
+
type_def = <<-GRAPHQL
|
|
27
|
+
type Query {
|
|
28
|
+
hello: String
|
|
29
|
+
}
|
|
30
|
+
GRAPHQL
|
|
31
|
+
|
|
32
|
+
resolver = {
|
|
33
|
+
"Query" => {
|
|
34
|
+
"hello" => Proc.new { "world" }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
map '/playground' do
|
|
39
|
+
use GraphQLPlayground
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
run GraphqlServer.new(type_def: type_def, resolver: resolver)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Launch it with
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
rackup app.ru
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
And then open http://localhost:9292/playground
|
|
52
|
+
|
|
53
|
+
(Reference https://github.com/betaflag/graphql-server-ruby)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class GraphQLPlayground
|
|
4
|
+
CDN_URL = '//cdn.jsdelivr.net/npm'
|
|
5
|
+
|
|
6
|
+
# Initialize the middleware
|
|
7
|
+
#
|
|
8
|
+
# @param string cdn_url The CDN url for graphql playground (defaults to the official release)
|
|
9
|
+
# @param string version The version of the graphql playground to use (defaults to latest)
|
|
10
|
+
# @param string endpoint The endpoint of your graphql server
|
|
11
|
+
def initialize(app = nil, cdn_url: CDN_URL, version: '', endpoint: '/')
|
|
12
|
+
@app = app
|
|
13
|
+
@cdn_url = cdn_url
|
|
14
|
+
@version = version
|
|
15
|
+
@endpoint = endpoint
|
|
16
|
+
@index_template = File.read(template('index.html.erb'))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def template(path)
|
|
20
|
+
File.expand_path("templates/#{path}", __dir__)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def call(env)
|
|
24
|
+
['200', {'Content-Type' => 'text/html'}, [ERB.new(@index_template).result(binding)]]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset=utf-8 />
|
|
5
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
|
|
6
|
+
<link rel="shortcut icon" href="https://graphcool-playground.netlify.com/favicon.png">
|
|
7
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700" rel="stylesheet">
|
|
8
|
+
<title>GraphQL Playground</title>
|
|
9
|
+
<link rel="stylesheet" href="<%= @cdn_url %>/graphql-playground-react<%= @version %>/build/static/css/index.css" />
|
|
10
|
+
<link rel="shortcut icon" href="<%= @cdn_url %>/graphql-playground-react<%= @version %>/build/favicon.png" />
|
|
11
|
+
<script src="<%= @cdn_url %>/graphql-playground-react<%= @version %>/build/static/js/middleware.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<style type="text/css">
|
|
15
|
+
html {
|
|
16
|
+
font-family: "Open Sans", sans-serif;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
body {
|
|
21
|
+
margin: 0;
|
|
22
|
+
background: #172a3a;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.playgroundIn {
|
|
26
|
+
-webkit-animation: playgroundIn 0.5s ease-out forwards;
|
|
27
|
+
animation: playgroundIn 0.5s ease-out forwards;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@-webkit-keyframes playgroundIn {
|
|
31
|
+
from {
|
|
32
|
+
opacity: 0;
|
|
33
|
+
-webkit-transform: translateY(10px);
|
|
34
|
+
-ms-transform: translateY(10px);
|
|
35
|
+
transform: translateY(10px);
|
|
36
|
+
}
|
|
37
|
+
to {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
-webkit-transform: translateY(0);
|
|
40
|
+
-ms-transform: translateY(0);
|
|
41
|
+
transform: translateY(0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@keyframes playgroundIn {
|
|
46
|
+
from {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
-webkit-transform: translateY(10px);
|
|
49
|
+
-ms-transform: translateY(10px);
|
|
50
|
+
transform: translateY(10px);
|
|
51
|
+
}
|
|
52
|
+
to {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
-webkit-transform: translateY(0);
|
|
55
|
+
-ms-transform: translateY(0);
|
|
56
|
+
transform: translateY(0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
<div id="root" />
|
|
61
|
+
<script type="text/javascript">
|
|
62
|
+
window.addEventListener('load', function (event) {
|
|
63
|
+
const root = document.getElementById('root');
|
|
64
|
+
root.classList.add('playgroundIn');
|
|
65
|
+
GraphQLPlayground.init(root, { endpoint: '<%= @endpoint %>' })
|
|
66
|
+
})
|
|
67
|
+
</script>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: graphql_playground
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- betaflag
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A rack middleware wrapper for GraphQL Playground
|
|
14
|
+
email: hello@betaflag.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- lib/graphql_playground.rb
|
|
21
|
+
- lib/templates/index.html.erb
|
|
22
|
+
homepage: https://github.com/betaflag/graphql-playground-ruby
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 2.2.0
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 2.7.6
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: A rack middleware wrapper for GraphQL Playground
|
|
46
|
+
test_files: []
|