graphql-kaminari_connection 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: da87b778be603c1ddd5e6774b70ec8922a62a37785c040be4172e1ff2314eab2
4
+ data.tar.gz: eb86004f00f5c7c3c37ce4e7aa1be07fff166effb820a6144c1ffe9500e3eac3
5
+ SHA512:
6
+ metadata.gz: 7ac8beb874ab25fddf4a6e203ddeaf12a14b5b88811aa78ba3d616673aaceaf9c199c3172958cdc24098c97ab598f3f67c8858b27e9b9cb209b0040d4926a475
7
+ data.tar.gz: b2c869791754da3d10a5a448910895537f1970f2657401c9cda082466adee03b613973171646b6ce5aca5492e5c7c5545b784480331f225bd038e1d9f2b6397c
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /tags
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Metrics/BlockLength:
5
+ Enabled: false
6
+
7
+ Metrics/MethodLength:
8
+ Enabled: false
9
+
10
+ Metrics/LineLength:
11
+ Max: 120
12
+
13
+ Style/Documentation:
14
+ Enabled: false
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.3
6
+ notifications:
7
+ email: false
8
+ script:
9
+ - bundle exec rake rubocop
10
+ - bundle exec rake spec
11
+
12
+ after_success:
13
+ - bundle exec codeclimate-test-reporter
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at taka84u9@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in graphql-kaminari_connection.gemspec
8
+ gemspec
@@ -0,0 +1,130 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ graphql-kaminari_connection (0.1.0)
5
+ graphql (~> 1.8)
6
+ kaminari (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionview (5.2.1)
12
+ activesupport (= 5.2.1)
13
+ builder (~> 3.1)
14
+ erubi (~> 1.4)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
17
+ activemodel (5.2.1)
18
+ activesupport (= 5.2.1)
19
+ activerecord (5.2.1)
20
+ activemodel (= 5.2.1)
21
+ activesupport (= 5.2.1)
22
+ arel (>= 9.0)
23
+ activesupport (5.2.1)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ arel (9.0.0)
29
+ ast (2.4.0)
30
+ builder (3.2.3)
31
+ codeclimate-test-reporter (1.0.7)
32
+ simplecov
33
+ coderay (1.1.2)
34
+ concurrent-ruby (1.0.5)
35
+ crass (1.0.4)
36
+ diff-lcs (1.3)
37
+ docile (1.3.1)
38
+ erubi (1.7.1)
39
+ graphql (1.8.10)
40
+ i18n (1.1.0)
41
+ concurrent-ruby (~> 1.0)
42
+ jaro_winkler (1.5.1)
43
+ json (2.1.0)
44
+ kaminari (1.1.1)
45
+ activesupport (>= 4.1.0)
46
+ kaminari-actionview (= 1.1.1)
47
+ kaminari-activerecord (= 1.1.1)
48
+ kaminari-core (= 1.1.1)
49
+ kaminari-actionview (1.1.1)
50
+ actionview
51
+ kaminari-core (= 1.1.1)
52
+ kaminari-activerecord (1.1.1)
53
+ activerecord
54
+ kaminari-core (= 1.1.1)
55
+ kaminari-core (1.1.1)
56
+ loofah (2.2.2)
57
+ crass (~> 1.0.2)
58
+ nokogiri (>= 1.5.9)
59
+ method_source (0.9.0)
60
+ mini_portile2 (2.3.0)
61
+ minitest (5.11.3)
62
+ nokogiri (1.8.4)
63
+ mini_portile2 (~> 2.3.0)
64
+ parallel (1.12.1)
65
+ parser (2.5.1.2)
66
+ ast (~> 2.4.0)
67
+ powerpack (0.1.2)
68
+ pry (0.11.3)
69
+ coderay (~> 1.1.0)
70
+ method_source (~> 0.9.0)
71
+ rails-dom-testing (2.0.3)
72
+ activesupport (>= 4.2.0)
73
+ nokogiri (>= 1.6)
74
+ rails-html-sanitizer (1.0.4)
75
+ loofah (~> 2.2, >= 2.2.2)
76
+ rainbow (3.0.0)
77
+ rake (10.5.0)
78
+ rspec (3.8.0)
79
+ rspec-core (~> 3.8.0)
80
+ rspec-expectations (~> 3.8.0)
81
+ rspec-mocks (~> 3.8.0)
82
+ rspec-core (3.8.0)
83
+ rspec-support (~> 3.8.0)
84
+ rspec-expectations (3.8.1)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.8.0)
87
+ rspec-mocks (3.8.0)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.8.0)
90
+ rspec-support (3.8.0)
91
+ rubocop (0.59.2)
92
+ jaro_winkler (~> 1.5.1)
93
+ parallel (~> 1.10)
94
+ parser (>= 2.5, != 2.5.1.1)
95
+ powerpack (~> 0.1)
96
+ rainbow (>= 2.2.2, < 4.0)
97
+ ruby-progressbar (~> 1.7)
98
+ unicode-display_width (~> 1.0, >= 1.0.1)
99
+ rubocop-rspec (1.29.1)
100
+ rubocop (>= 0.58.0)
101
+ ruby-progressbar (1.10.0)
102
+ simplecov (0.16.1)
103
+ docile (~> 1.1)
104
+ json (>= 1.8, < 3)
105
+ simplecov-html (~> 0.10.0)
106
+ simplecov-html (0.10.2)
107
+ sqlite3 (1.3.13)
108
+ thread_safe (0.3.6)
109
+ tzinfo (1.2.5)
110
+ thread_safe (~> 0.1)
111
+ unicode-display_width (1.4.0)
112
+
113
+ PLATFORMS
114
+ ruby
115
+
116
+ DEPENDENCIES
117
+ activerecord (~> 5.0)
118
+ bundler (~> 1.16)
119
+ codeclimate-test-reporter (~> 1.0)
120
+ graphql-kaminari_connection!
121
+ pry (= 0.11.3)
122
+ rake (~> 10.0)
123
+ rspec (~> 3.0)
124
+ rubocop (~> 0.59.1)
125
+ rubocop-rspec (~> 1.29)
126
+ simplecov (~> 0.13)
127
+ sqlite3 (~> 1.3)
128
+
129
+ BUNDLED WITH
130
+ 1.16.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Increments Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,152 @@
1
+ # GraphQL::KaminariConnection
2
+
3
+ [![Gem](https://img.shields.io/gem/v/graphql-kaminari_connection.svg)](https://rubygems.org/gems/graphql-kaminari_connection)
4
+ [![Build Status](https://travis-ci.org/increments/graphql-kaminari_connection.svg?branch=master)](https://travis-ci.org/increments/graphql-kaminari_connection)
5
+ [![Code Climate](https://codeclimate.com/github/increments/graphql-kaminari_connection/badges/gpa.svg)](https://codeclimate.com/github/increments/graphql-kaminari_connection)
6
+ [![Test Coverage](https://codeclimate.com/github/increments/graphql-kaminari_connection/badges/coverage.svg)](https://codeclimate.com/github/increments/graphql-kaminari_connection/coverage)
7
+ [![license](https://img.shields.io/github/license/increments/graphql-kaminari_connection.svg)](https://github.com/increments/graphql-kaminari_connection/blob/master/LICENSE)
8
+
9
+
10
+ Kaminari based GraphQL pagination
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'graphql-kaminari_connection', require: 'graphql/kaminari_connection'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install graphql-kaminari_connection
27
+
28
+ ## Usage
29
+
30
+ Include `GraphQL::KaminariConnection` to an object class:
31
+
32
+ ```rb
33
+ class Types::Article < GraphQL::Schema::Object
34
+ include GraphQL::KaminariConnection
35
+
36
+ field :title, String, null: false
37
+ field :body, String, null: false
38
+ end
39
+ ```
40
+
41
+ then set `.kaminari_connection` to field type and resolve it as a kaminari object:
42
+
43
+ ```rb
44
+ class Types::Query < GraphQL::Schema::Object
45
+ field :articles, ArticleType.kaminari_connection
46
+
47
+ def articles(page: nil, per: nil)
48
+ Article.all.page(page).per(per)
49
+ end
50
+ end
51
+
52
+ class Schema < GraphQL::Schema
53
+ query Types::Query
54
+ end
55
+ ```
56
+
57
+ now, the `Schema`'s definition is:
58
+
59
+ ```graphql
60
+ type Article {
61
+ body: String!
62
+ title: String!
63
+ }
64
+
65
+ type ArticlePage {
66
+ items: [Article!]!
67
+ pageData: PageData!
68
+ }
69
+
70
+ type PageData {
71
+ currentPage: Int!
72
+ isFirstPage: Boolean!
73
+ isLastPage: Boolean!
74
+ isOutOfRange: Boolean!
75
+ limitValue: Int!
76
+ nextPage: Int
77
+ prevPage: Int
78
+ totalPages: Int!
79
+ }
80
+
81
+ type Query {
82
+ articles(page: Int, per: Int): ArticlePage!
83
+ }
84
+ ```
85
+
86
+ ### Additional arguments
87
+
88
+ You can define additional field arguments in its block:
89
+
90
+ ```rb
91
+ class Types::Query < GraphQL::Schema::Object
92
+ field(:articles, ArticleType.kaminari_connection) do
93
+ argument :scope, Types::ArticleScope, required: true
94
+ end
95
+
96
+ def articles(page: nil, per: nil, scope:)
97
+ Article.public_send(scope).page(page).per(per)
98
+ end
99
+ end
100
+ ```
101
+
102
+ ### Without COUNT
103
+
104
+ Give `{ without_count: true }` to `.kaminari_connection`:
105
+
106
+ ```rb
107
+ class Types::Query < GraphQL::Schema::Object
108
+ field :articles, ArticleType.kaminari_connection(without_count: true)
109
+
110
+ def articles(page: nil, per: nil)
111
+ Article.all.page(page).per(per).without_count
112
+ end
113
+ end
114
+ ```
115
+
116
+ now schema definition contains:
117
+
118
+ ```graphql
119
+ type ArticlePageWithoutTotalPages {
120
+ items: [Article!]!
121
+ pageData: PageDataWithoutTotalPages!
122
+ }
123
+
124
+ type PageDataWithoutTotalPages {
125
+ currentPage: Int!
126
+ isFirstPage: Boolean!
127
+ isLastPage: Boolean!
128
+ isOutOfRange: Boolean!
129
+ limitValue: Int!
130
+ nextPage: Int
131
+ prevPage: Int
132
+ # not have totalPages
133
+ }
134
+ ```
135
+
136
+ ## Development
137
+
138
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
139
+
140
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
141
+
142
+ ## Contributing
143
+
144
+ Bug reports and pull requests are welcome on GitHub at https://github.com/increments/graphql-kaminari_connection. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
145
+
146
+ ## License
147
+
148
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
149
+
150
+ ## Code of Conduct
151
+
152
+ Everyone interacting in the Graphql::KaminariConnection project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/increments/graphql-kaminari_connection/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[rubocop spec]
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'graphql/kaminari_connection'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'graphql/kaminari_connection/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'graphql-kaminari_connection'
9
+ spec.version = GraphQL::KaminariConnection::VERSION
10
+ spec.authors = ['Yuku TAKAHASHI']
11
+ spec.email = ['yuku@qiita.com']
12
+
13
+ spec.summary = 'Kaminari based GraphQL pagination'
14
+ spec.homepage = 'https://github.com/increments/graphql-kaminari_connection'
15
+ spec.license = 'MIT'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'graphql', '~> 1.8'
27
+ spec.add_dependency 'kaminari', '~> 1.1'
28
+
29
+ spec.add_development_dependency 'activerecord', '~> 5.0'
30
+ spec.add_development_dependency 'bundler', '~> 1.16'
31
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
32
+ spec.add_development_dependency 'pry', '0.11.3'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'rubocop', '~> 0.59.1'
36
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.29'
37
+ spec.add_development_dependency 'simplecov', '~> 0.13'
38
+ spec.add_development_dependency 'sqlite3', '~> 1.3'
39
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'graphql'
4
+ require 'graphql/kaminari_connection/version'
5
+
6
+ module GraphQL
7
+ module KaminariConnection
8
+ class << self
9
+ def included(klass)
10
+ klass.extend ClassMethods
11
+ end
12
+
13
+ # @return [Class]
14
+ def page_data_type
15
+ @page_data_type ||= define_page_data_type(without_count: false)
16
+ end
17
+
18
+ def page_data_without_count_type
19
+ @page_data_without_count_type ||= define_page_data_type(without_count: true)
20
+ end
21
+
22
+ # If your schema already has 'PageData' type, you can change its name.
23
+ attr_writer :page_data_type_name
24
+
25
+ attr_writer :base_page_data_class
26
+
27
+ private
28
+
29
+ # The name of page data GraphQL type.
30
+ #
31
+ # @return [String]
32
+ def page_data_type_name
33
+ @page_data_type_name || 'PageData'
34
+ end
35
+
36
+ # @return [Class]
37
+ def base_page_data_class
38
+ @base_page_data_class || GraphQL::Schema::Object
39
+ end
40
+
41
+ # @param without_count [Boolean]
42
+ # @return [Class]
43
+ def define_page_data_type(without_count:)
44
+ type_name = without_count ? "#{page_data_type_name}WithoutTotalPages" : page_data_type_name
45
+ Class.new(base_page_data_class) do
46
+ graphql_name type_name
47
+ description 'Information about pagination'
48
+
49
+ field :current_page, 'Int', null: false
50
+ field :is_first_page, 'Boolean', null: false, method: :first_page?
51
+ field :is_last_page, 'Boolean', null: false, method: :last_page?
52
+ field :is_out_of_range, 'Boolean', null: false, method: :out_of_range?
53
+ field :limit_value, 'Int', null: false
54
+ field :next_page, 'Int', null: true
55
+ field :prev_page, 'Int', null: true
56
+ field :total_pages, 'Int', null: false unless without_count
57
+ end
58
+ end
59
+ end
60
+
61
+ module ClassMethods
62
+ def kaminari_connection(without_count: false, **params)
63
+ {
64
+ type: without_count ? page_type_without_count : page_type,
65
+ arguments: page_arguments,
66
+ null: false
67
+ }.merge(params)
68
+ end
69
+
70
+ # @return [Class]
71
+ def base_page_class
72
+ GraphQL::Schema::Object
73
+ end
74
+
75
+ private
76
+
77
+ # @return [Class]
78
+ def page_type_without_count
79
+ @page_type_without_count ||= define_page_type(without_count: true)
80
+ end
81
+
82
+ # @return [Class]
83
+ def page_type
84
+ @page_type ||= define_page_type(without_count: false)
85
+ end
86
+
87
+ def page_arguments
88
+ [
89
+ [:page, type: 'Int', required: false],
90
+ [:per, type: 'Int', required: false]
91
+ ]
92
+ end
93
+
94
+ # @param without_count [Boolean]
95
+ # @return [Class]
96
+ def define_page_type(without_count:)
97
+ type_name = without_count ? "#{graphql_name}PageWithoutTotalPages" : "#{graphql_name}Page"
98
+ type_class = self
99
+ page_data_type_class =
100
+ without_count ? KaminariConnection.page_data_without_count_type : KaminariConnection.page_data_type
101
+
102
+ Class.new(base_page_class) do
103
+ graphql_name type_name
104
+ description "Autogenerated page type for #{type_name}"
105
+
106
+ field :page_data, page_data_type_class, null: false, method: :object
107
+ field :items, [type_class], 'A list of items', null: false, method: :object
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphQL
4
+ module KaminariConnection
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-kaminari_connection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuku TAKAHASHI
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphql
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kaminari
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.11.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.11.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.59.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.59.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.29'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.29'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.13'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.13'
167
+ - !ruby/object:Gem::Dependency
168
+ name: sqlite3
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.3'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.3'
181
+ description:
182
+ email:
183
+ - yuku@qiita.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".rspec"
190
+ - ".rubocop.yml"
191
+ - ".travis.yml"
192
+ - CODE_OF_CONDUCT.md
193
+ - Gemfile
194
+ - Gemfile.lock
195
+ - LICENSE.txt
196
+ - README.md
197
+ - Rakefile
198
+ - bin/console
199
+ - bin/setup
200
+ - graphql-kaminari_connection.gemspec
201
+ - lib/graphql/kaminari_connection.rb
202
+ - lib/graphql/kaminari_connection/version.rb
203
+ homepage: https://github.com/increments/graphql-kaminari_connection
204
+ licenses:
205
+ - MIT
206
+ metadata: {}
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubyforge_project:
223
+ rubygems_version: 2.7.6
224
+ signing_key:
225
+ specification_version: 4
226
+ summary: Kaminari based GraphQL pagination
227
+ test_files: []