Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export ExpressContext #2352

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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