Apollo-server: Custom Response Headers

Created on 19 Oct 2018  路  1Comment  路  Source: apollographql/apollo-server

Hi I'm currently using apollo-server-lambda is there any way I can add custom response headers?
TIA

Most helpful comment

closing this as I found the solution.

exports.graphqlHandler = (event, context, callback) => {
  const callbackFilter = (error, output) => {
    const customOutput = output;
    customOutput.headers['x-custom-header-response'] = 'value here';
    callback(error, customOutput);
  };
  return server.createHandler()(event, context, callbackFilter);
};

>All comments

closing this as I found the solution.

exports.graphqlHandler = (event, context, callback) => {
  const callbackFilter = (error, output) => {
    const customOutput = output;
    customOutput.headers['x-custom-header-response'] = 'value here';
    callback(error, customOutput);
  };
  return server.createHandler()(event, context, callbackFilter);
};
Was this page helpful?
0 / 5 - 0 ratings