graphql_scaffold_fan 0.1.4 → 0.1.7

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: 84f167b5a1e8c21a585366673d66334bf50ef2b1a7c7734bad0876c1688fbaab
4
- data.tar.gz: d7b35e8aa095be976130c52cc3cfd76b46dcb95af51a3d37d5578b705f56fde8
3
+ metadata.gz: 72714862b9f0922c1836a6ff8e70f4c19d7a758cad55cbd41e239dcb2e609486
4
+ data.tar.gz: 01a8cf74e2319f31611ff818d63e6c58b27f746b63d12546533647593e62b81c
5
5
  SHA512:
6
- metadata.gz: 2866addc1ca028afc26af9017467d623c4010d574183d5cddb0a0a0e2fb7ba42b52fcc9dd5b2b437893b41545df0df7c5023adfd09e805fbfc9d38250a741331
7
- data.tar.gz: 284f2af7999e7e3fb32cffeeecb828f567a8e566ac0f7e3fa930d65d79f59484d9c7ae8e5e7c18cff138bfbc0d46beddd478873117bcc84cee34d67529c7f3be
6
+ metadata.gz: a5fc720f4825e05623c0e81a511778a9b05664920455063fb2ac859f411df0fb5c92504060c17f85efd8cba09b7d4fb30013379b737a0a0d7cdca100d71c16d2
7
+ data.tar.gz: 9281a9f5d78e069f7f76e6761c49a874450a318898358147f8b4c1801b346228a9e006ba1f71295195a6d8f5298a2b99d0ba6937ad89b8abc8f16c79586db148
data/Gemfile.lock CHANGED
@@ -1,17 +1,145 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_scaffold_fan (0.1.4)
4
+ graphql_scaffold_fan (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ actioncable (6.1.6.1)
10
+ actionpack (= 6.1.6.1)
11
+ activesupport (= 6.1.6.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.1.6.1)
15
+ actionpack (= 6.1.6.1)
16
+ activejob (= 6.1.6.1)
17
+ activerecord (= 6.1.6.1)
18
+ activestorage (= 6.1.6.1)
19
+ activesupport (= 6.1.6.1)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.1.6.1)
22
+ actionpack (= 6.1.6.1)
23
+ actionview (= 6.1.6.1)
24
+ activejob (= 6.1.6.1)
25
+ activesupport (= 6.1.6.1)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.1.6.1)
29
+ actionview (= 6.1.6.1)
30
+ activesupport (= 6.1.6.1)
31
+ rack (~> 2.0, >= 2.0.9)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.1.6.1)
36
+ actionpack (= 6.1.6.1)
37
+ activerecord (= 6.1.6.1)
38
+ activestorage (= 6.1.6.1)
39
+ activesupport (= 6.1.6.1)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.1.6.1)
42
+ activesupport (= 6.1.6.1)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.1.6.1)
48
+ activesupport (= 6.1.6.1)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.1.6.1)
51
+ activesupport (= 6.1.6.1)
52
+ activerecord (6.1.6.1)
53
+ activemodel (= 6.1.6.1)
54
+ activesupport (= 6.1.6.1)
55
+ activestorage (6.1.6.1)
56
+ actionpack (= 6.1.6.1)
57
+ activejob (= 6.1.6.1)
58
+ activerecord (= 6.1.6.1)
59
+ activesupport (= 6.1.6.1)
60
+ marcel (~> 1.0)
61
+ mini_mime (>= 1.1.0)
62
+ activesupport (6.1.6.1)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 1.6, < 2)
65
+ minitest (>= 5.1)
66
+ tzinfo (~> 2.0)
67
+ zeitwerk (~> 2.3)
68
+ builder (3.2.4)
69
+ concurrent-ruby (1.1.10)
70
+ crass (1.0.6)
71
+ erubi (1.10.0)
72
+ globalid (1.0.0)
73
+ activesupport (>= 5.0)
74
+ graphql (2.0.11)
75
+ graphql_playground-rails (2.1.0)
76
+ rails (>= 5.1.0)
77
+ i18n (1.12.0)
78
+ concurrent-ruby (~> 1.0)
79
+ loofah (2.18.0)
80
+ crass (~> 1.0.2)
81
+ nokogiri (>= 1.5.9)
82
+ mail (2.7.1)
83
+ mini_mime (>= 0.1.1)
84
+ marcel (1.0.2)
85
+ method_source (1.0.0)
86
+ mini_mime (1.1.2)
87
+ minitest (5.16.2)
88
+ nio4r (2.5.8)
89
+ nokogiri (1.13.7-x86_64-darwin)
90
+ racc (~> 1.4)
91
+ racc (1.6.0)
92
+ rack (2.2.4)
93
+ rack-test (2.0.2)
94
+ rack (>= 1.3)
95
+ rails (6.1.6.1)
96
+ actioncable (= 6.1.6.1)
97
+ actionmailbox (= 6.1.6.1)
98
+ actionmailer (= 6.1.6.1)
99
+ actionpack (= 6.1.6.1)
100
+ actiontext (= 6.1.6.1)
101
+ actionview (= 6.1.6.1)
102
+ activejob (= 6.1.6.1)
103
+ activemodel (= 6.1.6.1)
104
+ activerecord (= 6.1.6.1)
105
+ activestorage (= 6.1.6.1)
106
+ activesupport (= 6.1.6.1)
107
+ bundler (>= 1.15.0)
108
+ railties (= 6.1.6.1)
109
+ sprockets-rails (>= 2.0.0)
110
+ rails-dom-testing (2.0.3)
111
+ activesupport (>= 4.2.0)
112
+ nokogiri (>= 1.6)
113
+ rails-html-sanitizer (1.4.3)
114
+ loofah (~> 2.3)
115
+ railties (6.1.6.1)
116
+ actionpack (= 6.1.6.1)
117
+ activesupport (= 6.1.6.1)
118
+ method_source
119
+ rake (>= 12.2)
120
+ thor (~> 1.0)
9
121
  rake (13.0.6)
