Skip to content

Commit

Permalink
Rename a variety of things to no longer be called Apollo
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Oct 23, 2016
1 parent 2bbd0af commit 4a5e6b3
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--

This comment has been minimized.

Copy link
@linhxai001

linhxai001 Jan 1, 2017

var nhanh = yêu cầu ( 'thể hiện' ) ;
var bodyParser = yêu cầu ( 'cơ thể phân tích cú pháp' ) ;
var { apolloExpress , graphiqlExpress } = yêu cầu ( 'apollo-máy chủ' ) ;
var { makeExecutableSchema } = yêu cầu ( 'graphql-công cụ' ) ;

var Typedefs = [ '
gõ truy vấn {
xin chào: String
}

lược đồ {
truy vấn: Truy vấn
} ` ] ;

var phân giải = {
Query : {
xin chào ( gốc ) {
trở lại 'thế giới' ;
}
}
} ;

var schema = makeExecutableSchema ( { Typedefs , phân giải } ) ;
var ứng dụng = nhanh ( ) ;
ứng dụng . sử dụng ( '/ graphql' , bodyParser . json ( ) , apolloExpress ( { schema } ) ) ;
ứng dụng . sử dụng ( '/ graphiql' , graphiqlExpress ( { endpointURL : '/ graphql' } ) ) ;
ứng dụng . nghe ( 4000 , ( ) = > giao diện điều khiển . log ( 'Bây giờ thì vào localhost: 4000 / graphiql' ) ) ;

Thanks for filing a pull request on Apollo Client!
Thanks for filing a pull request on GraphQL Server!
Please look at the following checklist to ensure that your PR
can be accepted quickly:
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"tslint.json": true,
"typings.json": false,
"typings": true,
".gitignore": false
".gitignore": false,
"**/dist": true
}
}
}
20 changes: 10 additions & 10 deletions DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# Apollo Server design goals
# GraphQL Server design goals

The goal of this project is to build a GraphQL server for Node.js that is simple, flexible, and performant. It is a Node.js GraphQL server built for production use.

Apollo Server consists of three parts:
GraphQL Server consists of three parts:

1. Core
2. Integrations
3. Modules

At the core of Apollo Server is a function called `runQuery`, which handles parsing, validating and executing queries. Its interface is generic in order to allow for integrations with different Node.js server frameworks. Extensions provide useful functionality that can be shared between different integrations.
At the core of GraphQL Server is a function called `runQuery`, which handles parsing, validating and executing queries. Its interface is generic in order to allow for integrations with different Node.js server frameworks. Extensions provide useful functionality that can be shared between different integrations.


### Core

The main goals of Apollo Server are (in order of priority):
The main goals of GraphQL Server are (in order of priority):

1. Simplicity: Apollo Server’s core API is very straight forward. It’s one function that does one thing really well (parsing, validating and executing GraphQL queries), and doesn’t do anything else.
2. Flexibility: The core of Apollo Server should be transport-agnostic (e.g. it doesn’t deal with HTTP or Websockets directly. This is will be handled in the wrappers for Express, Hapi, etc.)
3. Performance: Apollo server should be be tunable to make it fast in production. One example of this is that it should be able to take pre-stored queries to skip parsing and validation. It should also allow easy integration of profiling tools like Apollo Tracer that help with debugging and optimizing server performance.
1. Simplicity: GraphQL Server’s core API is very straight forward. It’s one function that does one thing really well (parsing, validating and executing GraphQL queries), and doesn’t do anything else.
2. Flexibility: The core of GraphQL Server should be transport-agnostic (e.g. it doesn’t deal with HTTP or Websockets directly. This is will be handled in the wrappers for Express, Hapi, etc.)
3. Performance: GraphQL server should be be tunable to make it fast in production. One example of this is that it should be able to take pre-stored queries to skip parsing and validation. It should also allow easy integration of profiling tools like Apollo Optics that help with debugging and optimizing server performance.

### Integrations

Apollo Server should come with a set of integrations for different Node.js server frameworks:
GraphQL Server should come with a set of integrations for different Node.js server frameworks:

- Express
- Hapi
- Connect
- Koa
- ...

Framework integrations take care of parsing requests, submitting them to Apollo Server’s core runQuery function, and sending the response back to the client. These integrations should accept requests over HTTP, websockets or other means, then invoke `runQuery` as appropriate, and return the result. They should be written in such a way that makes it easy to add features, such as batched queries, subscriptions etc.
Framework integrations take care of parsing requests, submitting them to GraphQL Server’s core runQuery function, and sending the response back to the client. These integrations should accept requests over HTTP, websockets or other means, then invoke `runQuery` as appropriate, and return the result. They should be written in such a way that makes it easy to add features, such as batched queries, subscriptions etc.

Framework integrations should hide all transport-specific (eg. setting headers) and framework-specific things (eg. registering a route) from the core functions.

### Modules
Things that are not part of runQuery’s tasks, but are GraphQL specific (such as providing a bundle for the GraphiQL UI, generating a schema, storing prepared queries, etc.) should be implemented in another core module of Apollo Server that lives alongside runQuery, or be imported from graphql-tools or other related packages.
Things that are not part of runQuery’s tasks, but are GraphQL specific (such as providing a bundle for the GraphiQL UI, generating a schema, storing prepared queries, etc.) should be implemented in another core module of GraphQL Server that lives alongside runQuery, or be imported from graphql-tools or other related packages.
6 changes: 3 additions & 3 deletions packages/graphql-server-core/src/apolloOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GraphQLSchema, ValidationRule } from 'graphql';
import { LogFunction } from './runQuery';

/*
* ExpressApolloOptions
* GraphQLServerOptions
*
* - schema: an executable GraphQL schema used to fulfill requests.
* - (optional) formatError: Formatting function applied to all errors before response is sent
Expand All @@ -15,7 +15,7 @@ import { LogFunction } from './runQuery';
* - (optional) debug: a boolean that will print additional debug logging if execution errors occur
*
*/
interface ApolloOptions {
interface GraphQLServerOptions {
schema: GraphQLSchema;
formatError?: Function;
rootValue?: any;
Expand All @@ -27,4 +27,4 @@ interface ApolloOptions {
debug?: boolean;
}

export default ApolloOptions;
export default GraphQLServerOptions;
18 changes: 9 additions & 9 deletions packages/graphql-server-express/src/apolloServerHttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* sure apolloServer still works if used in the place of express-graphql.
*/

import { apolloExpress } from './expressApollo';
import { graphqlExpress } from './expressApollo';

/**
* Copyright (c) 2015, Facebook, Inc.
Expand Down Expand Up @@ -158,7 +158,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress(() => ({
app.use(urlString(), graphqlExpress(() => ({
schema: TestSchema
})));

Expand All @@ -185,7 +185,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress(() => ({
app.use(urlString(), graphqlExpress(() => ({
schema: TestSchema
})));

Expand Down Expand Up @@ -253,7 +253,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {

// Providing the request as part of `rootValue` allows it to
// be accessible from within Schema resolve functions.
app.use(urlString(), apolloExpress(req => {
app.use(urlString(), graphqlExpress(req => {
return {
schema: TestMutationSchema,
rootValue: { request: req }
Expand Down Expand Up @@ -285,7 +285,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress({
app.use(urlString(), graphqlExpress({
schema: TestSchema
}));

Expand All @@ -310,7 +310,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress({
app.use(urlString(), graphqlExpress({
schema: TestSchema,
formatError(error) {
return { message: 'Custom error format: ' + error.message };
Expand All @@ -336,7 +336,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress({
app.use(urlString(), graphqlExpress({
schema: TestSchema,
formatError(error) {
return {
Expand Down Expand Up @@ -368,7 +368,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress({ schema: TestSchema }));
app.use(urlString(), graphqlExpress({ schema: TestSchema }));

const response = await request(app)
.get(urlString({ query: '{test}' }));
Expand All @@ -395,7 +395,7 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
const app = express();

app.use(urlString(), bodyParser.json());
app.use(urlString(), apolloExpress({
app.use(urlString(), graphqlExpress({
schema: TestSchema,
validationRules: [ AlwaysInvalidRule ],
}));
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-server-express/src/connectApollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as connect from 'connect';
import * as bodyParser from 'body-parser';
import { apolloConnect, graphiqlConnect } from './connectApollo';
import { graphqlConnect, graphiqlConnect } from './connectApollo';
import 'mocha';

import testSuite, { Schema, CreateAppOptions } from 'graphql-server-integration-testsuite';
Expand All @@ -15,7 +15,7 @@ function createConnectApp(options: CreateAppOptions = {}) {
if (options.graphiqlOptions ) {
app.use('/graphiql', graphiqlConnect( options.graphiqlOptions ));
}
app.use('/graphql', apolloConnect( options.apolloOptions ));
app.use('/graphql', graphqlConnect( options.apolloOptions ));
return app;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-server-express/src/connectApollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { apolloExpress, graphiqlExpress } from './expressApollo';
import { graphqlExpress, graphiqlExpress } from './expressApollo';

export const apolloConnect = apolloExpress;
export const graphqlConnect = graphqlExpress;
export const graphiqlConnect = graphiqlExpress;
8 changes: 4 additions & 4 deletions packages/graphql-server-express/src/expressApollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as express from 'express';
import * as bodyParser from 'body-parser';
import { apolloExpress, graphiqlExpress } from './expressApollo';
import { graphqlExpress, graphiqlExpress } from './expressApollo';
import testSuite, { Schema, CreateAppOptions } from 'graphql-server-integration-testsuite';
import { expect } from 'chai';
import { ApolloOptions } from 'graphql-server-core';
Expand All @@ -16,17 +16,17 @@ function createApp(options: CreateAppOptions = {}) {
if (options.graphiqlOptions ) {
app.use('/graphiql', graphiqlExpress( options.graphiqlOptions ));
}
app.use('/graphql', apolloExpress( options.apolloOptions ));
app.use('/graphql', graphqlExpress( options.apolloOptions ));
return app;
}

describe('expressApollo', () => {
it('throws error if called without schema', function(){
expect(() => apolloExpress(undefined as ApolloOptions)).to.throw('Apollo Server requires options.');
expect(() => graphqlExpress(undefined as ApolloOptions)).to.throw('Apollo Server requires options.');
});

it('throws an error if called with more than one argument', function(){
expect(() => (<any>apolloExpress)({}, 'x')).to.throw(
expect(() => (<any>graphqlExpress)({}, 'x')).to.throw(
'Apollo Server expects exactly one argument, got 2');
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-server-express/src/expressApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ExpressHandler {
(req: express.Request, res: express.Response, next): void;
}

export function apolloExpress(options: ApolloOptions | ExpressApolloOptionsFunction): ExpressHandler {
export function graphqlExpress(options: ApolloOptions | ExpressApolloOptionsFunction): ExpressHandler {
if (!options) {
throw new Error('Apollo Server requires options.');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-server-express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export {
ExpressApolloOptionsFunction,
ExpressHandler,
apolloExpress,
graphqlExpress,
graphiqlExpress,
} from './expressApollo';

export {
apolloConnect,
graphqlConnect,
graphiqlConnect,
} from './connectApollo';
4 changes: 2 additions & 2 deletions packages/graphql-server-hapi/src/hapiApollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as hapi from 'hapi';
import { apolloHapi, graphiqlHapi, HapiPluginOptions } from './hapiApollo';
import { graphqlHapi, graphiqlHapi, HapiPluginOptions } from './hapiApollo';
import 'mocha';

import testSuite, { Schema } from 'graphql-server-integration-testsuite';
Expand All @@ -13,7 +13,7 @@ function createApp(createOptions: HapiPluginOptions) {
});

server.register({
register: apolloHapi,
register: graphqlHapi,
options: {
apolloOptions: createOptions ? createOptions.apolloOptions : { schema: Schema },
path: '/graphql',
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-server-hapi/src/hapiApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface HapiPluginOptions {
apolloOptions: ApolloOptions | HapiOptionsFunction;
}

const apolloHapi: IRegister = function(server: Server, options: HapiPluginOptions, next) {
const graphqlHapi: IRegister = function(server: Server, options: HapiPluginOptions, next) {
server.method('verifyPayload', verifyPayload);
server.method('getGraphQLParams', getGraphQLParams);
server.method('getApolloOptions', getApolloOptions);
Expand Down Expand Up @@ -66,7 +66,7 @@ const apolloHapi: IRegister = function(server: Server, options: HapiPluginOption
return next();
};

apolloHapi.attributes = {
graphqlHapi.attributes = {
name: 'graphql',
version: '0.0.1',
};
Expand Down Expand Up @@ -231,4 +231,4 @@ function renderGraphiQL(route, graphiqlParams: any, reply) {
reply(graphiQLString);
}

export { apolloHapi, graphiqlHapi };
export { graphqlHapi, graphiqlHapi };
2 changes: 1 addition & 1 deletion packages/graphql-server-hapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export { IRegister,
HapiOptionsFunction,
HapiPluginOptions,
GraphiQLPluginOptions,
apolloHapi, graphiqlHapi } from './hapiApollo';
graphqlHapi, graphiqlHapi } from './hapiApollo';
2 changes: 1 addition & 1 deletion packages/graphql-server-koa/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { KoaApolloOptionsFunction, KoaHandler, apolloKoa, graphiqlKoa } from './koaApollo';
export { KoaGraphQLOptionsFunction, KoaHandler, graphqlKoa, graphiqlKoa } from './koaApollo';
8 changes: 4 additions & 4 deletions packages/graphql-server-koa/src/koaApollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as koa from 'koa';
import * as koaRouter from 'koa-router';
import * as koaBody from 'koa-bodyparser';
import { apolloKoa, graphiqlKoa } from './koaApollo';
import { graphqlKoa, graphiqlKoa } from './koaApollo';
import { ApolloOptions } from 'graphql-server-core';
import { expect } from 'chai';
import * as http from 'http';
Expand All @@ -20,7 +20,7 @@ function createApp(options: CreateAppOptions = {}) {
if (options.graphiqlOptions ) {
router.get('/graphiql', graphiqlKoa( options.graphiqlOptions ));
}
router.post('/graphql', apolloKoa( options.apolloOptions ));
router.post('/graphql', graphqlKoa( options.apolloOptions ));
app.use(router.routes());
app.use(router.allowedMethods());
return http.createServer(app.callback());
Expand All @@ -32,11 +32,11 @@ function destroyApp(app) {

describe('koaApollo', () => {
it('throws error if called without schema', function(){
expect(() => apolloKoa(undefined as ApolloOptions)).to.throw('Apollo Server requires options.');
expect(() => graphqlKoa(undefined as ApolloOptions)).to.throw('Apollo Server requires options.');
});

it('throws an error if called with more than one argument', function(){
expect(() => (<any>apolloKoa)({}, 'x')).to.throw(
expect(() => (<any>graphqlKoa)({}, 'x')).to.throw(
'Apollo Server expects exactly one argument, got 2');
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-server-koa/src/koaApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import * as graphql from 'graphql';
import { ApolloOptions, runQuery } from 'graphql-server-core';
import * as GraphiQL from 'graphql-server-module-graphiql';

export interface KoaApolloOptionsFunction {
export interface KoaGraphQLOptionsFunction {
(ctx: koa.Context): ApolloOptions | Promise<ApolloOptions>;
}

export interface KoaHandler {
(req: any, next): void;
}

export function apolloKoa(options: ApolloOptions | KoaApolloOptionsFunction): KoaHandler {
export function graphqlKoa(options: ApolloOptions | KoaGraphQLOptionsFunction): KoaHandler {
if (!options) {
throw new Error('Apollo Server requires options.');
}
Expand Down Expand Up @@ -109,7 +109,7 @@ export function apolloKoa(options: ApolloOptions | KoaApolloOptionsFunction): Ko
};
}

function isOptionsFunction(arg: ApolloOptions | KoaApolloOptionsFunction): arg is KoaApolloOptionsFunction {
function isOptionsFunction(arg: ApolloOptions | KoaGraphQLOptionsFunction): arg is KoaGraphQLOptionsFunction {
return typeof arg === 'function';
}

Expand Down

0 comments on commit 4a5e6b3

Please sign in to comment.