Skip to content

Commit

Permalink
Fix and Export Extension and Playground Types (#1360)
Browse files Browse the repository at this point in the history
* export playground types

* make playground configuration recursively partial
  • Loading branch information
evans authored Jul 16, 2018
1 parent 8a58892 commit fa6c973
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 15 deletions.
23 changes: 22 additions & 1 deletion packages/apollo-server-cloudflare/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
export * from 'graphql-tools';

export { ApolloServer } from './ApolloServer';
export { gql } from 'apollo-server-core';

export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
toApolloError,
SyntaxError,
ValidationError,
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';
7 changes: 6 additions & 1 deletion packages/apollo-server-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export {

export { convertNodeHttpToRequest } from './nodeHttpToRequest';

export { createPlaygroundOptions } from './playground';
export {
createPlaygroundOptions,
PlaygroundConfig,
defaultPlaygroundOptions,
PlaygroundRenderPageOptions,
} from './playground';

// ApolloServer Base class
export { ApolloServerBase } from './ApolloServer';
Expand Down
11 changes: 10 additions & 1 deletion packages/apollo-server-core/src/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export {
// by the integration subclasses
const playgroundVersion = '1.7.2';

export type PlaygroundConfig = Partial<PlaygroundRenderPageOptions> | boolean;
// https://stackoverflow.com/a/51365037
type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object ? RecursivePartial<T[P]> : T[P]
};

export type PlaygroundConfig =
| RecursivePartial<PlaygroundRenderPageOptions>
| boolean;

export const defaultPlaygroundOptions = {
version: playgroundVersion,
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-server-express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
Expand All @@ -10,6 +12,10 @@ export {
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export * from 'graphql-tools';
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-server-hapi/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
Expand All @@ -10,6 +12,10 @@ export {
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export * from 'graphql-tools';
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-server-koa/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
Expand All @@ -10,6 +12,10 @@ export {
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export * from 'graphql-tools';
Expand Down
1 change: 0 additions & 1 deletion packages/apollo-server-lambda/src/ApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as lambda from 'aws-lambda';
import { ApolloServerBase } from 'apollo-server-core';
export { GraphQLOptions, GraphQLExtension } from 'apollo-server-core';
import { GraphQLOptions, Config } from 'apollo-server-core';
import {
renderPlaygroundPage,
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-server-lambda/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
Expand All @@ -10,6 +12,10 @@ export {
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export * from 'graphql-tools';
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-server-micro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
gql,
// Errors
ApolloError,
Expand All @@ -10,6 +12,10 @@ export {
AuthenticationError,
ForbiddenError,
UserInputError,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export * from 'graphql-tools';
Expand Down
13 changes: 12 additions & 1 deletion packages/apollo-server/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ export * from 'graphql-tools';
export * from 'graphql-subscriptions';

export {
gql,
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
Config,
// Errors
ApolloError,
toApolloError,
SyntaxError,
ValidationError,
AuthenticationError,
ForbiddenError,
UserInputError,
gql,
// playground
defaultPlaygroundOptions,
PlaygroundConfig,
PlaygroundRenderPageOptions,
} from 'apollo-server-core';

export { CorsOptions } from 'apollo-server-express';
10 changes: 0 additions & 10 deletions packages/apollo-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ import {
} from 'apollo-server-express';
import { Config } from 'apollo-server-core';

export {
GraphQLUpload,
GraphQLOptions,
GraphQLExtension,
gql,
Config,
} from 'apollo-server-core';

export { CorsOptions } from 'apollo-server-express';

export * from './exports';

export interface ServerInfo {
Expand Down

0 comments on commit fa6c973

Please sign in to comment.