okay 6.0.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -3
- data/examples/github-graphql-example.rb +3 -2
- data/examples/github-graphql-intentional-failure-example.rb +11 -0
- data/lib/okay/graphql.rb +4 -4
- data/lib/okay/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d0d452136c759c627514748b86e2c0760bf026d74cf8213a9d5f864a4225e79
|
4
|
+
data.tar.gz: 1793596233e2270079bae3649ea8b625617b1554c0a953f3e9bc0fa23d5570a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc59f92d55fb6f2788956dd1ca359a2cce8b5b271af5d3f7cfcd507fef23a2a8fa069656b75f698ba63ef7d6a1fbd3c8c74a02992661a871dcab8a4166564d94
|
7
|
+
data.tar.gz: be1e363656e50537e5612d63144f053ec3ca4ef4cc93db245165fdfc35f733c98d34b51db48bba77bb656d55ceb24f694e29c07c63421530ea7deeff369892ae
|
data/README.md
CHANGED
@@ -65,11 +65,10 @@ Okay::HTTP.post("https://httpbin.org/post", form_data: { "foo" => "bar" })
|
|
65
65
|
Okay::HTTP.post("https://httpbin.org/post", data: "hello, world!")
|
66
66
|
```
|
67
67
|
|
68
|
-
### GraphQL
|
68
|
+
### GraphQL DSL
|
69
69
|
|
70
70
|
```ruby
|
71
71
|
require "okay/graphql"
|
72
|
-
require "json"
|
73
72
|
|
74
73
|
query = GraphQL.query {
|
75
74
|
viewer {
|
@@ -78,13 +77,37 @@ query = GraphQL.query {
|
|
78
77
|
}
|
79
78
|
|
80
79
|
response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
|
81
|
-
|
80
|
+
response.body.from_json
|
82
81
|
# =>
|
83
82
|
# {"data" =>
|
84
83
|
# {"viewer" =>
|
85
84
|
# {"login" => "duckinator"}}}
|
86
85
|
```
|
87
86
|
|
87
|
+
### Raw GraphQL Queries
|
88
|
+
|
89
|
+
There are cases where the DSL is more of a hindrance than help, e.g. if
|
90
|
+
you need to use `@filter` or similar. For those cases, you can use raw
|
91
|
+
queries:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
require "okay/graphql"
|
95
|
+
|
96
|
+
query = GraphQL.query <<~QUERY
|
97
|
+
viewer {
|
98
|
+
login
|
99
|
+
}
|
100
|
+
QUERY
|
101
|
+
|
102
|
+
response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
|
103
|
+
response.body.from_json
|
104
|
+
# =>
|
105
|
+
# {"data" =>
|
106
|
+
# {"viewer" =>
|
107
|
+
# {"login" => "duckinator"}}}
|
108
|
+
|
109
|
+
```
|
110
|
+
|
88
111
|
## Development
|
89
112
|
|
90
113
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -5,6 +5,7 @@ query = Okay::GraphQL.query {
|
|
5
5
|
login
|
6
6
|
}
|
7
7
|
}
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
headers = { bearer_token: ENV['DEMO_GITHUB_TOKEN'] }
|
10
|
+
results = query.submit!(:github, headers).or_raise!
|
10
11
|
puts results.from_json
|
data/lib/okay/graphql.rb
CHANGED
@@ -59,8 +59,8 @@ module Okay
|
|
59
59
|
end
|
60
60
|
|
61
61
|
class Query
|
62
|
-
def initialize(&query)
|
63
|
-
@query = QueryDSL.new(&query)
|
62
|
+
def initialize(raw_query = nil, &query)
|
63
|
+
@query = raw_query || QueryDSL.new(&query)
|
64
64
|
end
|
65
65
|
|
66
66
|
def to_s
|
@@ -97,8 +97,8 @@ module Okay
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def self.query(&query_)
|
101
|
-
Query.new(&query_)
|
100
|
+
def self.query(raw_query = nil, &query_)
|
101
|
+
Query.new(raw_query, &query_)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
data/lib/okay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ellen Marie Dash
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl-better_defaults
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- bin/console
|
114
114
|
- bin/setup
|
115
115
|
- examples/github-graphql-example.rb
|
116
|
+
- examples/github-graphql-intentional-failure-example.rb
|
116
117
|
- lib/okay.rb
|
117
118
|
- lib/okay/graphql.rb
|
118
119
|
- lib/okay/http.rb
|