Skip to content

Commit

Permalink
Revert "Extract TypeScript utility types to apollo-server-env (#2415)"
Browse files Browse the repository at this point in the history
This reverts commit 3a3c67d.

Revert this and #2417 on release-2.5.0 because having apollo-server-plugin-base
use newly added types from apollo-server-env yet only declare it as a
devDependency meant that TypeScript consumers of the published alpha packages
could end up breaking because the import of apollo-server-env could be resolved
to an older version of the package without the newly added types.

I'm not sure if this reversion is the right long term answer vs making the
apollo-server-env dependency non-dev, but this will let the alpha process for
2.5.0 move forward for now.
  • Loading branch information
glasser committed Mar 26, 2019
1 parent fd0357d commit ecc198c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/apollo-datasource-rest/src/RESTDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
URL,
URLSearchParams,
URLSearchParamsInit,
ValueOrPromise,
} from 'apollo-server-env';

import { DataSource, DataSourceConfig } from 'apollo-datasource';
Expand Down Expand Up @@ -42,6 +41,8 @@ export interface CacheOptions {
export type Body = BodyInit | object;
export { Request };

type ValueOrPromise<T> = T | Promise<T>;

export abstract class RESTDataSource<TContext = any> extends DataSource {
httpCache!: HTTPCache;
context!: TContext;
Expand Down
1 change: 0 additions & 1 deletion packages/apollo-server-env/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './fetch';
export * from './url';
export * from './typescript-utility-types';
2 changes: 0 additions & 2 deletions packages/apollo-server-env/src/typescript-utility-types.d.ts

This file was deleted.

6 changes: 4 additions & 2 deletions packages/apollo-server-plugin-base/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ValueOrPromise, WithRequired } from 'apollo-server-env';
export { WithRequired };
import {
GraphQLServiceContext,
GraphQLRequestContext,
Expand All @@ -13,13 +11,17 @@ export {
GraphQLResponse,
};

type ValueOrPromise<T> = T | Promise<T>;

export interface ApolloServerPlugin {
serverWillStart?(service: GraphQLServiceContext): ValueOrPromise<void>;
requestDidStart?<TContext>(
requestContext: GraphQLRequestContext<TContext>,
): GraphQLRequestListener<TContext> | void;
}

export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;

export interface GraphQLRequestListener<TContext = Record<string, any>> {
parsingDidStart?(
requestContext: WithRequired<
Expand Down

0 comments on commit ecc198c

Please sign in to comment.