Skip to content

Commit

Permalink
Merge 8df3383 into 36ae6d4
Browse files Browse the repository at this point in the history
  • Loading branch information
DxCx committed Oct 18, 2016
2 parents 36ae6d4 + 8df3383 commit 0f3d6d0
Show file tree
Hide file tree
Showing 54 changed files with 635 additions and 170 deletions.
4 changes: 0 additions & 4 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ node_js:
- "6"
- "4"
install:
- npm install -g npm@3
- npm install -g coveralls
- npm install
- npm run typings

script:
- npm test
Expand Down
69 changes: 36 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
# GraphQL Server for Express, Connect, Hapi and Koa

[![npm version](https://badge.fury.io/js/apollo-server.svg)](https://badge.fury.io/js/apollo-server)
[![Build Status](https://travis-ci.org/apollostack/apollo-server.svg?branch=master)](https://travis-ci.org/apollostack/apollo-server)
[![Coverage Status](https://coveralls.io/repos/github/apollostack/apollo-server/badge.svg?branch=master)](https://coveralls.io/github/apollostack/apollo-server?branch=master)
[![npm version](https://badge.fury.io/js/graphql-server.svg)](https://badge.fury.io/js/graphql-server)
[![Build Status](https://travis-ci.org/apollostack/graphql-server.svg?branch=master)](https://travis-ci.org/apollostack/graphql-server)
[![Coverage Status](https://coveralls.io/repos/github/apollostack/graphql-server/badge.svg?branch=master)](https://coveralls.io/github/apollostack/graphql-server?branch=master)
[![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](http://www.apollostack.com/#slack)

Apollo Server is a community-maintained open-source GraphQL server. It works with all Node.js HTTP server frameworks: Express, Connect, Hapi and Koa.
GraphQL Server is a community-maintained open-source GraphQL server. It works with all Node.js HTTP server frameworks: Express, Connect, Hapi and Koa.

## Principles

Apollo Server is built with the following principles in mind:
GraphQL Server is built with the following principles in mind:

* **By the community, for the community**: Apollo Server's development is driven by the needs of developers
* **Simplicity**: by keeping things simple, Apollo Server is easier to use, easier to contribute to, and more secure
* **Performance**: Apollo Server is well-tested and production-ready - no modifications needed
* **By the community, for the community**: GraphQL Server's development is driven by the needs of developers
* **Simplicity**: by keeping things simple, GraphQL Server is easier to use, easier to contribute to, and more secure
* **Performance**: GraphQL Server is well-tested and production-ready - no modifications needed


Anyone is welcome to contribute to Apollo Server, just read [CONTRIBUTING.md](./CONTRIBUTING.md), take a look at the [roadmap](./ROADMAP.md) and make your first PR!
Anyone is welcome to contribute to GraphQL Server, just read [CONTRIBUTING.md](./CONTRIBUTING.md), take a look at the [roadmap](./ROADMAP.md) and make your first PR!


## Getting started

Apollo Server is super-easy to set up. Just npm-install apollo-server, write a GraphQL schema, and then use one of the following snippets to get started. For more info, read the [Apollo Server docs](http://dev.apollodata.com/tools/apollo-server/index.html).
GraphQL Server is super-easy to set up. Just npm-install graphql-server-<variant>, write a GraphQL schema, and then use one of the following snippets to get started. For more info, read the [GraphQL Server docs](http://dev.apollodata.com/tools/graphql-server/index.html).

### Installation

Just run `npm install --save apollo-server` and you're good to go!
Just run `npm install --save graphql-server-<variant>` and you're good to go!

where variant is one of the following:
- express
- koa
- hapi

### Express

```js
import express from 'express';
import { apolloExpress } from 'apollo-server';
import { apolloExpress } from 'graphql-server-express';

const myGraphQLSchema = // ... define or import your schema here!
const PORT = 3000;
Expand All @@ -47,7 +52,7 @@ app.listen(PORT);
```js
import connect from 'connect';
import bodyParser from 'body-parser';
import { apolloConnect } from 'apollo-server';
import { apolloConnect } from 'graphql-server-express';
import http from 'http';

const PORT = 3000;
Expand All @@ -66,7 +71,7 @@ Now with the Hapi plugins `apolloHapi` and `graphiqlHapi` you can pass a route o

```js
import hapi from 'hapi';
import { apolloHapi } from 'apollo-server';
import { apolloHapi } from 'graphql-server-hapi';

const server = new hapi.Server();

Expand Down Expand Up @@ -103,7 +108,7 @@ server.start((err) => {
```js
import koa from 'koa';
import koaRouter from 'koa-router';
import { apolloKoa } from 'apollo-server';
import { apolloKoa } from 'graphql-server-koa';

const app = new koa();
const router = new koaRouter();
Expand All @@ -119,7 +124,7 @@ app.listen(PORT);

## Options

Apollo Server can be configured with an options object with the the following fields:
GraphQL Server can be configured with an options object with the the following fields:

* **schema**: the GraphQLSchema to be used
* **context**: the context value passed to resolvers during GraphQL execution
Expand Down Expand Up @@ -149,41 +154,39 @@ apolloOptions = {

## Differences to express-graphql

Apollo Server and express-graphql are more or less the same thing (GraphQL middleware for Node.js), but there are a few key differences:
GraphQL Server and express-graphql are more or less the same thing (GraphQL middleware for Node.js), but there are a few key differences:

* express-graphql works with Express and Connect, Apollo Server supports Express, Connect, Hapi and Koa.
* express-graphql's main goal is to be a minimal reference implementation, whereas Apollo Server's goal is to be a complete production-ready GraphQL server.
* Compared to express-graphql, Apollo Server has a simpler interface and supports exactly one way of passing queries.
* Apollo Server separates serving GraphiQL (GraphQL UI) from responding to GraphQL requests.
* express-graphql contains code for parsing HTTP request bodies, Apollo Server leaves that to standard packages like body-parser.
* express-graphql works with Express and Connect, GraphQL Server supports Express, Connect, Hapi and Koa.
* express-graphql's main goal is to be a minimal reference implementation, whereas GraphQL Server's goal is to be a complete production-ready GraphQL server.
* Compared to express-graphql, GraphQL Server has a simpler interface and supports exactly one way of passing queries.
* GraphQL Server separates serving GraphiQL (GraphQL UI) from responding to GraphQL requests.
* express-graphql contains code for parsing HTTP request bodies, GraphQL Server leaves that to standard packages like body-parser.
* Includes an `OperationStore` to easily manage whitelisting
* Built with TypeScript

Despite express-graphql being a reference implementation, Apollo Server is actually easier to understand and more modular than express-graphql.
Despite express-graphql being a reference implementation, GraphQL Server is actually easier to understand and more modular than express-graphql.

That said, Apollo Server is heavily inspired by express-graphql (it's the reference implementation after all). Rather than seeing the two as competing alternatives, we think that they both have separate roles in the GraphQL ecosystem: express-graphql is a reference implementation, and Apollo Server is a GraphQL server to be used in production and evolve quickly with the needs of the community. Over time, express-graphql can adopt those features of Apollo Server that have proven their worth and become established more widely.
That said, GraphQL Server is heavily inspired by express-graphql (it's the reference implementation after all). Rather than seeing the two as competing alternatives, we think that they both have separate roles in the GraphQL ecosystem: express-graphql is a reference implementation, and GraphQL Server is a GraphQL server to be used in production and evolve quickly with the needs of the community. Over time, express-graphql can adopt those features of GraphQL Server that have proven their worth and become established more widely.

## Apollo Server Development
## GraphQL Server Development

If you want to develop apollo server locally you must follow the following instructions:

* Fork this repository

* Install the Apollo Server project in your computer
* Install the GraphQL Server project in your computer

```
git clone https://github.com/[your-user]/apollo-server
cd apollo-server
npm install -g typescript live-server
git clone https://github.com/[your-user]/graphql-server
cd graphql-server
npm install
npm run typings
npm run compile
cd packages/graphql-server-<variant>/
npm link
```

* Install your local Apollo Server in other App
* Install your local GraphQL Server in other App

```
cd ~/myApp
npm link apollo-server
npm link graphql-server-<variant>
```
6 changes: 3 additions & 3 deletions integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An Express Middleware for the Apollo Server
import * as graphql from "graphql";
import * as express from "express";
import * as bodyParser from "body-parser";
import { graphqlHTTP, renderGraphiQL } from "apollo-server";
import { apolloExpress, graphiqlExpress } from "graphql-server-express";

const port = 3000;
const endpointURL = "/graphql";
Expand All @@ -24,8 +24,8 @@ const schema = new graphql.GraphQLSchema({
});

app.use(bodyParser.json());
app.get("/", renderGraphiQL({endpointURL}));
app.post(endpointURL, graphqlHTTP({schema}));
app.get("/", graphiqlExpress({endpointURL}));
app.post(endpointURL, apolloExpress({schema}));

app.listen(port, () => {
console.log(`Server is listen on ${port}`);
Expand Down
16 changes: 16 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"lerna": "2.0.0-beta.30",
"version": "0.3.2",
"changelog": {
"repo": "apollostack/graphql-server",
"labels": {
"tag: spec compliancy": ":eyeglasses: Spec Compliancy",
"tag: breaking change": ":boom: Breaking Change",
"tag: new feature": ":rocket: New Feature",
"tag: bug fix": ":bug: Bug Fix",
"tag: polish": ":nail_care: Polish",
"tag: documentation": "Documentation",
"tag: internal": ":house: Internal"
}
}
}
89 changes: 16 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,98 +1,41 @@
{
"name": "apollo-server",
"version": "0.3.2",
"description": "Production-ready Node.js GraphQL server for Express, Hapi, Koa",
"main": "dist/index.js",
"directories": {
"test": "test"
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/apollostack/graphql-server.git"
},
"scripts": {
"compile": "tsc",
"typings": "typings install",
"compile": "lerna exec -- npm run compile",
"lint": "tslint ./packages/**/src/**/*.ts",
"prebootstrap": "npm install",
"postinstall": "lerna bootstrap",
"pretest": "npm run compile",
"test": "npm run testonly --",
"posttest": "npm run lint",
"lint": "tslint ./src/**/*.ts",
"watch": "tsc -w",
"testonly": "mocha --compilers js:babel-core/register --reporter spec --full-trace ./dist/test/tests.js",
"coverage": "babel-node ./node_modules/istanbul/lib/cli.js cover _mocha -- --full-trace ./dist/test/tests.js",
"testonly": "mocha --compilers js:babel-core/register --reporter spec --full-trace ./test/tests.js",
"coverage": "istanbul cover -x \"*.test.js\" _mocha -- --compilers js:babel-core/register --full-trace --reporter dot ./test/tests.js",
"postcoverage": "remap-istanbul --input coverage/coverage.raw.json --type lcovonly --output coverage/lcov.info"
},
"repository": {
"type": "git",
"url": "git+https://github.com/apollostack/apollo-server.git"
},
"keywords": [
"GraphQL",
"Apollo",
"Hapi",
"Koa",
"Express",
"Javascript"
],
"author": "Jonas Helfer <jonas@helfer.email>",
"license": "MIT",
"bugs": {
"url": "https://github.com/apollostack/apollo-proxy/issues"
},
"homepage": "https://github.com/apollostack/apollo-proxy#readme",
"dependencies": {
"@types/body-parser": "0.0.33",
"@types/boom": "0.0.32",
"@types/chai": "^3.4.34",
"@types/connect": "^3.4.30",
"@types/cookies": "^0.5.30",
"@types/express": "^4.0.33",
"@types/express-serve-static-core": "^4.0.36",
"@types/fibers": "0.0.29",
"@types/hapi": "^13.0.35",
"@types/http-errors": "^1.3.29",
"@types/koa": "^2.0.33",
"@types/koa-bodyparser": "^3.0.19",
"@types/koa-router": "^7.0.21",
"@types/mime": "0.0.29",
"@types/multer": "0.0.32",
"@types/node": "^6.0.41",
"@types/serve-static": "^1.7.31",
"boom": "^4.0.0",
"http-errors": "^1.5.0",
"source-map-support": "^0.4.2",
"typed-graphql": "^1.0.2"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.42",
"@types/sinon": "^1.16.31",
"babel-cli": "^6.11.4",
"babel-core": "^6.11.4",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"body-parser": "^1.15.2",
"chai": "^3.5.0",
"connect": "^3.4.1",
"express": "^4.14.0",
"fibers": "^1.0.15",
"graphql": "^0.7.0",
"hapi": "^15.0.3",
"istanbul": "1.0.0-alpha.2",
"koa": "^2.0.0-alpha.4",
"koa-bodyparser": "^3.0.0",
"koa-router": "^7.0.1",
"meteor-promise": "^0.7.3",
"lerna": "git://github.com/DxCx/lerna.git#bootstrap-dev-bin-pkg",
"mocha": "^3.1.1",
"multer": "^1.1.0",
"remap-istanbul": "^0.7.0",
"sinon": "^1.17.5",
"sinon": "^1.17.6",
"supertest": "^2.0.0",
"supertest-as-promised": "^4.0.0",
"tslint": "^3.13.0",
"typescript": "^2.0.3",
"typings": "^1.3.2"
},
"peerDependencies": {
"graphql": "^0.6.1 || ^0.7.0"
},
"typings": "dist/index.d.ts",
"typescript": {
"definition": "dist/index.d.ts"
"typescript": "^2.0.3"
}
}
5 changes: 5 additions & 0 deletions packages/graphql-server-core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!dist
!dist/**/*
dist/**/*.test.*
!package.json
43 changes: 43 additions & 0 deletions packages/graphql-server-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "graphql-server-core",
"version": "0.3.2",
"description": "Core engine ffor Apollo GraphQL server",
"main": "dist/index.js",
"scripts": {
"compile": "tsc",
"prepublish": "npm run compile"
},
"repository": {
"type": "git",
"url": "https://github.com/apollostack/graphql-server/tree/master/packages/graphql-server-core"
},
"keywords": [
"GraphQL",
"Apollo",
"Server",
"Javascript"
],
"author": "Jonas Helfer <jonas@helfer.email>",
"license": "MIT",
"bugs": {
"url": "https://github.com/apollostack/graphql-server/issues"
},
"homepage": "https://github.com/apollostack/graphql-server#readme",
"dependencies": {},
"devDependencies": {
"@types/fibers": "0.0.29",
"typed-graphql": "^1.0.2",
"fibers": "^1.0.15",
"meteor-promise": "^0.7.3"
},
"peerDependencies": {
"graphql": "^0.6.1 || ^0.7.0"
},
"optionalDependencies": {
"typed-graphql": "^1.0.2"
},
"typings": "dist/index.d.ts",
"typescript": {
"definition": "dist/index.d.ts"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLSchema, ValidationRule } from 'graphql';
import { LogFunction } from '../core/runQuery';
import { LogFunction } from './runQuery';

/*
* ExpressApolloOptions
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-server-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { runQuery, LogFunction, LogMessage, LogStep, LogAction } from './runQuery'
export { default as ApolloOptions} from './apolloOptions'
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { stub } from 'sinon';
import 'mocha';

import {
GraphQLSchema,
Expand Down
File renamed without changes.

0 comments on commit 0f3d6d0

Please sign in to comment.