@@ -136,6 +136,19 @@ function parser.parse_body(content_type, body_node, source, context)
136136 name = get_node_field_text (body_node , " name" , source ),
137137 path = path ,
138138 }
139+ elseif node_type == " graphql_body" then
140+ body .__TYPE = " graphql"
141+ local query_text = vim .treesitter .get_node_text (assert (body_node :named_child (0 )), source )
142+ local variables_text
143+ local variables_node = body_node :named_child (1 )
144+ if variables_node then
145+ variables_text = vim .treesitter .get_node_text (variables_node , source )
146+ end
147+ body .data = vim .json .encode ({
148+ query = query_text ,
149+ variables = vim .json .decode (variables_text )
150+ })
151+ logger .debug (body .data )
139152 elseif node_type == " json_body" or content_type == " application/json" then
140153 body .__TYPE = " json"
141154 body .data = vim .trim (vim .treesitter .get_node_text (body_node , source ))
@@ -171,8 +184,6 @@ function parser.parse_body(content_type, body_node, source, context)
171184 body .__TYPE = " multipart_form_data"
172185 -- TODO:
173186 logger .error (" multipart form data is not supported yet" )
174- elseif node_type == " graphql_body" then
175- logger .error (" graphql body is not supported yet" )
176187 end
177188 return body
178189end
@@ -370,6 +381,9 @@ function parser.parse(node, source, ctx)
370381 logger .info (" no method provided, falling back to 'GET'" )
371382 method = " GET"
372383 end
384+ if method == " GRAPHQL" then
385+ method = " POST"
386+ end
373387 -- NOTE: url will be parsed after because in-place variables should be parsed first
374388 local url
375389
0 commit comments