graphql_scaffold_fan 0.2.1 → 0.2.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: 2f755d7a5c9191354b222be9f9fcd9c4c51c1338dff06c7071af1347bee84d30
4
- data.tar.gz: 4843677bfe20e96fe2938cba3acf89660a48c2120234d119eea9ab9cd087cc14
3
+ metadata.gz: bd16366de26333651bededf94e3b522ddc3f23e3beb39fb885292cc39afca52a
4
+ data.tar.gz: 30bb023a7cf18328365147f83b405406fadcbff4d7e498032e621f5db24b5f90
5
5
  SHA512:
6
- metadata.gz: a15f608b54dcae10a5fdf830ad615e0ebe88eaf55e0c4855b8549a1f0331b31237d3c52d64958ffa3ca92f3fb24464abc61098ea8160e123e3a99a910b92c031
7
- data.tar.gz: 0066a77155de7f9f7d68ccdd89dd2c8e3093962b9e6657b3c968f2da9f7c3bc01ae4fde1a084d39edcfd72b21e1b0459d1e987bccd5f7dbe19e72a3c210c2066
6
+ metadata.gz: 21b1cf73b2627efbb3f89b25c839b826d59f2c930842f86e3be8c8b0209d80e2792d5483247586f2c66aac88a70023a0d25d3026294583224322a637da01aefd
7
+ data.tar.gz: 0f18d48487e041e3568e5e95c3da2a0a5612a04a7d2be2f082cefae6be80173018bb60937c00b81772777ac004fb96338b436cde95cca376d83f661232112fef
data/.DS_Store CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_scaffold_fan (0.2.1)
4
+ graphql_scaffold_fan (0.2.4)
5
5
  graphql
6
6
  graphql_playground-rails
7
7
 
@@ -17,13 +17,12 @@ module GraphqlScaffold
17
17
  end
18
18
 
19
19
  def create_admin_schema_file
20
- @top_folder_name = File.basename(Dir.getwd)
21
20
  dir_path = 'app/graphql'
22
- file_path = dir_path + "/#{@top_folder_name.underscore}_admin_schema.rb"
21
+ file_path = dir_path + "/#{file_name.underscore}_admin_schema.rb"
23
22
  FileUtils.mkdir_p(dir_path) unless File.exist?(dir_path)
24
23
 
25
24
  if File.exist?(file_path)
26
- p "File #{@top_folder_name}_admin_schema.rb already exists"
25
+ p "File #{file_name}_admin_schema.rb already exists"
27
26
  else
28
27
  template 'admin_schema.haml', file_path
29
28
  end
@@ -57,6 +56,25 @@ module GraphqlScaffold
57
56
  p 'Please create routes.rb file under config folder firstly'
58
57
  end
59
58
  end
59
+
60
+ def add_gem_dependencies
61
+ route_file_path = 'Gemfile'
62
+
63
+ p 'Gemfile does not exist' unless File.exist?(route_file_path)
64
+
65
+ if File.exist?(route_file_path)
66
+ file = File.open(route_file_path)
67
+ file_data = file.read
68
+ new_file_data = file_data.insert(-2, "\ngem 'graphql_playground-rails'")
69
+ File.write(file, new_file_data)
70
+ Bundler.with_clean_env do
71
+ run "bundle install"
72
+ end
73
+ p 'Write to Gemfile successfully'
74
+ else
75
+ p 'Please create Gemfile file firstly'
76
+ end
77
+ end
60
78
  end
61
79
  end
62
80
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Comment
1
4
  class AdminGraphqlController < ApplicationController
2
5
  include GraphqlDevise::Concerns::SetUserByToken
3
6
 
@@ -51,6 +54,7 @@ class AdminGraphqlController < ApplicationController
51
54
  logger.error err.message
52
55
  logger.error err.backtrace.join("\n")
53
56
 
54
- render json: { errors: [{ message: err.message, backtrace: err.backtrace }], data: {} }, status: :internal_server_error
57
+ render json: { errors: [{ message: err.message, backtrace: err.backtrace }], data: {} },
58
+ status: :internal_server_error
55
59
  end
56
- end
60
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  module Inputs
3
5
  module Admin
@@ -14,4 +16,4 @@ module Types
14
16
  end
15
17
  end
16
18
  end
17
- end
19
+ end
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Comment
1
4
  class <%= class_name %>AdminSchema < GraphQL::Schema
2
5
  use GraphQL::Tracing::NewRelicTracing, set_transaction_name: true
