Convert request bodies when changing type (#499)

This commit is contained in:
Gregory Schier
2026-07-04 22:22:35 -07:00
committed by GitHub
parent e52853cc2d
commit eb2a2dd775
13 changed files with 1065 additions and 151 deletions
+47
View File
@@ -562,6 +562,53 @@ describe("importer-curl", () => {
});
});
test("Imports GraphQL JSON data as a GraphQL request", () => {
expect(
convertCurl(
`curl 'https://yaak.app/graphql' -H 'Content-Type: application/json' --data-raw $'{"query":"query Search($id: ID\\u0021) { node(id: $id) { id } }","variables":{"id":"123"}}'`,
),
).toEqual({
resources: {
workspaces: [baseWorkspace()],
httpRequests: [
baseRequest({
url: "https://yaak.app/graphql",
method: "POST",
headers: [{ name: "Content-Type", value: "application/json", enabled: true }],
bodyType: "graphql",
body: {
query: "query Search($id: ID!) { node(id: $id) { id } }",
variables: '{\n "id": "123"\n}',
},
}),
],
},
});
});
test("Imports GraphQL JSON with extensions as JSON", () => {
expect(
convertCurl(
`curl 'https://yaak.app/graphql' -H 'Content-Type: application/json' --data-raw $'{"query":"query Search($id: ID\\u0021) { node(id: $id) { id } }","extensions":{"persistedQuery":{"version":1,"sha256Hash":"abc123"}}}'`,
),
).toEqual({
resources: {
workspaces: [baseWorkspace()],
httpRequests: [
baseRequest({
url: "https://yaak.app/graphql",
method: "POST",
headers: [{ name: "Content-Type", value: "application/json", enabled: true }],
bodyType: "application/json",
body: {
text: '{"query":"query Search($id: ID!) { node(id: $id) { id } }","extensions":{"persistedQuery":{"version":1,"sha256Hash":"abc123"}}}',
},
}),
],
},
});
});
test("Imports data with multiple escape sequences", () => {
expect(
convertCurl(