altair-rails 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 073d47c7db152d67e61edaa10a53289026a6816ef6da55036223239f2516fa7e
4
- data.tar.gz: b93b8ad0b079abfaae4807e2c9ab331c103a8bd0ee35a17d8dcf4afe70c680fb
3
+ metadata.gz: 12e6e222762759b0a6f2152bebba6843b6aefdc5e0011b2e411c67520f7e512a
4
+ data.tar.gz: 4c13d79a2d3d412079fc6788f3dc6e2227c548010dfb12d2f867fc4a1bf20fc9
5
5
  SHA512:
6
- metadata.gz: dfa4259a2aaf0e57a72e0d88d9726ab5c2608b35c79e96a5a6c96de8ae08e081dadef221a9e314abc12c0bee5f8003a53efb07198528faa0cac77f8bca4e3f01
7
- data.tar.gz: bf0bda9c47faf2d8d097c28240db179e62470ba3418ffff1077a17b5db0a00d2ca84f16cad53ff1da2504f9b0892e153d7d33335aa4e799bcecab7a1d937bc62
6
+ metadata.gz: 5c984089da04c2718f3153036d4e1168b180356d7908625e9d3759695ad23019835d114181a64970a79e40f87afd33d2cab9a517ddce36e4dc4b730599c45916
7
+ data.tar.gz: 4d9fad827e9325cfaeb6e0649ec09300e044223a73727a71f163588b689c2bca22d38bc0935ed8305311c0503c0def3259cc51b70570ede44d0939094560f883
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Altair Rails - The Altair GraphQL Client for Rails
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/altair-rails.svg)](https://badge.fury.io/rb/altair-rails)
4
- [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/22128c5c828a8eed6f95/maintainability)](https://codeclimate.com/github/jejacks0n/altair-rails/maintainability)
3
+ [![Gem Version](https://img.shields.io/gem/v/altair-rails.svg?label=gem%20version)](https://rubygems.org/gems/altair-rails)
4
+ [![MIT License](https://img.shields.io/github/license/jejacks0n/altair-rails.svg)](https://opensource.org/licenses/MIT)
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/jejacks0n/altair-rails/ci.yml.svg?label=build%20status)](https://github.com/jejacks0n/altair-rails/actions/workflows/ci.yml)
6
+ [![Maintainability](https://img.shields.io/codeclimate/coverage-letter/jejacks0n/altair-rails.svg?label=maintainability)](https://codeclimate.com/github/jejacks0n/altair-rails/maintainability)
7
+ [![Test Coverage](https://img.shields.io/codeclimate/coverage/jejacks0n/altair-rails.svg?label=test%20coverage)](https://codeclimate.com/github/jejacks0n/altair-rails/test_coverage)
8
+ [![RubyGems](https://img.shields.io/gem/dt/altair-rails.svg?label=rubygems%20downloads)](https://rubygems.org/gems/altair-rails)
6
9
 
7
10
  Altair Rails is a Rails engine that provides a mountable endpoint for the [Altair GraphQL Client](https://altairgraphql.dev/).
8
11
 
@@ -49,12 +52,22 @@ Altair::Rails.configure do |config|
49
52
  end
50
53
  ```
51
54
 
55
+ ## Similar Projects
56
+
57
+ I created this project after battling GraphQL subscriptions, and GraphiQLs lack of support for ActionCable.
58
+
59
+ That being said, there are still great projects worth checking out:
60
+
61
+ - [graphiql-rails](https://github.com/rmosolgo/graphiql-rails) - A Rails engine that provides a mountable endpoint for GraphiQL.
62
+
52
63
  ## License
53
64
 
54
- Active Experiment is released under the MIT license:
65
+ This project is released under the MIT license:
55
66
 
56
67
  * https://opensource.org/licenses/MIT
57
68
 
58
69
  Copyright 2023 [jejacks0n](https://github.com/jejacks0n)
59
70
 
60
- ## Make Code Not War
71
+ ## Make Code Not War
72
+
73
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)
@@ -5,14 +5,19 @@ module Altair
5
5
  class Configuration
6
6
  include Singleton
7
7
 
8
- cattr_accessor(*[:mount_at, :graphql_path, :action_cable_path, :altair_options, :altair_version])
8
+ cattr_accessor(*[
9
+ :mount_at,
10
+ :graphql_path,
11
+ :action_cable_path,
12
+ :altair_options,
13
+ :altair_version,
14
+ :altair_template
15
+ ])
9
16
 
10
17
  # Where you want to mount the engine in your application. If set to nil,
11
18
  # the engine will not be mounted automatically and it will need to be
12
19
  # mounted manually. E.g.: in your routes.rb file, adding:
13
20
  # mount Altair::Rails::Engine => "/altair"`
14
- #
15
- # Defaults to "/altair".
16
21
  @@mount_at = "/altair"
17
22
 
18
23
  # The path to your GraphQL endpoint. This is used to set the endpointURL.
@@ -29,6 +34,54 @@ module Altair
29
34
  # Generally this should be left to the release version of altair-rails,
30
35
  # but if you really want, you can override it here.
31
36
  @@altair_version = "5.0.28" # Altair::Rails.version
37
+
38
+ # Generally this should be left to the release version of altair-rails,
39
+ # but if you really want, you can override it here.
40
+ @@altair_template = ->(env) do
41
+ [200, {}, <<~HTML_BODY]
42
+ <!DOCTYPE html>
43
+ <html>
44
+ <head>
45
+ <meta charset="utf-8" />
46
+ <title>Altair</title>
47
+ <base href="https://cdn.jsdelivr.net/npm/altair-static@#{altair_version}/build/dist/">
48
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
49
+ <link href="styles.css" rel="stylesheet" />
50
+ <style>.loading-screen { display: none }</style>
51
+ </head>
52
+ <body>
53
+ <script>
54
+ // window.__ALTAIR_WEB_APP__ = 1;
55
+ const defaultOptions = {
56
+ endpointURL: window.location.origin + "#{graphql_path}",
57
+ subscriptionsEndpoint: "ws://" + window.location.host + "#{action_cable_path}",
58
+ initialSubscriptionsProvider: "action-cable"
59
+ };
60
+ document.addEventListener('DOMContentLoaded', function() {
61
+ AltairGraphQL.init(Object.assign({}, defaultOptions, #{altair_options.to_json}));
62
+ });
63
+ </script>
64
+ <app-root>
65
+ <div class="loading-screen styled">
66
+ <div class="loading-screen-inner">
67
+ <div class="loading-screen-logo-container">
68
+ <img src="assets/img/logo_350.svg" alt="Altair" />
69
+ </div>
70
+ <div class="loading-screen-loading-indicator">
71
+ <span class="loading-indicator-dot"></span>
72
+ <span class="loading-indicator-dot"></span>
73
+ <span class="loading-indicator-dot"></span>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </app-root>
78
+ <script rel="preload" as="script" type="text/javascript" src="runtime.js"></script>
79
+ <script rel="preload" as="script" type="text/javascript" src="polyfills.js" ></script>
80
+ <script rel="preload" as="script" type="text/javascript" src="main.js" ></script>
81
+ </body>
82
+ </html>
83
+ HTML_BODY
84
+ end
32
85
  end
33
86
 
34
87
  mattr_accessor :configuration
@@ -5,59 +5,15 @@ module Altair
5
5
  class Engine < ::Rails::Engine
6
6
  isolate_namespace Altair::Rails
7
7
 
8
- altair_rails = Altair::Rails.configuration
8
+ routes { root to: Altair::Rails.configuration.altair_template }
9
9
 
10
- if altair_rails.mount_at.present?
10
+ if Altair::Rails.configuration.mount_at.present?
11
11
  config.after_initialize do |app|
12
- app.routes.prepend { mount Altair::Rails::Engine => altair_rails.mount_at }
12
+ app.routes.prepend do
13
+ mount(Engine, at: Altair::Rails.configuration.mount_at, as: :altair)
14
+ end
13
15
  end
14
16
  end
15
-
16
- routes do
17
- root to: ->(_) { [200, {}, <<~HTML_BODY] }
18
- <!DOCTYPE html>
19
- <html>
20
- <head>
21
- <meta charset="utf-8" />
22
- <title>Altair</title>
23
- <base href="https://cdn.jsdelivr.net/npm/altair-static@#{altair_rails.altair_version}/build/dist/">
24
- <meta name="viewport" content="width=device-width,initial-scale=1" />
25
- <link href="styles.css" rel="stylesheet" />
26
- <style>.loading-screen { display: none }</style>
27
- </head>
28
- <body>
29
- <script>
30
- // window.__ALTAIR_WEB_APP__ = 1;
31
- const defaultOptions = {
32
- endpointURL: window.location.origin + "#{altair_rails.graphql_path}",
33
- subscriptionsEndpoint: "ws://" + window.location.host + "#{altair_rails.action_cable_path}",
34
- initialSubscriptionsProvider: "action-cable"
35
- };
36
- document.addEventListener('DOMContentLoaded', function() {
37
- AltairGraphQL.init(Object.assign({}, defaultOptions, #{altair_rails.altair_options.to_json}));
38
- });
39
- </script>
40
- <app-root>
41
- <div class="loading-screen styled">
42
- <div class="loading-screen-inner">
43
- <div class="loading-screen-logo-container">
44
- <img src="assets/img/logo_350.svg" alt="Altair" />
45
- </div>
46
- <div class="loading-screen-loading-indicator">
47
- <span class="loading-indicator-dot"></span>
48
- <span class="loading-indicator-dot"></span>
49
- <span class="loading-indicator-dot"></span>
50
- </div>
51
- </div>
52
- </div>
53
- </app-root>
54
- <script rel="preload" as="script" type="text/javascript" src="runtime.js"></script>
55
- <script rel="preload" as="script" type="text/javascript" src="polyfills.js" ></script>
56
- <script rel="preload" as="script" type="text/javascript" src="main.js" ></script>
57
- </body>
58
- </html>
59
- HTML_BODY
60
- end
61
17
  end
62
18
  end
63
- end
19
+ end
@@ -2,8 +2,7 @@
2
2
 
3
3
  module Altair
4
4
  module Rails
5
- # Returns the currently loaded version of Active Experiment as a
6
- # +Gem::Version+.
5
+ # Returns the currently loaded version as a +Gem::Version+.
7
6
  def self.version
8
7
  Gem::Version.new(VERSION::STRING)
9
8
  end
@@ -11,10 +10,10 @@ module Altair
11
10
  module VERSION
12
11
  MAJOR = 0
13
12
  MINOR = 0
14
- TINY = 2
13
+ TINY = 4
15
14
  PRE = nil
16
15
 
17
16
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
17
  end
19
18
  end
20
- end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: altair-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Jackson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-22 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.4.14
66
+ rubygems_version: 3.4.17
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: Altair GraphQL Client for Rails.