graphql_scaffold_fan 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/generators/graphql_scaffold/init_generator.rb +0 -1
- data/lib/generators/templates/admin_controller.haml +1 -9
- data/lib/generators/templates/admin_schema.haml +1 -1
- data/lib/generators/templates/mutation_create.haml +1 -1
- data/lib/graphql_scaffold_fan/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca0c115c610c53ece69712300c30d7b6a4b8d604360e1ff12983c5efb58bd5c
|
4
|
+
data.tar.gz: 2238a18b5a643e5ae89b31bcc08e44aad0965caedd145d6e72210ebf34c0250a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ce30b9e17ae0d95728e73f46b03eb5470123ad1d85c58de2a7a13a03a28123fc45ae2a7698140f01da4aa93473b4e1fd7a272dd164b3a1eb7752c831c28175
|
7
|
+
data.tar.gz: cfc8defe9cf83b6a6aa3a8d7d509fbf316c3c8f6d6f2cddac45b7b359124d5fa19e8b702de67dab3c6334b622ec28646f31936e256bbe1e70850734c16d32981
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,12 @@ Example commands:
|
|
29
29
|
`rails generate graphql_scaffold:mutation <MutationName>`
|
30
30
|
`rails generate graphql_scaffold:type <TypeName>`
|
31
31
|
|
32
|
+
If you ever found mutation not loading in schema: pls check the following code
|
33
|
+
`config.load_defaults 6.1`
|
34
|
+
`# config.autoloader = :zeitwerk`
|
35
|
+
Reference link:
|
36
|
+
https://guides.rubyonrails.org/classic_to_zeitwerk_howto.html
|
37
|
+
|
32
38
|
|
33
39
|
## Development
|
34
40
|
|
@@ -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)
|
@@ -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 = <%=
|
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 <%=
|
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
|
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(', ')))
|
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.1.
|
4
|
+
version: 0.1.6
|
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-
|
11
|
+
date: 2022-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Helping creating graphql files
|
14
14
|
email:
|