Skip to content

Commit

Permalink
Translator in context param
Browse files Browse the repository at this point in the history
  • Loading branch information
andrelmlins committed Jun 22, 2020
1 parent 842da5a commit b21327a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "recife-express",
"description": "Recife Express is a integration of recifejs with express",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express, { Express } from 'express';
import express, { Express, Request } from 'express';
import cors, { CorsOptions } from 'cors';
import bodyParser, { Options } from 'body-parser';
import { ApolloServer, IResolvers } from 'apollo-server-express';
Expand All @@ -9,7 +9,7 @@ import { Server } from 'http';
type CreateMiddlewareParams = {
typeDefs: DocumentNode;
resolvers: IResolvers;
context: Context;
context: (request: any) => Context;
graphqlConfig: Config;
};

Expand Down Expand Up @@ -61,7 +61,8 @@ class RecifeExpress {
...graphqlConfig,
resolvers,
typeDefs,
context
context: ({ req }: { req: Request }) =>
context({ method: req.method, url: req.url, header: req.header })
});

apolloServer.applyMiddleware({ app: this.app });
Expand Down

0 comments on commit b21327a

Please sign in to comment.