graphql-filters 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +1635 -0
  4. data/CHANGELOG.md +13 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +77 -0
  7. data/LICENSE +21 -0
  8. data/README.md +265 -0
  9. data/Rakefile +10 -0
  10. data/lib/graphql/filters/activerecord_patch/arel/nodes/contained.rb +9 -0
  11. data/lib/graphql/filters/activerecord_patch/arel/predications.rb +9 -0
  12. data/lib/graphql/filters/activerecord_patch.rb +3 -0
  13. data/lib/graphql/filters/dsl/graphql/schema/enum.rb +16 -0
  14. data/lib/graphql/filters/dsl/graphql/schema/field.rb +64 -0
  15. data/lib/graphql/filters/dsl/graphql/schema/list.rb +28 -0
  16. data/lib/graphql/filters/dsl/graphql/schema/member.rb +25 -0
  17. data/lib/graphql/filters/dsl/graphql/schema/non_null.rb +15 -0
  18. data/lib/graphql/filters/dsl/graphql/schema/object.rb +16 -0
  19. data/lib/graphql/filters/dsl/graphql/schema/scalar.rb +16 -0
  20. data/lib/graphql/filters/dsl/graphql/types/numeric.rb +20 -0
  21. data/lib/graphql/filters/dsl/graphql/types/string.rb +16 -0
  22. data/lib/graphql/filters/dsl.rb +3 -0
  23. data/lib/graphql/filters/filterable.rb +42 -0
  24. data/lib/graphql/filters/input_types/base_comparison_input_type.rb +12 -0
  25. data/lib/graphql/filters/input_types/base_list_comparison_input_type.rb +23 -0
  26. data/lib/graphql/filters/input_types/base_scalar_comparison_input_type.rb +63 -0
  27. data/lib/graphql/filters/input_types/fields_comparison_input_type.rb +58 -0
  28. data/lib/graphql/filters/input_types/list_object_comparison_input_type.rb +97 -0
  29. data/lib/graphql/filters/input_types/list_scalar_comparison_input_type.rb +134 -0
  30. data/lib/graphql/filters/input_types/numeric_comparison_input_type.rb +45 -0
  31. data/lib/graphql/filters/input_types/object_comparison_input_type.rb +71 -0
  32. data/lib/graphql/filters/input_types/string_comparison_input_type.rb +64 -0
  33. data/lib/graphql/filters/utility/cached_class.rb +74 -0
  34. data/lib/graphql/filters/version.rb +5 -0
  35. data/lib/graphql/filters.rb +26 -0
  36. data/lib/graphql/models_connect/dsl/graphql/schema/object.rb +27 -0
  37. data/lib/graphql/models_connect/dsl.rb +3 -0
  38. data/lib/graphql/models_connect.rb +15 -0
  39. metadata +126 -0
@@ -0,0 +1,5 @@
1
+ module GraphQL
2
+ module Filters
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require 'active_support/configurable'
2
+ require 'active_support/core_ext/module/delegation'
3
+ require 'graphql'
4
+ require_relative 'filters/version'
5
+ require_relative 'filters/utility/cached_class'
6
+
7
+ module GraphQL
8
+ module Filters
9
+ # This will one day be a separate gem, and in that moment we will change this reference accordingly
10
+ CachedClass = Utility::CachedClass
11
+ private_constant :CachedClass
12
+
13
+ include ActiveSupport::Configurable
14
+
15
+ config.base_input_object_class = GraphQL::Schema::InputObject
16
+
17
+ singleton_class.delegate(*config.keys, to: :config)
18
+ end
19
+ end
20
+
21
+ # These need to be here, after the definition of GraphQL::Filters
22
+
23
+ require_relative 'models_connect'
24
+ require_relative 'filters/activerecord_patch'
25
+ require_relative 'filters/dsl'
26
+ require_relative 'filters/filterable'
@@ -0,0 +1,27 @@
1
+ require 'active_support/concern'
2
+
3
+ monkey_patch = Module.new do
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def model_class new_model_class=nil
8
+ if new_model_class.nil?
9
+ @model_class ||= default_model_class
10
+ else
11
+ @model_class = new_model_class
12
+ end
13
+ end
14
+
15
+ def default_model_class
16
+ raise 'You must set an explicit model for anonymous graphql classes' if name.nil?
17
+
18
+ default_model_name = name.delete_suffix 'Type'
19
+
20
+ raise "No default model found for #{name}" unless const_defined? default_model_name
21
+
22
+ const_get default_model_name
23
+ end
24
+ end
25
+ end
26
+
27
+ GraphQL::Schema::Object.prepend monkey_patch
@@ -0,0 +1,3 @@
1
+ Dir['dsl/**/*.rb', base: __dir__].each do |filename|
2
+ require_relative filename
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'active_support/configurable'
2
+ require 'active_support/core_ext/module/delegation'
3
+ require 'graphql'
4
+
5
+ module GraphQL
6
+ module ModelsConnect
7
+ include ActiveSupport::Configurable
8
+
9
+ singleton_class.delegate(*config.keys, to: :config)
10
+ end
11
+ end
12
+
13
+ # These need to be here, after the definition of GraphQL::ModelsConnect
14
+
15
+ require_relative 'models_connect/dsl'
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-filters
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Moku S.r.l.
8
+ - Riccardo Agatea
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2023-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 7.0.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 7.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 7.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 7.0.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: graphql
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 2.0.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 2.0.0
56
+ description: Provide a fully typed interface to filter lists in a GraphQL API.
57
+ email:
58
+ - info@moku.io
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - lib/graphql/filters.rb
72
+ - lib/graphql/filters/activerecord_patch.rb
73
+ - lib/graphql/filters/activerecord_patch/arel/nodes/contained.rb
74
+ - lib/graphql/filters/activerecord_patch/arel/predications.rb
75
+ - lib/graphql/filters/dsl.rb
76
+ - lib/graphql/filters/dsl/graphql/schema/enum.rb
77
+ - lib/graphql/filters/dsl/graphql/schema/field.rb
78
+ - lib/graphql/filters/dsl/graphql/schema/list.rb
79
+ - lib/graphql/filters/dsl/graphql/schema/member.rb
80
+ - lib/graphql/filters/dsl/graphql/schema/non_null.rb
81
+ - lib/graphql/filters/dsl/graphql/schema/object.rb
82
+ - lib/graphql/filters/dsl/graphql/schema/scalar.rb
83
+ - lib/graphql/filters/dsl/graphql/types/numeric.rb
84
+ - lib/graphql/filters/dsl/graphql/types/string.rb
85
+ - lib/graphql/filters/filterable.rb
86
+ - lib/graphql/filters/input_types/base_comparison_input_type.rb
87
+ - lib/graphql/filters/input_types/base_list_comparison_input_type.rb
88
+ - lib/graphql/filters/input_types/base_scalar_comparison_input_type.rb
89
+ - lib/graphql/filters/input_types/fields_comparison_input_type.rb
90
+ - lib/graphql/filters/input_types/list_object_comparison_input_type.rb
91
+ - lib/graphql/filters/input_types/list_scalar_comparison_input_type.rb
92
+ - lib/graphql/filters/input_types/numeric_comparison_input_type.rb
93
+ - lib/graphql/filters/input_types/object_comparison_input_type.rb
94
+ - lib/graphql/filters/input_types/string_comparison_input_type.rb
95
+ - lib/graphql/filters/utility/cached_class.rb
96
+ - lib/graphql/filters/version.rb
97
+ - lib/graphql/models_connect.rb
98
+ - lib/graphql/models_connect/dsl.rb
99
+ - lib/graphql/models_connect/dsl/graphql/schema/object.rb
100
+ homepage: https://github.com/moku-io/graphql-filters
101
+ licenses:
102
+ - MIT
103
+ metadata:
104
+ homepage_uri: https://github.com/moku-io/graphql-filters
105
+ source_code_uri: https://github.com/moku-io/graphql-filters
106
+ changelog_uri: https://github.com/moku-io/graphql-filters
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 3.0.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.3.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Provide a fully typed interface to filter lists in a GraphQL API.
126
+ test_files: []