graphiql-rails 1.4.10 → 1.4.11
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/app/views/graphiql/rails/editors/show.html.erb +19 -14
- data/lib/graphiql/rails/config.rb +4 -2
- data/lib/graphiql/rails/version.rb +1 -1
- data/readme.md +2 -0
- data/test/controllers/editors_controller_test.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff226393a4c410b3b878c08e575263986ce4f74e
|
4
|
+
data.tar.gz: 807dae7778cee2858de34d13b195beb64486d5b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad1b9740f79b7598f1c6dd02a53a829dc4f8655f1d5465d469e8fc4641eb1463b321d1948f3309164ffb154c9f69a9d12dade311af136a58014cc4ca13553de
|
7
|
+
data.tar.gz: acf71512277755b51e426e8994affa67364c83f9964926806421a557afc70ed57c437aa975d26d5276a2405427a11b6bf00a91269f0097577f43fc432c2a4f36
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title
|
4
|
+
<title><%= GraphiQL::Rails.config.title || 'GraphiQL' %></title>
|
5
|
+
|
5
6
|
<%= stylesheet_link_tag("graphiql/rails/application") %>
|
6
7
|
<%= javascript_include_tag("graphiql/rails/application") %>
|
7
8
|
</head>
|
@@ -60,14 +61,13 @@
|
|
60
61
|
body: JSON.stringify(graphQLParams),
|
61
62
|
credentials: 'include',
|
62
63
|
}).then(function(response) {
|
63
|
-
return response.text();
|
64
|
-
}).then(function(text) {
|
65
64
|
try {
|
66
|
-
return
|
65
|
+
return response.json();
|
67
66
|
} catch(error) {
|
68
67
|
return {
|
68
|
+
"status": response.status,
|
69
69
|
"message": "The server responded with invalid JSON, this is probably a server-side error",
|
70
|
-
"response": text,
|
70
|
+
"response": response.text(),
|
71
71
|
};
|
72
72
|
}
|
73
73
|
})
|
@@ -81,16 +81,21 @@
|
|
81
81
|
|
82
82
|
// Render <GraphiQL /> into the body.
|
83
83
|
ReactDOM.render(
|
84
|
-
React.createElement(GraphiQL,
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
React.createElement(GraphiQL,
|
85
|
+
{
|
86
|
+
fetcher: graphQLFetcher,
|
87
|
+
defaultQuery: defaultQuery,
|
88
|
+
<% if GraphiQL::Rails.config.query_params %>
|
89
|
+
query: parameters.query,
|
90
|
+
variables: parameters.variables,
|
91
|
+
onEditQuery: onEditQuery,
|
92
|
+
onEditVariables: onEditVariables
|
93
|
+
<% end %>
|
94
|
+
},
|
95
|
+
<% if GraphiQL::Rails.config.logo %>
|
96
|
+
React.createElement(GraphiQL.Logo, {}, "<%= GraphiQL::Rails.config.logo %>")
|
92
97
|
<% end %>
|
93
|
-
|
98
|
+
),
|
94
99
|
document.getElementById("graphiql-container")
|
95
100
|
);
|
96
101
|
</script>
|
@@ -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
|
10
|
+
attr_accessor :query_params, :initial_query, :csrf, :title, :logo
|
11
11
|
|
12
12
|
DEFAULT_HEADERS = {
|
13
13
|
'Content-Type' => ->(_) { 'application/json' },
|
@@ -17,10 +17,12 @@ 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, csrf: true, headers: DEFAULT_HEADERS)
|
20
|
+
def initialize(query_params: false, initial_query: nil, title: nil, logo: nil, csrf: true, headers: DEFAULT_HEADERS)
|
21
21
|
@query_params = query_params
|
22
22
|
@headers = headers.dup
|
23
23
|
@initial_query = initial_query
|
24
|
+
@title = title
|
25
|
+
@logo = logo
|
24
26
|
@csrf = csrf
|
25
27
|
end
|
26
28
|
|
data/readme.md
CHANGED
@@ -37,6 +37,8 @@ You can override `GraphiQL::Rails.config` values in an initializer (eg, `config/
|
|
37
37
|
|
38
38
|
- `query_params` (boolean, default `false`): if `true`, the GraphQL query string will be persisted the page's query params
|
39
39
|
- `initial_query` (string, default `nil`): if provided, it will be rendered in the query pane for a visitor's first visit
|
40
|
+
- `title` (string, default `nil`): if provided, it will be rendered in the page <title> tag
|
41
|
+
- `logo` (string, default `nil`): if provided, it will be the text logo
|
40
42
|
- `csrf` (boolean, default `true`): include `X-CSRF-Token` in GraphiQL's HTTP requests
|
41
43
|
- `headers` (hash, `String => Proc`): procs to fetch header values for GraphiQL's HTTP requests, in the form `(view_context) -> { ... }`. For example:
|
42
44
|
|
@@ -10,6 +10,8 @@ module GraphiQL
|
|
10
10
|
teardown do
|
11
11
|
GraphiQL::Rails.config.query_params = false
|
12
12
|
GraphiQL::Rails.config.initial_query = nil
|
13
|
+
GraphiQL::Rails.config.title = nil
|
14
|
+
GraphiQL::Rails.config.logo = nil
|
13
15
|
GraphiQL::Rails.config.headers = {}
|
14
16
|
end
|
15
17
|
|
@@ -35,6 +37,26 @@ module GraphiQL
|
|
35
37
|
refute_includes(@response.body, '"{ customQuery(id: \"123\") }"')
|
36
38
|
end
|
37
39
|
|
40
|
+
test "it uses title config" do
|
41
|
+
GraphiQL::Rails.config.title = 'Custom Title'
|
42
|
+
get :show, graphql_params
|
43
|
+
assert_includes(@response.body, '<title>Custom Title</title>')
|
44
|
+
|
45
|
+
GraphiQL::Rails.config.title = nil
|
46
|
+
get :show, graphql_params
|
47
|
+
assert_includes(@response.body, '<title>GraphiQL</title>')
|
48
|
+
end
|
49
|
+
|
50
|
+
test "it uses logo config" do
|
51
|
+
GraphiQL::Rails.config.logo = 'Custom Logo'
|
52
|
+
get :show, graphql_params
|
53
|
+
assert_includes(@response.body, 'React.createElement(GraphiQL.Logo, {}, "Custom Logo")')
|
54
|
+
|
55
|
+
GraphiQL::Rails.config.logo = nil
|
56
|
+
get :show, graphql_params
|
57
|
+
refute_includes(@response.body, 'React.createElement(GraphiQL.Logo, {}, "Custom Logo")')
|
58
|
+
end
|
59
|
+
|
38
60
|
test "it uses query_params config" do
|
39
61
|
get :show, graphql_params
|
40
62
|
refute_includes(@response.body, "onEditQuery")
|
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.4.
|
4
|
+
version: 1.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|