cli
cli copied to clipboard
Native Graphql Support
Currently to hit any Graphql query
or mutation
, we need to convert them first to json.
It would be really great if we can copy the query directly from graphiql
and then pass it to httpie
.
Is it possible with httpie natively ? One of the vs-code extension is already doing it.
Is the same/similar thing possible with httpie
?
@collegeimprovements currently not possible, sadly.
I’d definitely like to look into some form of native GraphQL support — what other GraphQL-related features would you like to see in HTTPie?
tldr; Example:
http query.graphql --schema schema.json
☝🏼Extension can be anything like: http
or gql
or graphql
or post
etc. The idea is user should be able to directly copy-paste the query from graphiql or graphql-client. He should not be worried about json conversion.
👉🏼 --schema
file is optional. When provided the query is parsed & validated against it first. [might be out of scope]
Feature Requests:
- Send
graphql
request. - Variable interpolation in httpie request. e.g. HOST and Request headers are different for
dev
and `prod. - Graphql introspection if possible.
I think with this two features we can compose many powerful apps.
I don't know if the following falls into httpie
's scope.
E.g. We can download graphql's schema.json
file and then we can have autocomplete
and validation
support.
With this two - Vim, VSCode, IDEs can implement: validation, autocomplete and response features for any graphql schema even with offline support. I was trying to send "graphql" queries from vim to terminal, but could not find a tool that can do that.
Useful Links:
- https://github.com/graphql/graphiql/tree/master/packages/graphql-language-service
- https://github.com/apollographql/apollo-tooling#apollo-clientdownload-schema-output
Hey there! I'm thinking about working on this one if that's ok.
I guess this can be broke down to three ideas/PRs:
-
Receive a GraphQL request just as a JSON request
(i.e.
http httpbin.org/post < graphql.schema
) -
Download a JSON request (
--save
or--download
) - Check GraphQL schema against JSON request file 3.1. Receive GraphQL schema (using 1) 3.2. Generate JSON request (using 2) 3.3. Compare generated JSON and given JSON
Obs: I think introspection would be in scope but as far as I understand (correct me if I'm wrong) it comes down to just a regular query, so I guess you'll end up having to write that yourself as a user (i.e. wouldn't be an actual httpie feature).
Am I either misunderstanding the issue, or has this been added?
http POST https://api.spacex.land/graphql/ query="{ launchesPast(limit: 1) { mission_name id } }"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 77
Content-Type: application/json; charset=utf-8
Date: Sun, 06 Dec 2020 23:36:39 GMT
Etag: W/"4d-gZOMzXfj+ItRDOmYGjTauITd5rQ"
Server: Cowboy
Via: 1.1 vegur
X-Powered-By: Express
{
"data": {
"launchesPast": [
{
"id": "109",
"mission_name": "Starlink-15 (v1.0)"
}
]
}
}
And it works with 'messy' whitespace too (directly ctrl-a + ctrl-c'd from graphiql)
http POST https://api.spacex.land/graphql/ query="{
launchesPast(limit: 1) {
mission_name
id
}
}
"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 77
Content-Type: application/json; charset=utf-8
Date: Sun, 06 Dec 2020 23:40:20 GMT
Etag: W/"4d-gZOMzXfj+ItRDOmYGjTauITd5rQ"
Server: Cowboy
Via: 1.1 vegur
X-Powered-By: Express
{
"data": {
"launchesPast": [
{
"id": "109",
"mission_name": "Starlink-15 (v1.0)"
}
]
}
}
@schmidlidev GraphQL requests are regular HTTP requests so they have always been supported. This issue is about deeper GraphQL-specific features.
It would be nice to get GraphQL pagination supported natively. To fetch more than 100 results from GitLab API https://docs.gitlab.com/ee/api/graphql/getting_started.html#pagination on one go.