3
6
  use GraphqlDevise::SchemaPlugin.new(
4
- query: Types::Query::AdminUserQueryType,
5
- mutation: Types::Mutation::AdminUserMutationType,
7
+ query: Types::Query::AdminUserQueryType,
8
+ mutation: Types::Mutation::AdminUserMutationType,
6
9
  resource_loaders: [
7
10
  GraphqlDevise::ResourceLoader.new(AdminUser, only: %i[login logout])
8
11
  ]
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mutations
2
4
  class BaseAdminMutation < GraphQL::Schema::Mutation
3
5
  end
4
- end
6
+ end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  class BaseObject < GraphQL::Schema::Object
3
-
4
5
  def self.has_admin_fields(attach_sttr, **conf)
5
6
  attach_sttr = attach_sttr.to_s
6
7
  get_one = attach_sttr
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  module Admin
3
5
  class ListMetadataType < Types::BaseObject
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Comment
1
4
  module Mutations
2
5
  module Admin
3
6
  class <%= class_name %>s::Create<%= class_name %> < BaseAdminMutation
4
-
5
7
  type Types::Admin::<%= class_name %>Type
6
8
 
7
9
  def resolve(**args)
8
- <%= class_name.underscore %> = <%= class_name %>.new(args)
10
+ <%= class_name.underscore %> = <%= class_name %>.new(args)
9
11
  if <%= class_name.underscore %>.save
10
- <%= class_name.underscore %>
12
+ <%= class_name.underscore %>
11
13
  else
12
- context.add_error(GraphQL::ExecutionError.new( <%= class_name.underscore %>.errors.full_messages.join(', ')))
14
+ context.add_error(GraphQL::ExecutionError.new(<%= class_name.underscore %>.errors.full_messages.join(', ')))
13
15
  end
14
16
  end
15
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Mutations::Admin::<%= class_name %>s::Create<%= class_name %>, type: :request do
@@ -29,4 +31,4 @@ RSpec.describe Mutations::Admin::<%= class_name %>s::Create<%= class_name %>, ty
29
31
  }
30
32
  GQL
31
33
  end
32
- end
34
+ end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Comment
1
4
  module Mutations
2
5
  module Admin
3
6
  class <%= class_name %>s::Delete<%= class_name %> < BaseAdminMutation
4
-
5
7
  type Types::Admin::<%= class_name %>Type
6
8
 
7
9
  def resolve(id:)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Mutations::Admin::<%= class_name %>s::Delete<%= class_name %>, type: :request do
@@ -34,4 +36,4 @@ RSpec.describe Mutations::Admin::<%= class_name %>s::Delete<%= class_name %>, ty
34
36
  }
35
37
  GQL
36
38
  end
37
- end
39
+ end
@@ -1,7 +1,7 @@
1
- require 'rails_helper'
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'rails_helper'
3
4
  RSpec.describe Mutations::<%= class_name %>, type: :request do
4
-
5
5
  describe 'resolve' do
6
6
 
7
7
  end
@@ -9,8 +9,7 @@ RSpec.describe Mutations::<%= class_name %>, type: :request do
9
9
  def query(**args)
10
10
  <<~GQL
11
11
  mutation <%= class_name.underscore %>{
12
- <%= class_name.underscore %>{
13
-
12
+ <%= class_name.underscore %>{
14
13
  }
15
14
  }
16
15
  GQL
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  module Admin
3
5
  class MutationType < Types::BaseObject
4
-
5
6
  has_admin_mutation :<%= class_name %>
6
7
  end
7
8
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Comment
1
4
  module Mutations
2
5
  module Admin
3
6
  class <%= class_name %>s::Update<%= class_name %> < BaseAdminMutation
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Mutations::Admin::<%= class_name %>s::Update<%= class_name %>, type: :request do
@@ -32,4 +34,4 @@ RSpec.describe Mutations::Admin::<%= class_name %>s::Update<%= class_name %>, ty
32
34
  }
33
35
  GQL
34
36
  end
35
- end
37
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Resolvers::<%= class_name %>, type: :request do
@@ -11,7 +13,6 @@ RSpec.describe Resolvers::<%= class_name %>, type: :request do
11
13
 
12
14
  describe '#resolve' do
13
15
  it 'pass' do
14
-
15
16
  end
16
17
  end
17
- end
18
+ end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  module Admin
3
5
  class QueryType < Types::BaseObject
4
-
5
6
  has_admin_fields :<%= class_name %>
6
7
  end
7
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlScaffoldFan
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_scaffold_fan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.4
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-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql