graphql-validation

Validate graphql-ruby arguments easily with dry-validation


License
MIT
Install
gem install graphql-validation -v 0.1.0

Documentation

Gem Version Build Status

Graphql::Validation

A simple gem to help with common validating GraphQL input objects.

Installation

Add this line to your application's Gemfile:

gem 'graphql-validation'

And then execute:

$ bundle

Usage

ProductValidator = Dry::Validation.Form do
  required(:amount).filled(:int?, gteq?: 0)
end

CreateProductMutation = GraphQL::Relay::Mutation.define do
  input_field :product, !ProductInputType, validate_with: ProductValidator
  return_field :id, types.ID
  # ...
end

MutationType = 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.