making request GRAPH QL api #724
sunilkumarnagoore
started this conversation in
General
Replies: 2 comments
-
A great question to ask in discussions. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@sunilkumarnagoore GraphQL is a protocol on top of HTTP. This gem provides HTTP client. You can find details on how to make GraphQL queries here: https://graphql.org/learn/serving-over-http/#http-methods-headers-and-body Here's a small example: require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "http"
end
authorization = "bearer #{ENV.fetch('GITHUB_ACCESS_TOKEN')}"
query = <<~GRAPHQL
query {
repository(owner: "httprb", name: "http") {
description
}
}
GRAPHQL
puts HTTP \
.headers("Authorization" => authorization) \
.post("https://api.github.com/graphql", json: { query: query }) \
.parse(:json) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
how to make use this http gem to make request for GRAPH QL API
Beta Was this translation helpful? Give feedback.
All reactions