122
+ sprockets (4.1.1)
123
+ concurrent-ruby (~> 1.0)
124
+ rack (> 1, < 3)
125
+ sprockets-rails (3.4.2)
126
+ actionpack (>= 5.2)
127
+ activesupport (>= 5.2)
128
+ sprockets (>= 3.0.0)
129
+ thor (1.2.1)
130
+ tzinfo (2.0.4)
131
+ concurrent-ruby (~> 1.0)
132
+ websocket-driver (0.7.5)
133
+ websocket-extensions (>= 0.1.0)
134
+ websocket-extensions (0.1.5)
135
+ zeitwerk (2.6.0)
10
136
 
11
137
  PLATFORMS
12
138
  x86_64-darwin-20
13
139
 
14
140
  DEPENDENCIES
141
+ graphql
142
+ graphql_playground-rails
15
143
  graphql_scaffold_fan!
16
144
  rake (~> 13.0)
17
145
 
data/README.md CHANGED
@@ -9,7 +9,6 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'graphql'
13
12
  gem 'graphql_scaffold_fan'
14
13
  ```
15
14
 
@@ -25,10 +24,18 @@ Or install it yourself as:
25
24
 
26
25
  Run `rails generate -h` to see if the GraphqlScaffold genertors have been loaded correctly
27
26
  Example commands:
28
- `rails generate graphql_scaffold:init <ProjectName>` Initial command will use the root folder name as its ProjectName, so be free to enter any character here.
27
+ `rails generate graphql_scaffold:init <ProjectName>`
28
+
29
29
  `rails generate graphql_scaffold:mutation <MutationName>`
30
+
30
31
  `rails generate graphql_scaffold:type <TypeName>`
31
32
 
33
+ If you ever found mutation not loading in schema: pls check the following code
34
+ `config.load_defaults 6.1`
35
+ `# config.autoloader = :zeitwerk`
36
+ Reference link:
37
+ https://guides.rubyonrails.org/classic_to_zeitwerk_howto.html
38
+
32
39
 
33
40
  ## Development
34
41
 
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  # Uncomment to register a new dependency of your gem
25
25
  # spec.add_dependency "example-gem", "~> 1.0"
