File tree Expand file tree Collapse file tree 3 files changed +38
-6
lines changed
Expand file tree Collapse file tree 3 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,38 @@ query ($name: String!, $owner: String!) {
259259}
260260```
261261
262+ Alternatively, you can use the http method ` GRAPHQL ` :
263+ ``` http
264+ GRAPHQL https://api.github.com/graphql
265+ Content-Type: application/json
266+ Authorization: Bearer xxx
267+
268+ query ($name: String!, $owner: String!) {
269+ repository(name: $name, owner: $owner) {
270+ name
271+ fullName: nameWithOwner
272+ description
273+ diskUsage
274+ forkCount
275+ stargazers(first: 5) {
276+ totalCount
277+ nodes {
278+ login
279+ name
280+ }
281+ }
282+ watchers {
283+ totalCount
284+ }
285+ }
286+ }
287+
288+ {
289+ "name": "vscode-restclient",
290+ "owner": "Huachao"
291+ }
292+ ```
293+
262294## Making cURL Request
263295![ cURL Request] ( https://raw.githubusercontent.com/Huachao/vscode-restclient/master/images/curl-request.png )
264296We add the capability to directly run [ curl request] ( https://curl.haxx.se/ ) in REST Client extension. The issuing request command is the same as raw HTTP one. REST Client will automatically parse the request with specified parser.
Original file line number Diff line number Diff line change 1515 ],
1616 "folding" : {
1717 "markers" : {
18- "start" : " ^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH|curl)\\ s+" ,
18+ "start" : " ^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH|GRAPHQL| curl)\\ s+" ,
1919 "end" : " ^#{3,}$"
2020 }
2121 }
22- }
22+ }
Original file line number Diff line number Diff line change @@ -82,10 +82,10 @@ export class HttpRequestParser implements RequestParser {
8282 removeHeader ( headers , 'content-length' ) ;
8383
8484 // check request type
85- const isGraphQlRequest = getHeader ( headers , 'X-Request-Type' ) === 'GraphQL' . toLowerCase ( ) ;
85+ const isGraphQlRequest = requestLine . method . toLowerCase ( ) === 'graphql' || getHeader ( headers , 'X-Request-Type' ) === 'GraphQL' . toLowerCase ( ) ;
8686 if ( isGraphQlRequest ) {
8787 removeHeader ( headers , 'X-Request-Type' ) ;
88-
88+ requestLine . method = 'POST' ;
8989 // a request doesn't necessarily need variables to be considered a GraphQL request
9090 const firstEmptyLine = bodyLines . findIndex ( value => value . trim ( ) === '' ) ;
9191 if ( firstEmptyLine !== - 1 ) {
@@ -152,7 +152,7 @@ export class HttpRequestParser implements RequestParser {
152152 let url : string ;
153153
154154 let match : RegExpExecArray | null ;
155- if ( match = / ^ ( G E T | P O S T | P U T | D E L E T E | P A T C H | H E A D | O P T I O N S | C O N N E C T | T R A C E | L O C K | U N L O C K | P R O P F I N D | P R O P P A T C H | C O P Y | M O V E | M K C O L | M K C A L E N D A R | A C L | S E A R C H ) \s + / i. exec ( line ) ) {
155+ if ( match = / ^ ( G E T | P O S T | P U T | D E L E T E | P A T C H | H E A D | O P T I O N S | C O N N E C T | T R A C E | L O C K | U N L O C K | P R O P F I N D | P R O P P A T C H | C O P Y | M O V E | M K C O L | M K C A L E N D A R | A C L | S E A R C H | G R A P H Q L ) \s + / i. exec ( line ) ) {
156156 method = match [ 1 ] ;
157157 url = line . substr ( match [ 0 ] . length ) ;
158158 } else {
@@ -228,4 +228,4 @@ export class HttpRequestParser implements RequestParser {
228228 private getLineEnding ( contentTypeHeader : string | undefined ) {
229229 return MimeUtility . isMultiPartFormData ( contentTypeHeader ) ? '\r\n' : EOL ;
230230 }
231- }
231+ }
You can’t perform that action at this time.
0 commit comments