Skip to content

Commit

Permalink
chore(package): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Andras Toth committed Dec 11, 2015
1 parent 33790ee commit 8aa2856
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 60 deletions.
3 changes: 2 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require('babel/register');
require('babel-register');
require('babel-polyfill');
require('./express');
require('./hapi');
require('./koa');
3 changes: 1 addition & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
},
"dependencies": {
"@risingstack/graffiti": "../",
"@risingstack/graffiti-mongoose": "^4.0.1",
"babel": "^5.8.21",
"@risingstack/graffiti-mongoose": "^4.3.2",
"express": "^4.13.3",
"koa": "^1.1.0",
"koa-static": "^1.5.1",
Expand Down
36 changes: 23 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Mongoose adapter for graffiti (Node.js GraphQL ORM)",
"main": "lib/index.js",
"scripts": {
"test": "NODE_ENV=test mocha --compilers js:babel/register --require co-mocha 'src/**/*.spec.js'",
"test": "NODE_ENV=test mocha --compilers js:babel-register --require babel-polyfill 'src/**/*.spec.js'",
"eslint": "eslint src",
"prepublish": "npm test && npm run build",
"build": "rm -rf lib/* && babel src --ignore *.spec.js --out-dir lib"
Expand Down Expand Up @@ -32,27 +32,37 @@
"co-body": "^4.0.0"
},
"peerDependencies": {
"graphql": "^0.4.12"
"graphql": "^0.4.14"
},
"devDependencies": {
"babel": "^5.8.29",
"babel-eslint": "^4.1.3",
"chai": "^3.4.0",
"chai-subset": "^1.1.0",
"co-mocha": "^1.1.2",
"eslint": "1.8.0",
"eslint-config-airbnb": "^0.1.0",
"babel": "^6.3.13",
"babel-cli": "^6.3.17",
"babel-eslint": "^5.0.0-beta6",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.3.13",
"chai": "^3.4.1",
"chai-subset": "^1.2.0",
"eslint": "1.10.3",
"eslint-config-airbnb": "^2.0.0",
"express": "^4.13.3",
"graphql": "^0.4.12",
"hapi": "^11.0.3",
"graphql": "^0.4.14",
"hapi": "^11.1.2",
"koa": "^2.0.0-alpha.2",
"mocha": "^2.3.3",
"mocha": "^2.3.4",
"pre-commit": "^1.1.2",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0"
},
"pre-commit": [
"eslint",
"test"
]
],
"babel": {
"presets": [
"stage-0",
"es2015"
]
}
}
12 changes: 6 additions & 6 deletions src/express/express.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {graphql} from 'graphql';
import {json} from 'co-body';
import { graphql } from 'graphql';
import { json } from 'co-body';
import {
badRequest,
methodNotAllowed
Expand All @@ -13,18 +13,18 @@ import {
} from '../util';

function sendError(response, boom) {
const {statusCode, payload} = boom.output;
const { statusCode, payload } = boom.output;
response.status(statusCode).send(payload);
}

export default function middleware({graphiql = true, schema = required()} = {}) {
export default function middleware({ graphiql = true, schema = required() } = {}) {
return (request, response, next) => {
if (isPath(request) && (isPost(request) || isGet(request))) {
return json(request).then((body) => {
const {query, variables} = Object.assign({}, body, request.query);
const { query, variables } = Object.assign({}, body, request.query);

if (isGet(request) && request.accepts('html') && graphiql) {
return response.send(renderGraphiQL({query, variables}));
return response.send(renderGraphiQL({ query, variables }));
}

if (isGet(request) && query && query.includes('mutation')) {
Expand Down
16 changes: 8 additions & 8 deletions src/express/express.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect} from 'chai';
import { expect } from 'chai';
import parser from 'co-body';
import express from './';

Expand Down Expand Up @@ -54,7 +54,7 @@ describe('graffiti express', () => {
});

it('should return with proper result on GET', function postTest(done) {
const result = {data: 1};
const result = { data: 1 };
const mw = mwFactory({
schema: this.schema
});
Expand All @@ -70,7 +70,7 @@ describe('graffiti express', () => {
};

const response = {
json: ({data}) => {
json: ({ data }) => {
expect(data).to.be.eql(result);
done();
}
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('graffiti express', () => {

const response = {
status: () => response,
send: ({statusCode}) => {
send: ({ statusCode }) => {
expect(statusCode).to.be.eql(405);
done();
}
Expand All @@ -109,7 +109,7 @@ describe('graffiti express', () => {
});

it('should return with proper result on POST', function postTest(done) {
const result = {data: 1};
const result = { data: 1 };
const mw = mwFactory({
schema: this.schema
});
Expand All @@ -125,7 +125,7 @@ describe('graffiti express', () => {
};

const response = {
json: ({data}) => {
json: ({ data }) => {
expect(data).to.be.eql(result);
done();
}
Expand Down Expand Up @@ -171,9 +171,9 @@ describe('graffiti express', () => {
accepts: (type) => type === 'html'
};

const result = {data: 1};
const result = { data: 1 };
const response = {
json: ({data}) => {
json: ({ data }) => {
expect(data).to.be.eql(result);
done();
}
Expand Down
2 changes: 1 addition & 1 deletion src/express/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default} from './express';
export { default } from './express';
12 changes: 6 additions & 6 deletions src/hapi/hapi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {graphql} from 'graphql';
import { graphql } from 'graphql';
import {
badRequest,
methodNotAllowed
Expand All @@ -11,18 +11,18 @@ import {

import pkg from '../../package.json';

function accepts({headers}, type) {
function accepts({ headers }, type) {
return headers.accept && headers.accept.includes(type);
}

const plugin = {
register: (server, {graphiql = true, schema = required()} = {}, next) => {
register: (server, { graphiql = true, schema = required() } = {}, next) => {
const handler = (request, reply) => {
const data = request.payload || request.query || {};
const {query, variables} = data;
const { query, variables } = data;

if (accepts(request, 'html') && graphiql) {
return reply(renderGraphiQL({query, variables}));
return reply(renderGraphiQL({ query, variables }));
}

if (query && query.includes('mutation') && isGet(request)) {
Expand Down Expand Up @@ -61,6 +61,6 @@ const plugin = {
}
};

plugin.register.attributes = {pkg};
plugin.register.attributes = { pkg };

export default plugin;
18 changes: 9 additions & 9 deletions src/hapi/hapi.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from 'chai';
import {Server} from 'hapi';
import { expect } from 'chai';
import { Server } from 'hapi';
import hapi from './';

describe('graffiti hapi', () => {
Expand All @@ -18,7 +18,7 @@ describe('graffiti hapi', () => {
const server = new Server();
server.connection({ port: 3000 });

const result = {data: 1};
const result = { data: 1 };

server.register({
register: hapi,
Expand All @@ -33,7 +33,7 @@ describe('graffiti hapi', () => {
server.inject({
method: 'GET',
url: '/graphql?query={data}'
}, ({payload}) => {
}, ({ payload }) => {
expect(JSON.parse(payload).data).to.eql(result);
done();
});
Expand All @@ -57,7 +57,7 @@ describe('graffiti hapi', () => {
server.inject({
method: 'GET',
url: '/graphql?query=mutation%20mutate%20{updateData(data:"123"){data}}'
}, ({payload}) => {
}, ({ payload }) => {
expect(JSON.parse(payload).error).to.be.ok; // eslint-disable-line
done();
});
Expand All @@ -68,7 +68,7 @@ describe('graffiti hapi', () => {
const server = new Server();
server.connection({ port: 3000 });

const result = {data: 1};
const result = { data: 1 };

server.register({
register: hapi,
Expand All @@ -87,7 +87,7 @@ describe('graffiti hapi', () => {
query: '{data}',
variables: {}
}
}, ({payload}) => {
}, ({ payload }) => {
expect(JSON.parse(payload).data).to.eql(result);
done();
});
Expand All @@ -114,7 +114,7 @@ describe('graffiti hapi', () => {
headers: {
Accept: 'text/html'
}
}, ({payload}) => {
}, ({ payload }) => {
expect(payload.includes('GraphiQL')).to.be.ok; // eslint-disable-line
done();
});
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('graffiti hapi', () => {
headers: {
Accept: 'text/html'
}
}, ({statusCode}) => {
}, ({ statusCode }) => {
expect(statusCode).to.be.eql(404);
done();
});
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default} from './hapi';
export { default } from './hapi';
2 changes: 1 addition & 1 deletion src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect} from 'chai';
import { expect } from 'chai';
import graffiti from './';

describe('graffiti', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/koa/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default} from './koa';
export { default } from './koa';
10 changes: 5 additions & 5 deletions src/koa/koa.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {graphql} from 'graphql';
import {json} from 'co-body';
import { graphql } from 'graphql';
import { json } from 'co-body';
import {
required,
isPath,
Expand All @@ -12,14 +12,14 @@ function accepts(type) {
return this.headers && this.headers.accept && this.headers.accept.includes(type);
}

export default function middleware({graphiql = true, schema = required()} = {}) {
export default function middleware({ graphiql = true, schema = required() } = {}) {
return function *middleware(next) {
if (isPath(this) && (isPost(this) || isGet(this))) {
const body = yield json(this);
const {query, variables} = Object.assign({}, body, this.query);
const { query, variables } = Object.assign({}, body, this.query);

if (isGet(this) && accepts.call(this, 'html') && graphiql) {
this.body = renderGraphiQL({query, variables});
this.body = renderGraphiQL({ query, variables });
return this.body;
}

Expand Down
8 changes: 4 additions & 4 deletions src/koa/koa.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect} from 'chai';
import { expect } from 'chai';
import parser from 'co-body';
import koa from './';

Expand Down Expand Up @@ -34,7 +34,7 @@ describe('graffiti koa', () => {
}
};

const result = {data: 1};
const result = { data: 1 };
const res = yield mw.call(request);

expect(res.data).to.eql(result);
Expand All @@ -56,7 +56,7 @@ describe('graffiti koa', () => {
}
};

const result = {data: 1};
const result = { data: 1 };
const res = yield mw.call(request);

expect(res.data).to.eql(result);
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('graffiti koa', () => {
}
};

const result = {data: 1};
const result = { data: 1 };
const res = yield mw.call(request);
expect(res.data).to.eql(result);
});
Expand Down
2 changes: 1 addition & 1 deletion src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GRAPHIQL_VERSION = '0.3.1';

// TODO default query
// const defaultQuery = ``;
export function renderGraphiQL({query, variables, version = GRAPHIQL_VERSION} = {}) {
export function renderGraphiQL({ query, variables, version = GRAPHIQL_VERSION } = {}) {
return `
<!DOCTYPE html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion src/util/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect} from 'chai';
import { expect } from 'chai';
import {
isPost
} from './';
Expand Down

0 comments on commit 8aa2856

Please sign in to comment.