Support new GraphQL body type in curl export

This commit is contained in:
Gregory Schier
2024-10-22 07:26:16 -07:00
parent 9d24aefba1
commit d91e60f7e0
2 changed files with 23 additions and 4 deletions

View File

@@ -51,9 +51,12 @@ export async function pluginHookExport(_ctx: Context, request: Partial<HttpReque
}
xs.push(NEWLINE);
}
} else if (typeof request.body?.query === 'string') {
const body = { query: request.body.query, variables: request.body.variables ?? undefined };
xs.push('--data-raw', `${quote(JSON.stringify(body))}`);
xs.push(NEWLINE);
} else if (typeof request.body?.text === 'string') {
// --data-raw $'...' to do special ANSI C quoting
xs.push('--data-raw', `$${quote(request.body.text)}`);
xs.push('--data-raw', `${quote(request.body.text)}`);
xs.push(NEWLINE);
}