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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89ee2cbda6f5519c795f0f63330492e35f67b31b3e68fbda68e3dda6358c5f76
4
- data.tar.gz: 1556c602c47c035ef3fd20a65ca20a2e92f04c15eb4bcbe65cfe297ecf7f7880
3
+ metadata.gz: 1d0d452136c759c627514748b86e2c0760bf026d74cf8213a9d5f864a4225e79
4
+ data.tar.gz: 1793596233e2270079bae3649ea8b625617b1554c0a953f3e9bc0fa23d5570a6
5
5
  SHA512:
6
- metadata.gz: c39d51d59a0ce40101dc6af8d54216063ba4656457ed1edf4d05e9791b57560ee4f8e547a90a09d2cca5a88bb073021acbbe650ab951c3f080dd084cd5106055
7
- data.tar.gz: 92f4c7175e6e1d18e5edda82a42b23dbabf6a5be2c05e45ab14cb48874df7eff2eab6048b4896c679c02c4fdc75e8336490e5a2a6e1369fb9e8d26efc6a95cf2
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
- JSON.parse(response.body)
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
- results = query.submit!(:github, {bearer_token: ENV['DEMO_GITHUB_TOKEN']}).or_raise!
8
+
9
+ headers = { bearer_token: ENV['DEMO_GITHUB_TOKEN'] }
10
+ results = query.submit!(:github, headers).or_raise!
10
11
  puts results.from_json
@@ -0,0 +1,11 @@
1
+ require "okay/graphql"
2
+
3
+ query = Okay::GraphQL.query {
4
+ viewer {
5
+ login
6
+ }
7
+ }
8
+
9
+ headers = { bearer_token: "oh no, invalid bearer token!" }
10
+ results = query.submit!(:github, headers).or_raise!
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
@@ -1,3 +1,3 @@
1
1
  module Okay
2
- VERSION = "6.0.0"
2
+ VERSION = "7.0.0"
3
3
  end
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: 6.0.0
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-04 00:00:00.000000000 Z
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