Files
IRC-kosmi-relay/cmd/test-introspection/main.go
cottongin dd398c9a8c sync
2025-11-01 21:00:16 -04:00

74 lines
1.3 KiB
Go

package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
// GraphQL introspection query to find all mutations
query := map[string]interface{}{
"query": `{
__schema {
mutationType {
fields {
name
description
args {
name
type {
name
kind
}
}
}
}
}
}`,
}
jsonBody, err := json.Marshal(query)
if err != nil {
fmt.Printf("Failed to marshal: %v\n", err)
return
}
req, err := http.NewRequest("POST", "https://engine.kosmi.io/", bytes.NewReader(jsonBody))
if err != nil {
fmt.Printf("Failed to create request: %v\n", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Referer", "https://app.kosmi.io/")
req.Header.Set("User-Agent", "Mozilla/5.0")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Printf("Request failed: %v\n", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Failed to read response: %v\n", err)
return
}
// Pretty print JSON response
var result map[string]interface{}
if err := json.Unmarshal(body, &result); err != nil {
fmt.Println("Response (raw):")
fmt.Println(string(body))
} else {
prettyJSON, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(prettyJSON))
}
}