Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Add middleware to transform req.query #102

Closed
zgababa opened this issue Jun 30, 2016 · 1 comment
Closed

Add middleware to transform req.query #102

zgababa opened this issue Jun 30, 2016 · 1 comment

Comments

@zgababa
Copy link

zgababa commented Jun 30, 2016

Hi !

I have a compressed query in req, and I want to decompress it before send to GraphiQL. Why this code doesn't work ? Is it possible ?

router.use("/debug", (req, res, next) => {
  const decompressed = lz.decompressFromEncodedURIComponent(req.query.query);
  req.query = {
    query : decompressed,
  };
  next();
}, require("express-graphql")({
  schema : graphqlRootSchema,
  graphiql : config.get("NODE_ENV") !== "production",
  pretty : true,
  formatError : format.fromGraphiql
}));

Thx !

@leebyron
Copy link
Contributor

If you use http-compatible compression (deflate, gzip) then express-graphql's body parser will automatically deflate the compressed body.

If you're doing some custom compression technique, then you will need to create your own middleware to decompress the body before using the express-graphql middleware.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants