graphiql-rails 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,9 @@
4
4
  <title>GraphiQL</title>
5
5
  <%= stylesheet_link_tag("graphiql/rails/application") %>
6
6
  <%= javascript_include_tag("graphiql/rails/application") %>
7
+ <% if GraphiQL::Rails.config.csrf %>
8
+ <%= csrf_meta_tags %>
9
+ <% end %>
7
10
  </head>
8
11
  <body>
9
12
  <div id="graphiql-container">
@@ -59,6 +62,11 @@
59
62
  return fetch(graphQLEndpoint, {
60
63
  method: 'post',
61
64
  headers: { 'Content-Type': 'application/json' },
65
+ headers: { 'Content-Type': 'application/json',
66
+ <% if GraphiQL::Rails.config.csrf %>
67
+ 'X-CSRF-Token': document.getElementsByName("csrf-token")[0].content
68
+ <% end %>
69
+ },
62
70
  body: JSON.stringify(graphQLParams),
63
71
  credentials: 'include',
64
72
  }).then(function (response) {
@@ -24,7 +24,8 @@ module GraphiQL
24
24
 
25
25
  self.config = OpenStruct.new({
26
26
  query_params: false,
27
- initial_query: GraphiQL::Rails::WELCOME_MESSAGE
27
+ initial_query: GraphiQL::Rails::WELCOME_MESSAGE,
28
+ csrf: false
28
29
  })
29
30
  end
30
31
  end
@@ -1,5 +1,5 @@
1
1
  module GraphiQL
2
2
  module Rails
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/readme.md CHANGED
@@ -39,6 +39,7 @@ You can override `GraphiQL::Rails` configs in an initializer (eg, `config/initia
39
39
  # These are the default values:
40
40
  GraphiQL::Rails.config.query_params = false # if true, the GraphQL query string will be persisted the page's query params.
41
41
  GraphiQL::Rails.config.initial_query = GraphiQL::Rails::WELCOME_MESSAGE # This string is presented to a new user
42
+ GraphiQL::Rails.config.csrf = false # if true, CSRF token will added and sent along with POST request to the GraphQL endpoint
42
43
  ```
43
44
 
44
45
  ## To-do
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.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -118,11 +118,11 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - app/assets/javascripts/graphiql/rails/application.js
120
120
  - app/assets/javascripts/graphiql/rails/fetch-0.10.1.js
121
- - app/assets/javascripts/graphiql/rails/graphiql-0.4.5.js
121
+ - app/assets/javascripts/graphiql/rails/graphiql-0.6.6.js
122
122
  - app/assets/javascripts/graphiql/rails/react-0.14.4.js
123
123
  - app/assets/javascripts/graphiql/rails/react-dom-0.14.4.js
124
124
  - app/assets/stylesheets/graphiql/rails/application.css
125
- - app/assets/stylesheets/graphiql/rails/graphiql-0.4.5.css
125
+ - app/assets/stylesheets/graphiql/rails/graphiql-0.6.6.css
126
126
  - app/controllers/graphiql/rails/editors_controller.rb
127
127
  - app/views/graphiql/rails/editors/show.html.erb
128
128
  - config/routes.rb
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.4.5
204
+ rubygems_version: 2.5.1
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: A mountable GraphiQL endpoint for Rails