@@ -93,23 +93,34 @@ export function filenameIsReadme(filename) {
9393}
9494
9595// Tools like Prettier can infer that a string is GraphQL if it uses this tagged
96- // template liteal .
96+ // template literal .
9797export function gql ( strings ) {
9898 return strings [ 0 ] ;
9999}
100100
101101export async function fetchGraphql ( query , variables = { } ) {
102102 const url = `${ API_URL } /graphql` ;
103- const response = await fetch ( url , {
104- method : "POST" ,
105- headers : {
106- "Content-Type" : "application/json" ,
107- Accept : "application/json" ,
108- } ,
109- mode : "cors" ,
110- credentials : "include" ,
111- body : JSON . stringify ( { query, variables } ) ,
112- } ) ;
103+ let response ;
104+ try {
105+ response = await fetch ( url , {
106+ method : "POST" ,
107+ headers : {
108+ "Content-Type" : "application/json" ,
109+ Accept : "application/json" ,
110+ } ,
111+ mode : "cors" ,
112+ credentials : "include" ,
113+ body : JSON . stringify ( { query, variables } ) ,
114+ } ) ;
115+ } catch ( error ) {
116+ console . error ( "Failed to fetch" , {
117+ message : error . message ,
118+ url,
119+ query,
120+ variables,
121+ } ) ;
122+ throw error ;
123+ }
113124 if ( response . status === 403 ) {
114125 window . location = `${ API_URL } /auth` ;
115126 }
0 commit comments