Skip to content

Commit 6b6787e

Browse files
committed
Add executeGraphQL function for GraphQL step support
1 parent 4ce7682 commit 6b6787e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/ui/src/lib/execute-adapter.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,37 @@ export async function executeRequest(payload: ExecutePayload): Promise<ExecuteRe
3434
return { data: result.data, status: result.status ?? response.status };
3535
}
3636

37+
/**
38+
* Execute a GraphQL request via local /api/execute-graphql endpoint
39+
*/
40+
export async function executeGraphQL(payload: {
41+
endpoint: string;
42+
query: string;
43+
variables?: Record<string, unknown>;
44+
headers?: Record<string, string>;
45+
}): Promise<ExecuteResult> {
46+
const response = await fetch('/api/execute-graphql', {
47+
method: 'POST',
48+
headers: {
49+
'Content-Type': 'application/json',
50+
'ngrok-skip-browser-warning': 'true',
51+
},
52+
body: JSON.stringify(payload),
53+
});
54+
55+
const result = await response.json();
56+
57+
if (!response.ok) {
58+
return {
59+
data: result,
60+
status: response.status,
61+
error: result.error || `Request failed with status ${response.status}`,
62+
};
63+
}
64+
65+
return { data: result, status: response.status };
66+
}
67+
3768
/**
3869
* Check if we're running in cloud mode (always false for open-source version)
3970
*/

0 commit comments

Comments
 (0)