graphlient 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +47 -0
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +125 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +35 -21
- data/RELEASING.md +61 -0
- data/Rakefile +4 -1
- data/graphlient.gemspec +2 -3
- data/lib/graphlient/client.rb +26 -11
- data/lib/graphlient/config.rb +1 -6
- data/lib/graphlient/errors/error.rb +6 -0
- data/lib/graphlient/errors/http.rb +12 -0
- data/lib/graphlient/errors.rb +2 -0
- data/lib/graphlient/{extension.rb → extensions/query.rb} +1 -1
- data/lib/graphlient/extensions.rb +1 -0
- data/lib/graphlient/version.rb +1 -2
- data/lib/graphlient.rb +6 -1
- data/spec/graphlient/client_spec.rb +31 -15
- data/spec/graphlient/extensions/query_spec.rb +14 -0
- data/spec/graphlient/query_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- metadata +13 -4
- data/spec/graphlient/extension_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63b47be656ea6f5f875fd9b4787190e01229e52
|
4
|
+
data.tar.gz: 563ac147a12a4329fb94c657546ef24509fa35db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba95816c8c386c519d774ee5fbb668ec2d78d7f0bb0177da8ba5941cb033b0f5d14da0845d291d2033ce4bcf45d34db4e3a5918a67afa8585f1f1b232c17ed4
|
7
|
+
data.tar.gz: 2caa1b128e9f8095310ddfca72ef13fe84225b2083f3ae2eead234c9604e97eb25abf51ba5c77ebf50070ff3ccfb4d2b170ff49a95b4060b227b5967323a8b94
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-10-04 14:22:21 -0400 using RuboCop version 0.47.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 3
|
10
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Max: 38
|
13
|
+
|
14
|
+
# Offense count: 5
|
15
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
16
|
+
# URISchemes: http, https
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 135
|
19
|
+
|
20
|
+
# Offense count: 6
|
21
|
+
Style/Documentation:
|
22
|
+
Exclude:
|
23
|
+
- 'spec/**/*'
|
24
|
+
- 'test/**/*'
|
25
|
+
- 'lib/graphlient/client.rb'
|
26
|
+
- 'lib/graphlient/config.rb'
|
27
|
+
- 'lib/graphlient/errors/http.rb'
|
28
|
+
- 'lib/graphlient/extensions/query.rb'
|
29
|
+
- 'lib/graphlient/query.rb'
|
30
|
+
|
31
|
+
# Offense count: 2
|
32
|
+
Style/MethodMissing:
|
33
|
+
Exclude:
|
34
|
+
- 'lib/graphlient/extensions/query.rb'
|
35
|
+
- 'lib/graphlient/query.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
39
|
+
# SupportedStyles: module_function, extend_self
|
40
|
+
Style/ModuleFunction:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/graphlient/config.rb'
|
43
|
+
|
44
|
+
# Offense count: 1
|
45
|
+
Style/MultilineBlockChain:
|
46
|
+
Exclude:
|
47
|
+
- 'spec/graphlient/client_spec.rb'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
### 0.0.4 (10/4/2017)
|
2
|
+
|
3
|
+
* [#8](https://github.com/ashkan18/graphlient/pull/8): Handle HTTP errors and raise `Graphlient::Errors::HTTP` on failure - [@dblock](https://github.com/dblock).
|
4
|
+
* [#5](https://github.com/ashkan18/graphlient/pull/5): Added RuboCop, Ruby-style linter, CHANGELOG, CONTRIBUTING and RELEASING - [@dblock](https://github.com/dblock).
|
5
|
+
* [#4](https://github.com/ashkan18/graphlient/pull/4): Refactored Graphlient::Client to take a URL and options, moved extensions - [@dblock](https://github.com/dblock).
|
6
|
+
|
7
|
+
### 0.0.3 (10/3/2017)
|
8
|
+
|
9
|
+
* Initial public release - [@ashkan18](https://github.com/ashkan18).
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# Contributing to Graphlient
|
2
|
+
|
3
|
+
This project is work of [many contributors](https://github.com/ashkan18/graphlient/graphs/contributors).
|
4
|
+
|
5
|
+
You're encouraged to submit [pull requests](https://github.com/ashkan18/graphlient/pulls), [propose features and discuss issues](https://github.com/ashkan18/graphlient/issues).
|
6
|
+
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
8
|
+
|
9
|
+
### Fork the Project
|
10
|
+
|
11
|
+
Fork the [project on Github](https://github.com/ashkan18/graphlient) and check out your copy.
|
12
|
+
|
13
|
+
```
|
14
|
+
git clone https://github.com/contributor/graphlient.git
|
15
|
+
cd graphlient
|
16
|
+
git remote add upstream https://github.com/ashkan18/graphlient.git
|
17
|
+
```
|
18
|
+
|
19
|
+
### Bundle Install and Test
|
20
|
+
|
21
|
+
Ensure that you can build the project and run tests.
|
22
|
+
|
23
|
+
```
|
24
|
+
bundle install
|
25
|
+
bundle exec rake
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contribute Code
|
29
|
+
|
30
|
+
### Create a Topic Branch
|
31
|
+
|
32
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
33
|
+
|
34
|
+
```
|
35
|
+
git checkout master
|
36
|
+
git pull upstream master
|
37
|
+
git checkout -b my-feature-branch
|
38
|
+
```
|
39
|
+
|
40
|
+
### Write Tests
|
41
|
+
|
42
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec).
|
43
|
+
|
44
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
45
|
+
|
46
|
+
### Write Code
|
47
|
+
|
48
|
+
Implement your feature or bug fix.
|
49
|
+
|
50
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
|
51
|
+
|
52
|
+
Make sure that `bundle exec rake` completes without errors.
|
53
|
+
|
54
|
+
### Write Documentation
|
55
|
+
|
56
|
+
Document any external behavior in the [README](README.md).
|
57
|
+
|
58
|
+
### Update Changelog
|
59
|
+
|
60
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*.
|
61
|
+
|
62
|
+
Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account.
|
63
|
+
|
64
|
+
### Commit Changes
|
65
|
+
|
66
|
+
Make sure git knows your name and email address:
|
67
|
+
|
68
|
+
```
|
69
|
+
git config --global user.name "Your Name"
|
70
|
+
git config --global user.email "contributor@example.com"
|
71
|
+
```
|
72
|
+
|
73
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
74
|
+
|
75
|
+
```
|
76
|
+
git add ...
|
77
|
+
git commit
|
78
|
+
```
|
79
|
+
|
80
|
+
### Push
|
81
|
+
|
82
|
+
```
|
83
|
+
git push origin my-feature-branch
|
84
|
+
```
|
85
|
+
|
86
|
+
### Make a Pull Request
|
87
|
+
|
88
|
+
Go to https://github.com/contributor/graphlient and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
89
|
+
|
90
|
+
### Update CHANGELOG Again
|
91
|
+
|
92
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
93
|
+
|
94
|
+
```
|
95
|
+
* [#123](https://github.com/ashkan18/graphlient/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
96
|
+
```
|
97
|
+
|
98
|
+
Amend your previous commit and force push the changes.
|
99
|
+
|
100
|
+
```
|
101
|
+
git commit --amend
|
102
|
+
git push origin my-feature-branch -f
|
103
|
+
```
|
104
|
+
|
105
|
+
### Rebase
|
106
|
+
|
107
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
108
|
+
|
109
|
+
```
|
110
|
+
git fetch upstream
|
111
|
+
git rebase upstream/master
|
112
|
+
git push origin my-feature-branch -f
|
113
|
+
```
|
114
|
+
|
115
|
+
### Check on Your Pull Request
|
116
|
+
|
117
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
118
|
+
|
119
|
+
### Be Patient
|
120
|
+
|
121
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
122
|
+
|
123
|
+
## Thank You
|
124
|
+
|
125
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,32 +1,34 @@
|
|
1
|
-
# Graphlient
|
2
|
-
Ruby Client for consuming GraphQL based APIs.
|
1
|
+
# Graphlient
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
[](https://badge.fury.io/rb/graphlient)
|
4
|
+
[](https://travis-ci.org/ashkan18/graphlient)
|
6
5
|
|
7
|
-
|
8
|
-
gem 'graphlient'
|
9
|
-
```
|
6
|
+
A Ruby Client for consuming GraphQL-based APIs.
|
10
7
|
|
11
|
-
##
|
8
|
+
## Installation
|
12
9
|
|
13
|
-
Add
|
10
|
+
Add the following line to your Gemfile.
|
14
11
|
|
15
12
|
```ruby
|
16
|
-
|
17
|
-
Graphlient.configure do |config|
|
18
|
-
config.graphql_endpoint = 'http://test-graphql.biz/graphql' # target GraphQL endpoint
|
19
|
-
end
|
13
|
+
gem 'graphlient'
|
20
14
|
```
|
21
15
|
|
22
16
|
## Usage
|
23
|
-
|
17
|
+
|
18
|
+
There are 3 different ways to use this library.
|
24
19
|
|
25
20
|
### Graphlient::Client
|
26
|
-
|
21
|
+
|
22
|
+
Create a new instance of `Graphlient::Client` and pass the query into a block.
|
27
23
|
|
28
24
|
```ruby
|
29
|
-
|
25
|
+
client = Graphlient::Client.new('https://test-graphql.biz/graphql',
|
26
|
+
headers: {
|
27
|
+
'Authorization' => 'Bearer 123'
|
28
|
+
}
|
29
|
+
)
|
30
|
+
|
31
|
+
response = client.query do
|
30
32
|
invoice(id: 10) do
|
31
33
|
id
|
32
34
|
total
|
@@ -38,21 +40,27 @@ response = Graphlient::Client.query(headers: { 'Authorization' => 'Bearer 123'})
|
|
38
40
|
end
|
39
41
|
```
|
40
42
|
|
41
|
-
This will call the endpoint setup in the configuration with `POST` and
|
43
|
+
This will call the endpoint setup in the configuration with `POST`, the `Authorization` header and `query` as
|
44
|
+
|
42
45
|
```graphql
|
43
46
|
invoice(id: 10) {
|
44
47
|
id
|
45
48
|
total
|
46
|
-
line_items{
|
49
|
+
line_items {
|
47
50
|
price
|
48
51
|
item_type
|
49
52
|
}
|
50
53
|
}
|
51
54
|
```
|
52
|
-
|
55
|
+
|
56
|
+
A successful response is a JSON object.
|
57
|
+
|
58
|
+
On failure the client raises `Graphlient::Errors::HTTP` which contains the `response` object.
|
53
59
|
|
54
60
|
### Use Graphlient::Query directly
|
61
|
+
|
55
62
|
You can directly use `Graphlient::Query` to generate GraphQL queries. Example:
|
63
|
+
|
56
64
|
```ruby
|
57
65
|
query = Graphlient::Query.new do
|
58
66
|
query do
|
@@ -67,10 +75,12 @@ query.to_s
|
|
67
75
|
```
|
68
76
|
|
69
77
|
### Use Graphlient::Extension::Query
|
70
|
-
|
78
|
+
|
79
|
+
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.
|
71
80
|
|
72
81
|
```ruby
|
73
|
-
include Graphlient::
|
82
|
+
include Graphlient::Extensions::Query
|
83
|
+
|
74
84
|
query = invoice(id: 10) do
|
75
85
|
line_items
|
76
86
|
end
|
@@ -78,3 +88,7 @@ end
|
|
78
88
|
query.to_s
|
79
89
|
# "\nquery{\n invoice(id: 10){\n line_items\n }\n }\n"
|
80
90
|
```
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
MIT License, see [LICENSE](LICENSE)
|
data/RELEASING.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Releasing Graphlient
|
2
|
+
|
3
|
+
There're no hard rules about when to release graphlient. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
|
4
|
+
|
5
|
+
### Release
|
6
|
+
|
7
|
+
Run tests, check that all tests succeed locally.
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle install
|
11
|
+
rake
|
12
|
+
```
|
13
|
+
|
14
|
+
Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/graphlient) for all supported platforms.
|
15
|
+
|
16
|
+
Change next release in [CHANGELOG.md](CHANGELOG.md) to the new version.
|
17
|
+
|
18
|
+
```
|
19
|
+
### 0.2.2 (7/10/2015)
|
20
|
+
```
|
21
|
+
|
22
|
+
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
23
|
+
|
24
|
+
Commit your changes.
|
25
|
+
|
26
|
+
```
|
27
|
+
git add README.md CHANGELOG.md
|
28
|
+
git commit -m "Preparing for release, 0.2.2."
|
29
|
+
git push origin master
|
30
|
+
```
|
31
|
+
|
32
|
+
Release.
|
33
|
+
|
34
|
+
```
|
35
|
+
$ rake release
|
36
|
+
|
37
|
+
graphlient 0.2.2 built to pkg/graphlient-0.2.2.gem.
|
38
|
+
Tagged v0.2.2.
|
39
|
+
Pushed git commits and tags.
|
40
|
+
Pushed graphlient 0.2.2 to rubygems.org.
|
41
|
+
```
|
42
|
+
|
43
|
+
### Prepare for the Next Version
|
44
|
+
|
45
|
+
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
46
|
+
|
47
|
+
```
|
48
|
+
### 0.2.3 (Next)
|
49
|
+
|
50
|
+
* Your contribution here.
|
51
|
+
```
|
52
|
+
|
53
|
+
Increment the third version number in [lib/graphlient/version.rb](lib/graphlient/version.rb). Usually the major version is incremented during the development cycle when the release contains major features or breaking API changes (eg. change `0.2.1` to `0.3.0`).
|
54
|
+
|
55
|
+
Commit your changes.
|
56
|
+
|
57
|
+
```
|
58
|
+
git add CHANGELOG.md lib/graphlient/version.rb
|
59
|
+
git commit -m "Preparing for next development iteration, 0.2.3."
|
60
|
+
git push origin master
|
61
|
+
```
|
data/Rakefile
CHANGED
data/graphlient.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
2
|
|
4
3
|
require 'graphlient/version'
|
@@ -14,5 +13,5 @@ Gem::Specification.new do |s|
|
|
14
13
|
s.require_paths = ['lib']
|
15
14
|
s.homepage = 'http://github.com/ashkan18/graphlient'
|
16
15
|
s.licenses = ['MIT']
|
17
|
-
s.summary =
|
18
|
-
end
|
16
|
+
s.summary = 'Ruby Gem for consuming GraphQL endpoints'
|
17
|
+
end
|
data/lib/graphlient/client.rb
CHANGED
@@ -1,22 +1,37 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'uri'
|
3
|
-
require 'json'
|
4
|
-
|
5
1
|
module Graphlient
|
6
|
-
|
7
|
-
|
2
|
+
class Client
|
3
|
+
attr_reader :uri
|
4
|
+
attr_reader :options
|
5
|
+
|
6
|
+
def initialize(url, options = {})
|
7
|
+
@uri = URI(url)
|
8
|
+
@options = options.dup
|
9
|
+
end
|
10
|
+
|
11
|
+
def query(&block)
|
8
12
|
query = Graphlient::Query.new do
|
9
13
|
instance_eval(&block)
|
10
14
|
end
|
11
|
-
|
12
|
-
|
15
|
+
response = post(query)
|
16
|
+
raise Graphlient::Errors::HTTP.new(response.message, response) unless response.is_a? Net::HTTPSuccess
|
17
|
+
parse(response.body)
|
18
|
+
end
|
19
|
+
|
20
|
+
def connection
|
21
|
+
@connection ||= Net::HTTP.new(uri.host, uri.port)
|
22
|
+
end
|
23
|
+
|
24
|
+
def post(query)
|
13
25
|
request = Net::HTTP::Post.new(uri.request_uri)
|
14
26
|
request.body = { query: query.to_s }.to_json
|
15
|
-
headers.each do |k, v|
|
27
|
+
options[:headers].each do |k, v|
|
16
28
|
request[k] = v
|
17
29
|
end
|
18
|
-
|
19
|
-
|
30
|
+
connection.request(request)
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse(response)
|
34
|
+
JSON.parse(response, symbolize_names: true)
|
20
35
|
end
|
21
36
|
end
|
22
37
|
end
|
data/lib/graphlient/config.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'extensions/query'
|
data/lib/graphlient/version.rb
CHANGED
data/lib/graphlient.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
1
5
|
require 'graphlient/version'
|
2
6
|
require 'graphlient/config.rb'
|
3
|
-
require 'graphlient/
|
7
|
+
require 'graphlient/extensions'
|
8
|
+
require 'graphlient/errors'
|
4
9
|
require 'graphlient/query'
|
5
10
|
require 'graphlient/client'
|
@@ -1,26 +1,42 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Graphlient::Client do
|
4
|
+
let(:graphql_endpoint) { 'http://graph.biz/gprahql' }
|
5
|
+
let(:request_headers) do
|
6
|
+
{
|
7
|
+
'Authorization' => 'Bearer 1231',
|
8
|
+
'Content-Type' => 'application/json'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
let(:graphql_client) { Graphlient::Client.new(graphql_endpoint, headers: request_headers) }
|
5
12
|
describe '#query' do
|
6
|
-
let(:
|
7
|
-
|
8
|
-
before do
|
9
|
-
Graphlient.configure do |config|
|
10
|
-
config.graphql_endpoint = graphql_endpoint
|
11
|
-
end
|
12
|
-
end
|
13
|
-
it 'returns expected query with block' do
|
14
|
-
graphql_post_request
|
15
|
-
Graphlient::Client.query('Authorization' => 'Bearer 1231', 'Content-Type' => 'application/json') do
|
13
|
+
let(:response) do
|
14
|
+
graphql_client.query do
|
16
15
|
invoice(id: 10) do
|
17
16
|
line_items
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
end
|
20
|
+
describe 'success' do
|
21
|
+
let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(body: {}.to_json) }
|
22
|
+
it 'returns expected query with block' do
|
23
|
+
expect(response).to eq({})
|
24
|
+
expect(graphql_post_request.with(
|
25
|
+
body: { query: "{ \ninvoice(id: 10){\n line_items\n }\n }" },
|
26
|
+
headers: { 'Content-Type' => 'application/json' }
|
27
|
+
)).to have_been_made.once
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe 'failure' do
|
31
|
+
let!(:graphql_post_request) { stub_request(:post, 'http://graph.biz/gprahql').to_return(status: [500, 'Internal Server Error']) }
|
32
|
+
it 'fails with an exception' do
|
33
|
+
expect do
|
34
|
+
response
|
35
|
+
end.to raise_error Graphlient::Errors::HTTP do |e|
|
36
|
+
expect(e.to_s).to eq 'Internal Server Error'
|
37
|
+
expect(e.response.code.to_i).to eq 500
|
38
|
+
end
|
39
|
+
end
|
24
40
|
end
|
25
41
|
end
|
26
42
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Graphlient::Extensions::Query do
|
4
|
+
describe 'Query' do
|
5
|
+
include Graphlient::Extensions::Query
|
6
|
+
|
7
|
+
it 'returns proper query' do
|
8
|
+
query = invoice(id: 10) do
|
9
|
+
line_items
|
10
|
+
end
|
11
|
+
expect(query.to_s).to eq("{ \ninvoice(id: 10){\n line_items\n }\n }")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphlient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashkan Nasseri
|
@@ -19,22 +19,31 @@ files:
|
|
19
19
|
- ".byebug_history"
|
20
20
|
- ".gitignore"
|
21
21
|
- ".rspec"
|
22
|
+
- ".rubocop.yml"
|
23
|
+
- ".rubocop_todo.yml"
|
22
24
|
- ".ruby-version"
|
23
25
|
- ".travis.yml"
|
26
|
+
- CHANGELOG.md
|
27
|
+
- CONTRIBUTING.md
|
24
28
|
- Gemfile
|
25
29
|
- Gemfile.lock
|
26
30
|
- LICENSE
|
27
31
|
- README.md
|
32
|
+
- RELEASING.md
|
28
33
|
- Rakefile
|
29
34
|
- graphlient.gemspec
|
30
35
|
- lib/graphlient.rb
|
31
36
|
- lib/graphlient/client.rb
|
32
37
|
- lib/graphlient/config.rb
|
33
|
-
- lib/graphlient/
|
38
|
+
- lib/graphlient/errors.rb
|
39
|
+
- lib/graphlient/errors/error.rb
|
40
|
+
- lib/graphlient/errors/http.rb
|
41
|
+
- lib/graphlient/extensions.rb
|
42
|
+
- lib/graphlient/extensions/query.rb
|
34
43
|
- lib/graphlient/query.rb
|
35
44
|
- lib/graphlient/version.rb
|
36
45
|
- spec/graphlient/client_spec.rb
|
37
|
-
- spec/graphlient/
|
46
|
+
- spec/graphlient/extensions/query_spec.rb
|
38
47
|
- spec/graphlient/query_spec.rb
|
39
48
|
- spec/spec_helper.rb
|
40
49
|
homepage: http://github.com/ashkan18/graphlient
|
@@ -57,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
66
|
version: 1.3.6
|
58
67
|
requirements: []
|
59
68
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.5.1
|
61
70
|
signing_key:
|
62
71
|
specification_version: 4
|
63
72
|
summary: Ruby Gem for consuming GraphQL endpoints
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Graphlient::Extension::Query do
|
5
|
-
describe 'Query' do
|
6
|
-
include Graphlient::Extension::Query
|
7
|
-
|
8
|
-
it 'returns proper query' do
|
9
|
-
query = invoice(id: 10) do
|
10
|
-
line_items
|
11
|
-
end
|
12
|
-
expect( query.to_s ).to eq("{ \ninvoice(id: 10){\n line_items\n }\n }")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|