From 154cb4218358a8f9d01ed0d8cb261ba46a1d3eb0 Mon Sep 17 00:00:00 2001 From: Evans Hauser Date: Mon, 16 Jul 2018 15:38:29 -0700 Subject: [PATCH 1/2] export playground types --- .../apollo-server-cloudflare/src/index.ts | 23 ++++++++++++++++++- packages/apollo-server-core/src/index.ts | 7 +++++- packages/apollo-server-express/src/index.ts | 6 +++++ packages/apollo-server-hapi/src/index.ts | 6 +++++ packages/apollo-server-koa/src/index.ts | 6 +++++ .../apollo-server-lambda/src/ApolloServer.ts | 1 - packages/apollo-server-lambda/src/index.ts | 6 +++++ packages/apollo-server-micro/src/index.ts | 6 +++++ packages/apollo-server/src/exports.ts | 13 ++++++++++- packages/apollo-server/src/index.ts | 10 -------- 10 files changed, 70 insertions(+), 14 deletions(-) diff --git a/packages/apollo-server-cloudflare/src/index.ts b/packages/apollo-server-cloudflare/src/index.ts index 829939cdea9..f9a662aa065 100644 --- a/packages/apollo-server-cloudflare/src/index.ts +++ b/packages/apollo-server-cloudflare/src/index.ts @@ -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'; diff --git a/packages/apollo-server-core/src/index.ts b/packages/apollo-server-core/src/index.ts index 668ad93f26a..6e3e3d344c8 100644 --- a/packages/apollo-server-core/src/index.ts +++ b/packages/apollo-server-core/src/index.ts @@ -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'; diff --git a/packages/apollo-server-express/src/index.ts b/packages/apollo-server-express/src/index.ts index 102993062bb..22a3b9e8d76 100644 --- a/packages/apollo-server-express/src/index.ts +++ b/packages/apollo-server-express/src/index.ts @@ -1,6 +1,8 @@ export { GraphQLUpload, GraphQLOptions, + GraphQLExtension, + Config, gql, // Errors ApolloError, @@ -10,6 +12,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; export * from 'graphql-tools'; diff --git a/packages/apollo-server-hapi/src/index.ts b/packages/apollo-server-hapi/src/index.ts index 839fcafe6d5..38374b22e5f 100644 --- a/packages/apollo-server-hapi/src/index.ts +++ b/packages/apollo-server-hapi/src/index.ts @@ -1,6 +1,8 @@ export { GraphQLUpload, GraphQLOptions, + GraphQLExtension, + Config, gql, // Errors ApolloError, @@ -10,6 +12,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; export * from 'graphql-tools'; diff --git a/packages/apollo-server-koa/src/index.ts b/packages/apollo-server-koa/src/index.ts index 839fcafe6d5..38374b22e5f 100644 --- a/packages/apollo-server-koa/src/index.ts +++ b/packages/apollo-server-koa/src/index.ts @@ -1,6 +1,8 @@ export { GraphQLUpload, GraphQLOptions, + GraphQLExtension, + Config, gql, // Errors ApolloError, @@ -10,6 +12,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; export * from 'graphql-tools'; diff --git a/packages/apollo-server-lambda/src/ApolloServer.ts b/packages/apollo-server-lambda/src/ApolloServer.ts index 462ab2ca02c..c8a562a49d3 100644 --- a/packages/apollo-server-lambda/src/ApolloServer.ts +++ b/packages/apollo-server-lambda/src/ApolloServer.ts @@ -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, diff --git a/packages/apollo-server-lambda/src/index.ts b/packages/apollo-server-lambda/src/index.ts index 39a8f62d1e0..2ff184ef590 100644 --- a/packages/apollo-server-lambda/src/index.ts +++ b/packages/apollo-server-lambda/src/index.ts @@ -1,6 +1,8 @@ export { GraphQLUpload, GraphQLOptions, + GraphQLExtension, + Config, gql, // Errors ApolloError, @@ -10,6 +12,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; export * from 'graphql-tools'; diff --git a/packages/apollo-server-micro/src/index.ts b/packages/apollo-server-micro/src/index.ts index 69da3a753cb..903ca4de1a1 100644 --- a/packages/apollo-server-micro/src/index.ts +++ b/packages/apollo-server-micro/src/index.ts @@ -1,6 +1,8 @@ export { GraphQLUpload, GraphQLOptions, + GraphQLExtension, + Config, gql, // Errors ApolloError, @@ -10,6 +12,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; export * from 'graphql-tools'; diff --git a/packages/apollo-server/src/exports.ts b/packages/apollo-server/src/exports.ts index 5f0bc35f590..ded825c35c2 100644 --- a/packages/apollo-server/src/exports.ts +++ b/packages/apollo-server/src/exports.ts @@ -2,6 +2,12 @@ export * from 'graphql-tools'; export * from 'graphql-subscriptions'; export { + gql, + GraphQLUpload, + GraphQLOptions, + GraphQLExtension, + Config, + // Errors ApolloError, toApolloError, SyntaxError, @@ -9,5 +15,10 @@ export { AuthenticationError, ForbiddenError, UserInputError, - gql, + // playground + defaultPlaygroundOptions, + PlaygroundConfig, + PlaygroundRenderPageOptions, } from 'apollo-server-core'; + +export { CorsOptions } from 'apollo-server-express'; diff --git a/packages/apollo-server/src/index.ts b/packages/apollo-server/src/index.ts index 489f52a763a..6d5686d27a8 100644 --- a/packages/apollo-server/src/index.ts +++ b/packages/apollo-server/src/index.ts @@ -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 { From 3d6d272031dbfbfc2ded7337c45dd57e6783a766 Mon Sep 17 00:00:00 2001 From: Evans Hauser Date: Mon, 16 Jul 2018 15:39:15 -0700 Subject: [PATCH 2/2] make playground configuration recursively partial --- packages/apollo-server-core/src/playground.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/apollo-server-core/src/playground.ts b/packages/apollo-server-core/src/playground.ts index 8ae88b75151..aabf52c8dc1 100644 --- a/packages/apollo-server-core/src/playground.ts +++ b/packages/apollo-server-core/src/playground.ts @@ -11,7 +11,16 @@ export { // by the integration subclasses const playgroundVersion = '1.7.2'; -export type PlaygroundConfig = Partial | boolean; +// https://stackoverflow.com/a/51365037 +type RecursivePartial = { + [P in keyof T]?: T[P] extends (infer U)[] + ? RecursivePartial[] + : T[P] extends object ? RecursivePartial : T[P] +}; + +export type PlaygroundConfig = + | RecursivePartial + | boolean; export const defaultPlaygroundOptions = { version: playgroundVersion,