cm-graphql 0.0.10 → 0.0.11
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 +1 -1
- data/app/graphql/types/enum_helpers.rb +13 -6
- data/app/graphql/types/graphql_type_utils.rb +7 -0
- data/app/graphql/types/paging_type_helper.rb +8 -3
- data/cm-graphql.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 804c41716d68195171fa39944aec667186842a7bd72f0fd0e194914a4591a1a8
|
4
|
+
data.tar.gz: 78de5caf228b55e1ac7200d6c50070f2de9973571812e4e97675591a551717a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f38693d738dd0c880bcd6c526ed04d83976833f66e57a9a30299fb869c4fd702bdad78e5a8d445b9ba64580c64226c57525b6f34afa834435d8f4970dc0703da
|
7
|
+
data.tar.gz: fc3df7c9122c14b27acef4222ba552b846dc8c5d87d9e9360fd317b3f07addb3531f055b52860e51a8524ea5ad0980ba7028f910d4e7a46339df4411aa6a011b
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,34 @@
|
|
1
1
|
module Types
|
2
2
|
module EnumHelpers
|
3
3
|
def self.enum_from_model(model, enum_name, graphql_enum_name: nil)
|
4
|
-
|
4
|
+
graphql_class_name = graphql_enum_name || "#{model.name}#{enum_name.to_s.camelize}Enum"
|
5
|
+
|
6
|
+
existing_enum = Types::GraphqlTypeUtils.get_or_check_existing_constant(graphql_class_name)
|
7
|
+
return existing_enum if existing_enum
|
5
8
|
|
6
|
-
|
7
|
-
|
9
|
+
enum_values = model.send(enum_name.to_s.pluralize).keys
|
10
|
+
Object.const_set(graphql_class_name, Class.new(Types::BaseEnum) do
|
11
|
+
graphql_name(graphql_class_name)
|
8
12
|
|
9
13
|
enum_values.each do |val|
|
10
14
|
value val, description: "#{val.titleize} #{enum_name}"
|
11
15
|
end
|
12
|
-
end
|
16
|
+
end)
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.enum_from_array(array, graphql_enum_name)
|
16
20
|
enum_values = array.map(&:to_s)
|
17
21
|
|
18
|
-
|
22
|
+
existing_enum = Types::GraphqlTypeUtils.get_or_check_existing_constant(graphql_enum_name)
|
23
|
+
return existing_enum if existing_enum
|
24
|
+
|
25
|
+
Object.const_set(graphql_enum_name, Class.new(Types::BaseEnum) do
|
19
26
|
graphql_name(graphql_enum_name)
|
20
27
|
|
21
28
|
enum_values.each do |val|
|
22
29
|
value val, description: val.titleize
|
23
30
|
end
|
24
|
-
end
|
31
|
+
end)
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module Types
|
2
2
|
module PagingTypeHelper
|
3
3
|
def self.paging_type_for_model(model:, record_data_type: nil, graphql_type_name: nil)
|
4
|
-
|
5
|
-
|
4
|
+
graphql_class_name = graphql_type_name.presence || "#{model}PagingType"
|
5
|
+
|
6
|
+
existing_paging_type = Types::GraphqlTypeUtils.get_or_check_existing_constant(graphql_class_name)
|
7
|
+
return existing_paging_type if existing_paging_type
|
8
|
+
|
9
|
+
Object.const_set(graphql_class_name, Class.new(Types::BaseObject) do
|
10
|
+
graphql_name(graphql_class_name)
|
6
11
|
|
7
12
|
model_data_type = if record_data_type.present?
|
8
13
|
record_data_type.to_s.constantize
|
@@ -12,7 +17,7 @@ module Types
|
|
12
17
|
|
13
18
|
field :paging, Types::Objects::Base::PagingType, null: true
|
14
19
|
field :data, [model_data_type], null: false
|
15
|
-
end
|
20
|
+
end)
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
data/cm-graphql.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'cm-graphql'
|
5
|
-
spec.version = '0.0.
|
5
|
+
spec.version = '0.0.11'
|
6
6
|
spec.date = '2022-09-14'
|
7
7
|
spec.summary = 'A gem to setup grapqhl basics like pagination, file upload'
|
8
8
|
spec.description = 'A gem to setup grapqhl basics like pagination, file upload'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anbazhagan Palani
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- app/graphql/types/enum_helpers.rb
|
92
92
|
- app/graphql/types/enums/base/sort_column.rb
|
93
93
|
- app/graphql/types/enums/base/sort_direction.rb
|
94
|
+
- app/graphql/types/graphql_type_utils.rb
|
94
95
|
- app/graphql/types/inputs/base/attachment.rb
|
95
96
|
- app/graphql/types/inputs/base/filter.rb
|
96
97
|
- app/graphql/types/inputs/base/paging.rb
|