File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff 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 */
You can’t perform that action at this time.
0 commit comments