26
-
26
+ spec.add_development_dependency 'graphql_playground-rails'
27
+ spec.add_development_dependency 'graphql'
27
28
  # For more information and examples about making a new gem, checkout our
28
29
  # guide at: https://bundler.io/guides/creating_gem.html
29
30
  end
@@ -30,7 +30,6 @@ module GraphqlScaffold
30
30
  end
31
31
 
32
32
  def create_admin_controller_file
33
- @top_folder_name = File.basename(Dir.getwd)
34
33
  dir_path = 'app/controllers'
35
34
  file_path = dir_path + '/admin_graphql_controller.rb'
36
35
  FileUtils.mkdir_p(dir_path) unless File.exist?(dir_path)
@@ -41,6 +40,23 @@ module GraphqlScaffold
41
40
  template 'admin_controller.haml', file_path
42
41
  end
43
42
  end
43
+
44
+ def add_route
45
+ route_dir_path = 'config'
46
+ route_file_path = route_dir_path + '/routes.rb'
47
+
48
+ FileUtils.mkdir_p(route_dir_path) unless File.exist?(route_dir_path)
49
+
50
+ if File.exist?(route_file_path)
51
+ file = File.open(route_file_path)
52
+ file_data = file.read
53
+ new_file_data = file_data.insert(-6, "\n mount GraphqlPlayground::Rails::Engine, at: '/graphiql_admin', graphql_path: 'api/admin/graphql', as: :admin_graphiql\n post 'api/admin/graphql', to: 'graphql_admin#execute'")
54
+ File.write(file, new_file_data)
55
+ p 'Write to routes.rb successfully'
56
+ else
57
+ p 'Please create routes.rb file under config folder firstly'
58
+ end
59
+ end
44
60
  end
45
61
  end
46
62
  end
@@ -7,7 +7,6 @@ class AdminGraphqlController < ApplicationController
7
7
  # This allows for outside API access while preventing CSRF attacks,
8
8
  # but you'll have to authenticate your user separately
9
9
  protect_from_forgery with: :null_session
10
- after_action :track_action
11
10
 
12
11
  def execute
13
12
  variables = prepare_variables(params[:variables])
@@ -18,7 +17,7 @@ class AdminGraphqlController < ApplicationController
18
17
 
19
18
  @current_resource = context[:current_resource]
20
19
 
21
- result = <%= @top_folder_name.camelize %>AdminSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
20
+ result = <%= class_name %>AdminSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
22
21
  render json: result
23
22
  rescue StandardError => e
24
23
  raise e unless Rails.env.development?
@@ -54,11 +53,4 @@ class AdminGraphqlController < ApplicationController
54
53
 
55
54
  render json: { errors: [{ message: err.message, backtrace: err.backtrace }], data: {} }, status: :internal_server_error
56
55
  end
57
-
58
- def track_action
59
- variables = prepare_variables(params[:variables])
60
- query = params[:query]
61
- operation_name = params[:operationName]
62
- ahoy.track 'Admin Portal', query: query, variables: variables, operation_name: operation_name
63
- end
64
56
  end
@@ -1,4 +1,4 @@
1
- class <%= @top_folder_name.camelize %>AdminSchema < GraphQL::Schema
1
+ class <%= class_name %>AdminSchema < GraphQL::Schema
2
2
  use GraphQL::Tracing::NewRelicTracing, set_transaction_name: true
3
3
  use GraphqlDevise::SchemaPlugin.new(
4
4
  query: Types::Query::AdminUserQueryType,
@@ -6,7 +6,7 @@ module Mutations
6
6
 
7
7
  def resolve(**args)
8
8
  <%= class_name.underscore %> = <%= class_name %>.new(args)
9
- if <%= class_name.underscore %>.save
9
+ if <%= class_name.underscore %>.save
10
10
  <%= class_name.underscore %>
11
11
  else
12
12
  context.add_error(GraphQL::ExecutionError.new( <%= class_name.underscore %>.errors.full_messages.join(', ')))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlScaffoldFan
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.7'
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_scaffold_fan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fan Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphql_playground-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: graphql
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Helping creating graphql files
14
42
  email:
15
43
  - fan.zhang@pixelforce.com.au