1- import  {  fetchJsonSchema ,  jsonSchemaToSDL  }  from  '#/graphql/schema' 
2- import  {  isURL ,  formatMessages ,  LANDING_MESSAGE  }  from  '#/utilities' 
1+ import  {  fetchJsonSchema ,  jsonSchemaToSDL  }  from  '#/graphql/schema.ts ' 
2+ import  {  isURL ,  formatMessages ,  LANDING_MESSAGE  }  from  '#/utilities.ts ' 
33
44/** 
55 * Route Options 
@@ -27,11 +27,11 @@ export async function handler(request: Request): Promise<Response> {
2727      ) 
2828    } 
2929
30-     if  ( requestedFormat   ===   'playground' )  { 
31-       const  {  htmlPage }  =  await  import ( '#/graphql/graphiql.html' ) 
30+     if  ( [ 'playground' ,   'graphiql' ] . includes ( requestedFormat ) )  { 
31+       const  {  htmlPage }  =  await  import ( '#/graphql/graphiql.html.ts ' ) 
3232      return  new  Response ( htmlPage ( {  endpoint : introspectionURL  } ) ,  { 
3333        status : 200 , 
34-         headers : {  'Content-Type' : 'text/html'  } 
34+         headers : {  'Content-Type' : 'text/html'  } , 
3535      } ) 
3636    } 
3737
@@ -42,20 +42,24 @@ export async function handler(request: Request): Promise<Response> {
4242
4343      return  new  Response ( sdlSchema ,  { 
4444        status : sdlSchema . startsWith ( 'Encountered an error' )  ? 400  : 200 , 
45-         headers : {  'Content-Type' : 'text/plain'  } 
45+         headers : {  'Content-Type' : 'text/plain'  } , 
4646      } ) 
4747    } 
4848
4949    return  new  Response ( JSON . stringify ( jsonSchema ) ,  { 
5050      status : 200 , 
51-       headers : {  'Content-Type' : 'application/json'  } 
51+       headers : {  'Content-Type' : 'application/json'  } , 
5252    } ) 
5353  }  catch  ( error )  { 
5454    const  message  =  error  instanceof  Error  ? error . message  : `Encountered an error: ${ error }  
5555    console . error ( message ) 
5656
5757    return  new  Response ( 
58-       formatMessages ( message ,  'The introspection URL should be the URL of a GraphQL endpoint.' ,  LANDING_MESSAGE ) , 
58+       formatMessages ( 
59+         message , 
60+         'The introspection URL should be the URL of a GraphQL endpoint.' , 
61+         LANDING_MESSAGE 
62+       ) , 
5963      {  status : 500 ,  headers : {  'Content-Type' : 'text/plain'  }  } 
6064    ) 
6165  } 
0 commit comments