README.md in graphql-pagination-1.1.0 vs README.md in graphql-pagination-1.1.1
- old
+ new
@@ -27,14 +27,13 @@
end
```
Value returned by query resolver must be a kaminari object or implements its page scope methods (`current_page`, `limit_value`, `total_count`, `total_pages`).
-
## GraphQL query
-```
+```graphql
{
fruits(page: 2, limit: 2) {
collection {
id
name
@@ -47,38 +46,60 @@
}
}
}
```
-```
+```json
{
- 'data': {
- 'checklists': {
- 'collection': [
+ "data": {
+ "checklists": {
+ "collection": [
{
- 'id': '93938bb3-7a6c-4d35-9961-cbb2d4c9e9ac',
- 'name': 'Apple'
+ "id": "93938bb3-7a6c-4d35-9961-cbb2d4c9e9ac",
+ "name": "Apple"
},
{
- 'id': 'b1ee93b2-579a-4107-8454-119bba5afb63',
- 'name': 'Mango'
+ "id": "b1ee93b2-579a-4107-8454-119bba5afb63",
+ "name": "Mango"
}
],
- 'metadata': {
- 'totalPages': 25,
- 'totalCount': 50,
- 'currentPage': 2,
- 'limitValue': 2
+ "metadata": {
+ "totalPages": 25,
+ "totalCount": 50,
+ "currentPage": 2,
+ "limitValue": 2
}
}
}
}
```
+## Custom Metadata
+
+By default, the following fields are present in the metadata block:
+
+```graphql
+metadata {
+ totalPages
+ totalCount
+ currentPage
+ limitValue
+}
+```
+
+These fields correspond to the `GraphqlPagination::CollectionMetadataType` used to provide the pagination information for the collection of data delivered. If you want to add more metadata fields to this block, you can do so by extending this `CollectionMetadataType`:
+
+```ruby
+class MyMetadataType < GraphqlPagination::CollectionMetadataType
+ field :custom_field, String, null: false
+end
+
+field :fruits, Types::FruitType.collection_type(metadata_type: MyMetadataType)
+```
+
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/renofi/graphql-pagination. 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.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
-