Sha256: d7617c6a25d5de5490826a9e2fe5b9476c33b4e034a69654a0766634f5de340b

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

# GraphTypes

[![Build Status](https://travis-ci.org/getninjas/graph_types.svg)](https://travis-ci.org/getninjas/graph_types)
[![Gem Version](https://badge.fury.io/rb/graph_types.svg)](https://badge.fury.io/rb/graph_types)

A Collection of Types for GraphQL.

## Installation

Install from RubyGems by adding it to your `Gemfile`, then bundling.

```ruby
# Gemfile
gem 'graph_types'
```
```
$ bundle install
```

## Types:

#### DateTimeType

Declaration:
```ruby
DummyType = GraphQL::ObjectType.define do
  name "Dummy"

  field :name,          !types.String
  field :createdAt,     !GraphTypes::DateTimeType, property: :created_at
end
```

Search:
```ruby
birthday {
  formatted(strftime: "%Y-%m-%d")
}
```

Result:
```json    
"birthday": {
  "formatted": "2018-01-22"
}
```

#### MoneyType

Declaration:
```ruby
DummyType = GraphQL::ObjectType.define do
  name "Dummy"

  field :name,          !types.String
  field :price,         !GraphTypes::MoneyType,    property: :price
end
```

Search:
```ruby
amount {
  cents
  formatted(delimiter: ".", separator: ",", unit: "R$ ")
}
```

Result:
```json
"amount": {
  "cents": 10000,
  "formatted": "R$ 100,00"
}      
```

## Interfaces:

#### TimestampableInterface:

Declaration:
```ruby
DummyType = GraphQL::ObjectType.define do
  name "Dummy"

  interfaces [TimestampableInterface]
end
```

Search:
```ruby
dummy {
  createdAt {
    formatted(strftime: "%FT%T%Z")
  }
  updatedAt {
    formatted(strftime: "%FT%T%Z")
  }
}
```

Result:
```json
"dummy": {
  "createdAt": "2018-01-11T17:36:07BRST",
  "updatedAt": "2018-01-11T17:36:07BRST"
}
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graph_types-0.2.0 README.md