Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/broadlume/graphql-validation
Simple validation of GraphQL inputs in Ruby
https://github.com/broadlume/graphql-validation
Last synced: 2 months ago
JSON representation
Simple validation of GraphQL inputs in Ruby
- Host: GitHub
- URL: https://github.com/broadlume/graphql-validation
- Owner: broadlume
- License: mit
- Created: 2017-10-04T01:37:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-16T18:04:27.000Z (over 7 years ago)
- Last Synced: 2024-11-21T19:03:37.776Z (2 months ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 4
- Watchers: 16
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/graphql-validation.svg)](https://badge.fury.io/rb/graphql-validation)
[![Build Status](https://travis-ci.org/adHawk/graphql-validation.svg?branch=master)](https://travis-ci.org/adHawk/graphql-validation)# Graphql::Validation
A simple gem to help with common validating GraphQL input objects.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'graphql-validation'
```And then execute:
$ bundle
## Usage
```ruby
ProductValidator = Dry::Validation.Form do
required(:amount).filled(:int?, gteq?: 0)
endCreateProductMutation = GraphQL::Relay::Mutation.define do
input_field :product, !ProductInputType, validate_with: ProductValidator
return_field :id, types.ID
# ...
endMutationType = GraphQL::ObjectType.define do
name 'Mutation'
description 'The mutation root of this schema'
field :createProduct, field: CreateProductMutation.field
end
```## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).