README.md in okay-6.0.0 vs README.md in okay-7.0.0
- old
+ new
@@ -63,27 +63,50 @@
# Uses +data+ as the request body.
Okay::HTTP.post("https://httpbin.org/post", data: "hello, world!")
```
-### GraphQL
+### GraphQL DSL
```ruby
require "okay/graphql"
-require "json"
query = GraphQL.query {
viewer {
login
}
}
response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
-JSON.parse(response.body)
+response.body.from_json
# =>
# {"data" =>
# {"viewer" =>
# {"login" => "duckinator"}}}
+```
+
+### Raw GraphQL Queries
+
+There are cases where the DSL is more of a hindrance than help, e.g. if
+you need to use `@filter` or similar. For those cases, you can use raw
+queries:
+
+```ruby
+require "okay/graphql"
+
+query = GraphQL.query <<~QUERY
+ viewer {
+ login
+ }
+QUERY
+
+response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
+response.body.from_json
+# =>
+# {"data" =>
+# {"viewer" =>
+# {"login" => "duckinator"}}}
+
```
## Development
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.