Skip to content

Commit

Permalink
Merge pull request #2352 from KATT/express-context
Browse files Browse the repository at this point in the history
Express context
  • Loading branch information
cheapsteak committed Feb 21, 2019
2 parents 879ed19 + 7cb3376 commit 2a9ad9f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### vNEXT

- `apollo-server-express`: Export `ExpressContext`

### v2.4.4

- Fix typing for ContextFunction incorrectly requiring the context object the function produces to match the parameters of the function [PR #2350](https://github.com/apollographql/apollo-server/pull/2350)
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-express/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const fileUploadMiddleware = (
}
};

interface ExpressContext {
export interface ExpressContext {
req: express.Request;
res: express.Response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import FormData from 'form-data';
import fs from 'fs';
import { createApolloFetch } from 'apollo-fetch';

import { gql, AuthenticationError, Config } from 'apollo-server-core';
import { ApolloServer, ServerRegistration } from '../ApolloServer';
import { gql, AuthenticationError } from 'apollo-server-core';
import {
ApolloServer,
ApolloServerExpressConfig,
ServerRegistration,
} from '../ApolloServer';

import {
NODE_MAJOR_VERSION,
Expand Down Expand Up @@ -57,7 +61,7 @@ describe('apollo-server-express', () => {
let httpServer: http.Server;

async function createServer(
serverOptions: Config,
serverOptions: ApolloServerExpressConfig,
options: Partial<ServerRegistration> = {},
) {
server = new ApolloServer(serverOptions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import connect from 'connect';
import query from 'qs-middleware';
import { ApolloServer } from '../ApolloServer';
import { Config } from 'apollo-server-core';
import { ApolloServer, ApolloServerExpressConfig } from '../ApolloServer';

import testSuite, {
schema as Schema,
Expand All @@ -17,7 +16,7 @@ function createConnectApp(options: CreateAppOptions = {}) {
// connect is probably already using connect-query or qs-middleware.
app.use(query());
const server = new ApolloServer(
(options.graphqlOptions as Config) || { schema: Schema },
(options.graphqlOptions as ApolloServerExpressConfig) || { schema: Schema },
);
// See comment on ServerRegistration.app for its typing.
server.applyMiddleware({ app: app as any });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import express from 'express';
import { ApolloServer } from '../ApolloServer';
import { ApolloServer, ApolloServerExpressConfig } from '../ApolloServer';
import testSuite, {
schema as Schema,
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
import { GraphQLOptions, Config } from 'apollo-server-core';
import { GraphQLOptions } from 'apollo-server-core';

function createApp(options: CreateAppOptions = {}) {
const app = express();

const server = new ApolloServer(
(options.graphqlOptions as Config) || { schema: Schema },
(options.graphqlOptions as ApolloServerExpressConfig) || { schema: Schema },
);
server.applyMiddleware({ app });
return app;
Expand Down

0 comments on commit 2a9ad9f

Please sign in to comment.