cm-graphql 0.0.8 → 0.0.10
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/objects/base/attachment_type.rb +16 -0
- data/app/graphql/types/paging_type_helper.rb +18 -0
- data/cm-graphql.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6c2f7040bfb9a66bf445a9b39ec6c26f5f40f2a8a6ced52d058035b81c96d3e
|
4
|
+
data.tar.gz: 56483111c895cc058a15a5d8eff804b1125331f684dec4cecd654d57ef633426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35443f4fcd9d6b181c376bbc72f5123faa398e20509baacc49e9463bccfbffd51793f8c7ba6705eae796d2ffee68d4720228091677525e978d69f9b55f5b56d4
|
7
|
+
data.tar.gz: 7ff807866e4ec814cbf8865dbf2a60ced6b1cca43038564acded2df32afa2387246397678440dab201cc8261d070603be446c468e3c42f229ce6067c6dce687b
|
data/Gemfile.lock
CHANGED
@@ -6,6 +6,8 @@ module Types::Objects::Base
|
|
6
6
|
argument :resolution, Types::Inputs::ImageResolution, required: false, default_value: nil
|
7
7
|
end
|
8
8
|
field :base64, String, nil, null: false
|
9
|
+
field :byte_size, Int, nil, null: false
|
10
|
+
field :file_size, String, nil, null: false
|
9
11
|
|
10
12
|
def id
|
11
13
|
if object.class.eql?(ActiveStorage::Variant)
|
@@ -50,5 +52,19 @@ module Types::Objects::Base
|
|
50
52
|
end
|
51
53
|
"data:#{object.content_type};base64,#{data}"
|
52
54
|
end
|
55
|
+
|
56
|
+
def byte_size
|
57
|
+
if object.class.eql?(ActiveStorage::Variant)
|
58
|
+
object.blob.byte_size
|
59
|
+
else
|
60
|
+
object.byte_size
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def file_size
|
65
|
+
return nil if byte_size.blank?
|
66
|
+
|
67
|
+
ActiveSupport::NumberHelper.number_to_human_size(byte_size)
|
68
|
+
end
|
53
69
|
end
|
54
70
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Types
|
2
|
+
module PagingTypeHelper
|
3
|
+
def self.paging_type_for_model(model:, record_data_type: nil, graphql_type_name: nil)
|
4
|
+
Class.new(Types::BaseObject) do
|
5
|
+
graphql_name(graphql_type_name.presence || "#{model}PagingType")
|
6
|
+
|
7
|
+
model_data_type = if record_data_type.present?
|
8
|
+
record_data_type.to_s.constantize
|
9
|
+
else
|
10
|
+
"Types::Objects::#{model}Type".constantize
|
11
|
+
end
|
12
|
+
|
13
|
+
field :paging, Types::Objects::Base::PagingType, null: true
|
14
|
+
field :data, [model_data_type], null: false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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.10'
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anbazhagan Palani
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- app/graphql/types/inputs/image_resolution.rb
|
99
99
|
- app/graphql/types/objects/base/attachment_type.rb
|
100
100
|
- app/graphql/types/objects/base/paging_type.rb
|
101
|
+
- app/graphql/types/paging_type_helper.rb
|
101
102
|
- app/models/concerns/attachable.rb
|
102
103
|
- app/models/concerns/paginator.rb
|
103
104
|
- app/models/filtered_list.rb
|
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
132
|
- !ruby/object:Gem::Version
|
132
133
|
version: '0'
|
133
134
|
requirements: []
|
134
|
-
rubygems_version: 3.6.
|
135
|
+
rubygems_version: 3.6.9
|
135
136
|
specification_version: 4
|
136
137
|
summary: A gem to setup grapqhl basics like pagination, file upload
|
137
138
|
test_files: []
|