Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async graphiql(ctx: Context, req: HttpRequest): Promise {
const options: GraphiQLData = {
endpointURL: `${this.config.prefix || ''}/graphql`,
passHeader: ctx.auth.token ? `'Authorization': '${ctx.auth.token}'` : undefined,
// editorTheme: "idea"
};
try {
return await GraphiQL.resolveGraphiQLString(req.queryStringParameters, options);
} catch (error) {
throw new InternalServerError(error.message, error);
}
}
const graphiqlHandler = (
httpContext: HttpContext,
request: IFunctionRequest,
) => {
const query = request.query;
resolveGraphiQLString(query, options, httpContext, request).then(
graphiqlString => {
const result = {
status: HttpStatusCodes.OK,
headers: {
'Content-Type': 'text/html',
},
body: graphiqlString,
isRaw: true,
};
httpContext.res = result;
httpContext.done(null, result);
},
error => {
httpContext.res = {
status: 500,
body: error.message,
const graphiqlHandler = (ctx: AdonisContext): Promise => {
const { request, response } = ctx;
const query = request.get();
return GraphiQL.resolveGraphiQLString(query, options, ctx).then(
graphiqlString => {
response.type('text/html').send(graphiqlString);
},
(error: HttpQueryError) => {
response.status(500).send(error.message);
},
);
};
const graphiqlHandler = (req: express.Request, res: express.Response, next: any) => {
const query = req.url && url.parse(req.url, true).query;
GraphiQL.resolveGraphiQLString(query, options, req).then(
graphiqlString => {
res.setHeader('Content-Type', 'text/html');
res.write(graphiqlString);
res.end();
},
error => next(error)
);
};
return (request, response, next) => {
const query = request.url && url.parse(request.url, true).query;
GraphiQL.resolveGraphiQLString(query, options, request).then(graphiqlString => {
response.setHeader("Content-Type", "text/html");
response.write(graphiqlString);
response.end();
}, error => next(error));
};
}
handler: async (request: Request, h: ResponseToolkit) => {
const graphiqlString = await GraphiQL.resolveGraphiQLString(
request.query,
options.graphiqlOptions,
request
);
return h.response(graphiqlString).type('text/html');
},
method: 'GET',
return ctx => {
const query = ctx.request.query;
return resolveGraphiQLString(query, options, ctx)
.then(graphiqlString => {
ctx.set('Content-Type', 'text/html');
ctx.body = graphiqlString;
});
};
}
const graphiqlHandler = (req: express.Request, res: express.Response, next: any) => {
const query = req.url && url.parse(req.url, true).query;
GraphiQL.resolveGraphiQLString(query, options, req).then(
(graphiqlString: any) => {
res.setHeader('Content-Type', 'text/html');
res.write(graphiqlString);
res.end();
},
(error: any) => next(error)
);
};
return async request => {
let query = request.params;
let response = await resolveGraphiQLString(query, options, request);
return HTMLPage(response);
};
}
return (request: Partial | any, response: ServerResponse | any, next: any) => {
const query = request.url && url.parse(request.url, true).query;
GraphiQL.resolveGraphiQLString(query, options, request).then(
graphiqlString => {
response.setHeader("Content-Type", "text/html");
response.write(graphiqlString);
response.end();
},
error => next(error),
);
};
}