mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:18:31 +02:00
Handle no GraphQL variables
This commit is contained in:
@@ -52,7 +52,7 @@ export async function pluginHookExport(_ctx: Context, request: Partial<HttpReque
|
|||||||
xs.push(NEWLINE);
|
xs.push(NEWLINE);
|
||||||
}
|
}
|
||||||
} else if (typeof request.body?.query === 'string') {
|
} else if (typeof request.body?.query === 'string') {
|
||||||
const body = { query: request.body.query || '', variables: maybeParseJSON(request.body.variables, {}) };
|
const body = { query: request.body.query || '', variables: maybeParseJSON(request.body.variables, undefined) };
|
||||||
xs.push('--data-raw', `${quote(JSON.stringify(body))}`);
|
xs.push('--data-raw', `${quote(JSON.stringify(body))}`);
|
||||||
xs.push(NEWLINE);
|
xs.push(NEWLINE);
|
||||||
} else if (typeof request.body?.text === 'string') {
|
} else if (typeof request.body?.text === 'string') {
|
||||||
|
|||||||
@@ -54,6 +54,21 @@ describe('exporter-curl', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Exports POST with GraphQL data no variables', async () => {
|
||||||
|
expect(
|
||||||
|
await pluginHookExport(ctx, {
|
||||||
|
url: 'https://yaak.app',
|
||||||
|
method: 'POST',
|
||||||
|
bodyType: 'graphql',
|
||||||
|
body: {
|
||||||
|
query : '{foo,bar}',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).toEqual(
|
||||||
|
[`curl -X POST 'https://yaak.app'`, `--data-raw '{"query":"{foo,bar}"}'`].join(` \\\n `),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('Exports PUT with multipart form', async () => {
|
test('Exports PUT with multipart form', async () => {
|
||||||
expect(
|
expect(
|
||||||
await pluginHookExport(ctx, {
|
await pluginHookExport(ctx, {
|
||||||
|
|||||||
Reference in New Issue
Block a user