diff --git a/packages/graphql-server-core/src/index.ts b/packages/graphql-server-core/src/index.ts index f1301b1a..21389dca 100644 --- a/packages/graphql-server-core/src/index.ts +++ b/packages/graphql-server-core/src/index.ts @@ -1,2 +1,2 @@ export { runQuery, LogFunction, LogMessage, LogStep, LogAction } from './runQuery' -export { default as ApolloOptions} from './graphqlOptions' +export { default as GraphQLOptions} from './graphqlOptions' diff --git a/packages/graphql-server-express/src/expressApollo.test.ts b/packages/graphql-server-express/src/expressApollo.test.ts index bf603c04..7c79f117 100644 --- a/packages/graphql-server-express/src/expressApollo.test.ts +++ b/packages/graphql-server-express/src/expressApollo.test.ts @@ -3,7 +3,7 @@ import * as bodyParser from 'body-parser'; import { graphqlExpress, graphiqlExpress } from './expressApollo'; import testSuite, { Schema, CreateAppOptions } from 'graphql-server-integration-testsuite'; import { expect } from 'chai'; -import { ApolloOptions } from 'graphql-server-core'; +import { GraphQLOptions } from 'graphql-server-core'; import 'mocha'; function createApp(options: CreateAppOptions = {}) { @@ -22,7 +22,7 @@ function createApp(options: CreateAppOptions = {}) { describe('expressApollo', () => { it('throws error if called without schema', function(){ - expect(() => graphqlExpress(undefined as ApolloOptions)).to.throw('Apollo Server requires options.'); + expect(() => graphqlExpress(undefined as GraphQLOptions)).to.throw('Apollo Server requires options.'); }); it('throws an error if called with more than one argument', function(){ diff --git a/packages/graphql-server-express/src/expressApollo.ts b/packages/graphql-server-express/src/expressApollo.ts index c12a5497..94b450d6 100644 --- a/packages/graphql-server-express/src/expressApollo.ts +++ b/packages/graphql-server-express/src/expressApollo.ts @@ -1,11 +1,11 @@ import * as express from 'express'; import * as graphql from 'graphql'; import * as url from 'url'; -import { ApolloOptions, runQuery } from 'graphql-server-core'; +import { GraphQLOptions, runQuery } from 'graphql-server-core'; import * as GraphiQL from 'graphql-server-module-graphiql'; -export interface ExpressApolloOptionsFunction { - (req?: express.Request, res?: express.Response): ApolloOptions | Promise; +export interface ExpressGraphQLOptionsFunction { + (req?: express.Request, res?: express.Response): GraphQLOptions | Promise; } // Design principles: @@ -17,7 +17,7 @@ export interface ExpressHandler { (req: express.Request, res: express.Response, next): void; } -export function graphqlExpress(options: ApolloOptions | ExpressApolloOptionsFunction): ExpressHandler { +export function graphqlExpress(options: GraphQLOptions | ExpressGraphQLOptionsFunction): ExpressHandler { if (!options) { throw new Error('Apollo Server requires options.'); } @@ -28,7 +28,7 @@ export function graphqlExpress(options: ApolloOptions | ExpressApolloOptionsFunc } return async (req: express.Request, res: express.Response, next) => { - let optionsObject: ApolloOptions; + let optionsObject: GraphQLOptions; if (isOptionsFunction(options)) { try { optionsObject = await options(req, res); @@ -133,7 +133,7 @@ export function graphqlExpress(options: ApolloOptions | ExpressApolloOptionsFunc }; } -function isOptionsFunction(arg: ApolloOptions | ExpressApolloOptionsFunction): arg is ExpressApolloOptionsFunction { +function isOptionsFunction(arg: GraphQLOptions | ExpressGraphQLOptionsFunction): arg is ExpressGraphQLOptionsFunction { return typeof arg === 'function'; } diff --git a/packages/graphql-server-express/src/index.ts b/packages/graphql-server-express/src/index.ts index 0b1d5b0d..9f7dd6ae 100644 --- a/packages/graphql-server-express/src/index.ts +++ b/packages/graphql-server-express/src/index.ts @@ -1,5 +1,5 @@ export { - ExpressApolloOptionsFunction, + ExpressGraphQLOptionsFunction, ExpressHandler, graphqlExpress, graphiqlExpress, diff --git a/packages/graphql-server-hapi/src/hapiApollo.ts b/packages/graphql-server-hapi/src/hapiApollo.ts index 7be42071..41ad72e4 100644 --- a/packages/graphql-server-hapi/src/hapiApollo.ts +++ b/packages/graphql-server-hapi/src/hapiApollo.ts @@ -2,7 +2,7 @@ import * as Boom from 'boom'; import { Server, Request, IReply } from 'hapi'; import { GraphQLResult, formatError } from 'graphql'; import * as GraphiQL from 'graphql-server-module-graphiql'; -import { ApolloOptions, runQuery } from 'graphql-server-core'; +import { GraphQLOptions, runQuery } from 'graphql-server-core'; export interface IRegister { (server: Server, options: any, next: any): void; @@ -10,13 +10,13 @@ export interface IRegister { } export interface HapiOptionsFunction { - (req?: Request): ApolloOptions | Promise; + (req?: Request): GraphQLOptions | Promise; } export interface HapiPluginOptions { path: string; route?: any; - graphqlOptions: ApolloOptions | HapiOptionsFunction; + graphqlOptions: GraphQLOptions | HapiOptionsFunction; } const graphqlHapi: IRegister = function(server: Server, options: HapiPluginOptions, next) { @@ -108,7 +108,7 @@ function getGraphQLParams(payload, isBatch, reply) { async function getGraphQLOptions(request: Request, reply: IReply): Promise<{}> { const options = request.route.settings.plugins['graphql']; - let optionsObject: ApolloOptions; + let optionsObject: GraphQLOptions; if (isOptionsFunction(options)) { try { const opsFunc: HapiOptionsFunction = options; @@ -117,12 +117,12 @@ async function getGraphQLOptions(request: Request, reply: IReply): Promise<{}> { return reply(createErr(500, `Invalid options provided to ApolloServer: ${e.message}`)); } } else { - optionsObject = options; + optionsObject = options; } reply(optionsObject); } -async function processQuery(graphqlParams, optionsObject: ApolloOptions, isBatch: boolean, reply) { +async function processQuery(graphqlParams, optionsObject: GraphQLOptions, isBatch: boolean, reply) { const formatErrorFn = optionsObject.formatError || formatError; let responses: GraphQLResult[] = []; @@ -162,7 +162,7 @@ async function processQuery(graphqlParams, optionsObject: ApolloOptions, isBatch return reply(responses); } -function isOptionsFunction(arg: ApolloOptions | HapiOptionsFunction): arg is HapiOptionsFunction { +function isOptionsFunction(arg: GraphQLOptions | HapiOptionsFunction): arg is HapiOptionsFunction { return typeof arg === 'function'; } diff --git a/packages/graphql-server-integration-testsuite/src/index.ts b/packages/graphql-server-integration-testsuite/src/index.ts index bb10b275..c39f9935 100644 --- a/packages/graphql-server-integration-testsuite/src/index.ts +++ b/packages/graphql-server-integration-testsuite/src/index.ts @@ -14,7 +14,7 @@ import { // tslint:disable-next-line const request = require('supertest-as-promised'); -import { ApolloOptions } from 'graphql-server-core'; +import { GraphQLOptions } from 'graphql-server-core'; import * as GraphiQL from 'graphql-server-module-graphiql'; import { OperationStore } from 'graphql-server-module-operation-store'; @@ -79,7 +79,7 @@ export const Schema = new GraphQLSchema({ export interface CreateAppOptions { excludeParser?: boolean; - graphqlOptions?: ApolloOptions | {(): ApolloOptions | Promise<{}>}; + graphqlOptions?: GraphQLOptions | {(): GraphQLOptions | Promise<{}>}; graphiqlOptions?: GraphiQL.GraphiQLData; } @@ -107,7 +107,7 @@ export default (createApp: CreateAppFunc, destroyApp?: DestroyAppFunc) => { describe('graphqlHTTP', () => { it('can be called with an options function', () => { - app = createApp({graphqlOptions: (): ApolloOptions => ({schema: Schema})}); + app = createApp({graphqlOptions: (): GraphQLOptions => ({schema: Schema})}); const expected = { testString: 'it works', }; @@ -144,7 +144,7 @@ export default (createApp: CreateAppFunc, destroyApp?: DestroyAppFunc) => { it('throws an error if options promise is rejected', () => { app = createApp({ graphqlOptions: () => { - return Promise.reject({}) as any as ApolloOptions; + return Promise.reject({}) as any as GraphQLOptions; }}); const expected = 'Invalid options'; const req = request(app) diff --git a/packages/graphql-server-koa/src/koaApollo.test.ts b/packages/graphql-server-koa/src/koaApollo.test.ts index 2d6fe332..a044652e 100644 --- a/packages/graphql-server-koa/src/koaApollo.test.ts +++ b/packages/graphql-server-koa/src/koaApollo.test.ts @@ -2,7 +2,7 @@ import * as koa from 'koa'; import * as koaRouter from 'koa-router'; import * as koaBody from 'koa-bodyparser'; import { graphqlKoa, graphiqlKoa } from './koaApollo'; -import { ApolloOptions } from 'graphql-server-core'; +import { GraphQLOptions } from 'graphql-server-core'; import { expect } from 'chai'; import * as http from 'http'; @@ -32,7 +32,7 @@ function destroyApp(app) { describe('koaApollo', () => { it('throws error if called without schema', function(){ - expect(() => graphqlKoa(undefined as ApolloOptions)).to.throw('Apollo Server requires options.'); + expect(() => graphqlKoa(undefined as GraphQLOptions)).to.throw('Apollo Server requires options.'); }); it('throws an error if called with more than one argument', function(){ diff --git a/packages/graphql-server-koa/src/koaApollo.ts b/packages/graphql-server-koa/src/koaApollo.ts index 1bd72018..5c465152 100644 --- a/packages/graphql-server-koa/src/koaApollo.ts +++ b/packages/graphql-server-koa/src/koaApollo.ts @@ -1,17 +1,17 @@ import * as koa from 'koa'; import * as graphql from 'graphql'; -import { ApolloOptions, runQuery } from 'graphql-server-core'; +import { GraphQLOptions, runQuery } from 'graphql-server-core'; import * as GraphiQL from 'graphql-server-module-graphiql'; export interface KoaGraphQLOptionsFunction { - (ctx: koa.Context): ApolloOptions | Promise; + (ctx: koa.Context): GraphQLOptions | Promise; } export interface KoaHandler { (req: any, next): void; } -export function graphqlKoa(options: ApolloOptions | KoaGraphQLOptionsFunction): KoaHandler { +export function graphqlKoa(options: GraphQLOptions | KoaGraphQLOptionsFunction): KoaHandler { if (!options) { throw new Error('Apollo Server requires options.'); } @@ -21,7 +21,7 @@ export function graphqlKoa(options: ApolloOptions | KoaGraphQLOptionsFunction): } return async (ctx, next) => { - let optionsObject: ApolloOptions; + let optionsObject: GraphQLOptions; if (isOptionsFunction(options)) { try { optionsObject = await options(ctx); @@ -109,7 +109,7 @@ export function graphqlKoa(options: ApolloOptions | KoaGraphQLOptionsFunction): }; } -function isOptionsFunction(arg: ApolloOptions | KoaGraphQLOptionsFunction): arg is KoaGraphQLOptionsFunction { +function isOptionsFunction(arg: GraphQLOptions | KoaGraphQLOptionsFunction): arg is KoaGraphQLOptionsFunction { return typeof arg === 'function'; }