graphql_scaffold_fan 0.2.4 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/generators/graphql_scaffold/init_generator.rb +23 -1
- data/lib/generators/graphql_scaffold/mutation_generator.rb +2 -2
- data/lib/generators/graphql_scaffold/type_generator.rb +2 -2
- data/lib/generators/templates/admin_schema.haml +13 -11
- data/lib/generators/templates/mutation_type.haml +1 -1
- data/lib/generators/templates/query_type.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: eed7880738bc1e560999cacc4cc80284a4a353eff9ce4db9e804248b6fecc82a
|
4
|
+
data.tar.gz: ebf38352c1e52f9bba28a8814280b64d7ee7dd5a961397da44cce847950861d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f6663b95a871a0df9ede7b467f9e03eadf789dde0f9ba17aa699dab91f58d9f6abc6b46acc4c13b566451a3a797993fcb7f9a6d1c3163ba7325ee59fc6f7a5
|
7
|
+
data.tar.gz: 67473a3eb62b1099bfe3f656811a52ba3ca786acd3f9e317726d1a81c2ee072ed6590aa95639e9c73a59ee25de7ef035888f76fab6b88ee7d3559bf607d3914b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql_scaffold_fan (0.2.
|
4
|
+
graphql_scaffold_fan (0.2.7)
|
5
5
|
graphql
|
6
6
|
graphql_playground-rails
|
7
7
|
|
@@ -73,7 +73,7 @@ GEM
|
|
73
73
|
erubi (1.10.0)
|
74
74
|
globalid (1.0.0)
|
75
75
|
activesupport (>= 5.0)
|
76
|
-
graphql (2.0.
|
76
|
+
graphql (2.0.12)
|
77
77
|
graphql_playground-rails (2.1.0)
|
78
78
|
rails (>= 5.1.0)
|
79
79
|
i18n (1.12.0)
|
@@ -88,7 +88,7 @@ GEM
|
|
88
88
|
mini_mime (1.1.2)
|
89
89
|
minitest (5.16.2)
|
90
90
|
nio4r (2.5.8)
|
91
|
-
nokogiri (1.13.
|
91
|
+
nokogiri (1.13.8-x86_64-darwin)
|
92
92
|
racc (~> 1.4)
|
93
93
|
racc (1.6.0)
|
94
94
|
rack (2.2.4)
|
@@ -129,7 +129,7 @@ GEM
|
|
129
129
|
activesupport (>= 5.2)
|
130
130
|
sprockets (>= 3.0.0)
|
131
131
|
thor (1.2.1)
|
132
|
-
tzinfo (2.0.
|
132
|
+
tzinfo (2.0.5)
|
133
133
|
concurrent-ruby (~> 1.0)
|
134
134
|
websocket-driver (0.7.5)
|
135
135
|
websocket-extensions (>= 0.1.0)
|
@@ -40,6 +40,28 @@ module GraphqlScaffold
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def create_mutation_type_file
|
44
|
+
mutation_type_dir_path = 'app/graphql/types/admin'
|
45
|
+
generator_dir_path = mutation_type_dir_path
|
46
|
+
generator_path = generator_dir_path + '/mutation_type.rb'
|
47
|
+
|
48
|
+
FileUtils.mkdir_p(mutation_type_dir_path) unless File.exist?(mutation_type_dir_path)
|
49
|
+
FileUtils.mkdir_p(generator_dir_path) unless File.exist?(generator_dir_path)
|
50
|
+
|
51
|
+
template 'mutation_type.haml', generator_path if !File.exist?(generator_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_query_type_file
|
55
|
+
query_type_dir_path = 'app/graphql/types/admin'
|
56
|
+
generator_dir_path = query_type_dir_path
|
57
|
+
generator_path = generator_dir_path + '/query_type.rb'
|
58
|
+
|
59
|
+
FileUtils.mkdir_p(query_type_dir_path) unless File.exist?(query_type_dir_path)
|
60
|
+
FileUtils.mkdir_p(generator_dir_path) unless File.exist?(generator_dir_path)
|
61
|
+
|
62
|
+
template 'query_type.haml', generator_path if !File.exist?(generator_path)
|
63
|
+
end
|
64
|
+
|
43
65
|
def add_route
|
44
66
|
route_dir_path = 'config'
|
45
67
|
route_file_path = route_dir_path + '/routes.rb'
|
@@ -49,7 +71,7 @@ module GraphqlScaffold
|
|
49
71
|
if File.exist?(route_file_path)
|
50
72
|
file = File.open(route_file_path)
|
51
73
|
file_data = file.read
|
52
|
-
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: '
|
74
|
+
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: 'admin_graphql#execute'")
|
53
75
|
File.write(file, new_file_data)
|
54
76
|
p 'Write to routes.rb successfully'
|
55
77
|
else
|
@@ -22,7 +22,7 @@ module GraphqlScaffold
|
|
22
22
|
generator_dir_path = admin_mutation_dir_path + ("/#{@module_name.underscore}" if @module_name.present?).to_s
|
23
23
|
@generator_path = generator_dir_path + "/#{file_name}s"
|
24
24
|
|
25
|
-
admin_mutation_test_dir_path = 'spec/
|
25
|
+
admin_mutation_test_dir_path = 'spec/requests/mutations/admin'
|
26
26
|
generator_test_dir_path = admin_mutation_test_dir_path + (if @module_name.present?
|
27
27
|
"/#{@module_name.underscore}"
|
28
28
|
end).to_s
|
@@ -104,7 +104,7 @@ module GraphqlScaffold
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
107
|
+
def write_to_mutation_type_file
|
108
108
|
mutation_type_dir_path = 'app/graphql/types/admin'
|
109
109
|
generator_dir_path = mutation_type_dir_path
|
110
110
|
generator_path = generator_dir_path + '/mutation_type.rb'
|
@@ -36,7 +36,7 @@ module GraphqlScaffold
|
|
36
36
|
template 'admin_filter.haml', generator_path
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def write_to_query_type_file
|
40
40
|
query_type_dir_path = 'app/graphql/types/admin'
|
41
41
|
generator_dir_path = query_type_dir_path
|
42
42
|
generator_path = generator_dir_path + '/query_type.rb'
|
@@ -67,7 +67,7 @@ module GraphqlScaffold
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def create_test_file
|
70
|
-
test_dir_path = 'spec/requests/queries'
|
70
|
+
test_dir_path = 'spec/requests/queries/admin'
|
71
71
|
test_file_path = test_dir_path + "/#{file_name}_spec.rb"
|
72
72
|
FileUtils.mkdir_p(test_dir_path) unless File.exist?(test_dir_path)
|
73
73
|
template 'query_test.haml', test_file_path
|
@@ -4,17 +4,19 @@
|
|
4
4
|
class <%= class_name %>AdminSchema < GraphQL::Schema
|
5
5
|
use GraphQL::Tracing::NewRelicTracing, set_transaction_name: true
|
6
6
|
use GraphqlDevise::SchemaPlugin.new(
|
7
|
-
query:
|
8
|
-
mutation:
|
7
|
+
query: Types::Admin::QueryType,
|
8
|
+
mutation: Types::Admin::MutationType,
|
9
9
|
resource_loaders: [
|
10
|
-
GraphqlDevise::ResourceLoader.new(AdminUser,
|
10
|
+
GraphqlDevise::ResourceLoader.new(AdminUser,
|
11
|
+
operations: {
|
12
|
+
login: Mutations::Admin::Auth::Login
|
13
|
+
},
|
14
|
+
only: %i[login logout])
|
11
15
|
]
|
12
16
|
)
|
13
17
|
|
14
|
-
mutation(Types::
|
15
|
-
query(Types::
|
16
|
-
|
17
|
-
use GraphQL::Batch
|
18
|
+
mutation(Types::Admin::MutationType)
|
19
|
+
query(Types::Admin::QueryType)
|
18
20
|
|
19
21
|
# Union and Interface Resolution
|
20
22
|
def self.resolve_type(_abstract_type, _obj, _ctx)
|
@@ -26,17 +28,17 @@ class <%= class_name %>AdminSchema < GraphQL::Schema
|
|
26
28
|
# Relay-style Object Identification:
|
27
29
|
|
28
30
|
# Return a string UUID for `object`
|
29
|
-
def self.id_from_object(object, type_definition,
|
31
|
+
def self.id_from_object(object, type_definition, query_ctx)
|
30
32
|
# Here's a simple implementation which:
|
31
33
|
# - joins the type name & object.id
|
32
34
|
# - encodes it with base64:
|
33
|
-
GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
|
35
|
+
# GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
|
34
36
|
end
|
35
37
|
|
36
38
|
# Given a string UUID, find the object
|
37
|
-
def self.object_from_id(id,
|
39
|
+
def self.object_from_id(id, query_ctx)
|
38
40
|
# For example, to decode the UUIDs generated above:
|
39
|
-
type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
|
41
|
+
# type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
|
40
42
|
#
|
41
43
|
# Then, based on `type_name` and `id`
|
42
44
|
# find an object in your application
|
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2022-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|