<commit_before># Graphlient

[![Gem Version](https://badge.fury.io/rb/graphlient.svg)](https://badge.fury.io/rb/graphlient)
[![Build Status](https://travis-ci.org/ashkan18/graphlient.svg?branch=master)](https://travis-ci.org/ashkan18/graphlient)

A Ruby Client for consuming GraphQL-based APIs.

## Installation

Add following line to your Gemfile.

```ruby
gem 'graphlient'
```

## Usage

There are 3 different ways to use this library.

### Graphlient::Client

Create a new instance of `Graphlient::Client` and pass the query into a block.

```ruby
client = Graphlient::Client.new('http://test-graphql.biz/graphql', headers: { 'Authorization' => 'Bearer 123'})

response = client.query do
  invoice(id: 10) do
    id
    total
    line_items do
      price
      item_type
    end
  end
end
```

This will call the endpoint setup in the configuration with `POST`, the `Authorization` header and `query` as

```graphql
invoice(id: 10) {
  id
  total
  line_items{
    price
    item_type
  }
}
```

### Use Graphlient::Query directly

You can directly use `Graphlient::Query` to generate GraphQL queries. Example:

```ruby
query = Graphlient::Query.new do
  query do
    invoice(id: 10) do
      line_items
    end
  end
end

query.to_s
# "\nquery{\n  invoice(id: 10){\n    line_items\n    }\n  }\n"
```

### Use Graphlient::Extension::Query

You can include `Graphlient::Extensions::Query` in your class. This will add a new `method_missing` method to your context which will be used to generate GraphQL queries.

```ruby
include Graphlient::Extensions::Query

query = invoice(id: 10) do
  line_items
end

query.to_s
# "\nquery{\n  invoice(id: 10){\n    line_items\n    }\n  }\n"
```

## License

MIT License, see [LICENSE](LICENSE)
<commit_msg>Prettier README.<commit_after># Graphlient

[![Gem Version](https://badge.fury.io/rb/graphlient.svg)](https://badge.fury.io/rb/graphlient)
[![Build Status](https://travis-ci.org/ashkan18/graphlient.svg?branch=master)](https://travis-ci.org/ashkan18/graphlient)

A Ruby Client for consuming GraphQL-based APIs.

## Installation

Add the following line to your Gemfile.

```ruby
gem 'graphlient'
```

## Usage

There are 3 different ways to use this library.

### Graphlient::Client

Create a new instance of `Graphlient::Client` and pass the query into a block.

```ruby
client = Graphlient::Client.new('https://test-graphql.biz/graphql',
  headers: {
    'Authorization' => 'Bearer 123'
  }
)

response = client.query do
  invoice(id: 10) do
    id
    total
    line_items do
      price
      item_type
    end
  end
end
```

This will call the endpoint setup in the configuration with `POST`, the `Authorization` header and `query` as

```graphql
invoice(id: 10) {
  id
  total
  line_items{
    price
    item_type
  }
}
```

The response is a JSON object.

### Use Graphlient::Query directly

You can directly use `Graphlient::Query` to generate GraphQL queries. Example:

```ruby
query = Graphlient::Query.new do
  query do
    invoice(id: 10) do
      line_items
    end
  end
end

query.to_s
# "\nquery{\n  invoice(id: 10){\n    line_items\n    }\n  }\n"
```

### Use Graphlient::Extension::Query

You can include `Graphlient::Extensions::Query` in your class. This will add a new `method_missing` method to your context which will be used to generate GraphQL queries.

```ruby
include Graphlient::Extensions::Query

query = invoice(id: 10) do
  line_items
end

query.to_s
# "\nquery{\n  invoice(id: 10){\n    line_items\n    }\n  }\n"
```

## License

MIT License, see [LICENSE](LICENSE)

{'fraction_non_alphanumeric': 0.1309255079006772, 'fraction_numerical': 0.011286681715575621, 'mean_word_length': 3.764784946236559, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4949402', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1210, 'n_words': 358}