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 Jan 27, 2016
1 parent 5c5dd0e commit 22cebcb
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 64 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
],
"dependencies": {
"graphql-relay": "^0.3.6",
"lodash": "^4.0.0"
"lodash": "^4.0.1"
},
"peerDependencies": {
"graphql": "^0.4.14",
"babel-polyfill": "^6.3.14"
},
"devDependencies": {
"babel": "^6.3.26",
"babel-cli": "^6.4.0",
"babel-cli": "^6.4.5",
"babel-eslint": "^5.0.0-beta6",
"babel-istanbul": "^0.6.0",
"babel-polyfill": "^6.3.14",
Expand All @@ -47,12 +47,12 @@
"chai": "^3.4.1",
"chai-subset": "^1.2.0",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^3.1.0",
"eslint-config-airbnb": "^4.0.0",
"graphql": "^0.4.14",
"mocha": "^2.3.4",
"mongoose": "^4.3.6",
"mocha": "^2.4.2",
"mongoose": "^4.3.7",
"pre-commit": "^1.1.2",
"sinon": "^1.17.2",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0"
},
"pre-commit": [
Expand Down
2 changes: 1 addition & 1 deletion src/e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('e2e', () => {
let user2;
let schema;
let hooks;
before(function beforeAll() {
before(() => {
hooks = {
viewer: {
pre: spy(),
Expand Down
6 changes: 3 additions & 3 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ function extractPath(schemaPath) {
* @return {Object) extractedSchemaPaths
*/
function extractPaths(schemaPaths, model) {
return reduce(schemaPaths, (fields, schemaPath) => {
return merge(fields, extractPath(schemaPath, model));
}, {});
return reduce(schemaPaths, (fields, schemaPath) => (
merge(fields, extractPath(schemaPath, model))
), {});
}

/**
Expand Down
34 changes: 14 additions & 20 deletions src/query/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ function updateOne(Collection, {id, _id, ...args}, info) {
function deleteOne(Collection, args) {
const _id = processId(args);

return Collection.remove({_id}).then(({result}) => {
return {
id: toGlobalId(Collection.modelName, _id),
ok: !!result.ok
};
});
return Collection.remove({_id}).then(({result}) => ({
id: toGlobalId(Collection.modelName, _id),
ok: !!result.ok
}));
}

function getList(Collection, selector, options = {}, info = null) {
Expand All @@ -113,14 +111,12 @@ function getList(Collection, selector, options = {}, info = null) {
}

const projection = getFieldList(info);
return Collection.find(selector, projection, options).then((result) => {
return result.map((value) => {
return {
...value.toObject(),
_type: Collection.modelName
};
});
});
return Collection.find(selector, projection, options).then((result) => (
result.map((value) => ({
...value.toObject(),
_type: Collection.modelName
}))
));
}

function getOneResolver(graffitiModel) {
Expand Down Expand Up @@ -303,12 +299,10 @@ async function connectionFromModel(graffitiModel, args, info) {
return emptyConnection();
}

const edges = result.map((value) => {
return {
cursor: idToCursor(value._id),
node: value
};
});
const edges = result.map((value) => ({
cursor: idToCursor(value._id),
node: value
}));

const firstElement = await getFirst(Collection);
return {
Expand Down
14 changes: 5 additions & 9 deletions src/query/query.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ describe('query', () => {
model: {
modelName: type,
findById(id) {
const obj = objArray.find((obj) => {
return obj._id === id;
});
const obj = objArray.find((obj) => obj._id === id);
return Promise.resolve(obj);
},

Expand Down Expand Up @@ -126,12 +124,10 @@ describe('query', () => {
describe('connectionFromModel', () => {
it('should return a connection', async function connectionFromModelTest() {
const result = await connectionFromModel(graffitiModels.type, {});
const edges = resultArray.map((obj) => {
return {
cursor: _idToCursor(obj._id),
node: obj
};
});
const edges = resultArray.map((obj) => ({
cursor: _idToCursor(obj._id),
node: obj
}));
const startCursor = edges[0].cursor;
const endCursor = edges[edges.length - 1].cursor;
expect(result).to.containSubset({
Expand Down
12 changes: 6 additions & 6 deletions src/schema/schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('schema', () => {

describe('getQueryField', () => {
it('should return a singular and a plural query field', function getQueryFieldTest() {
this.sandbox.stub(query, 'getOneResolver').returns(() => {});
this.sandbox.stub(query, 'getListResolver').returns(() => {});
this.sandbox.stub(query, 'getOneResolver').returns(() => null);
this.sandbox.stub(query, 'getListResolver').returns(() => null);

const graphQLType = types.Qux;
const fields = getQueryField({Qux: {model: {}}}, graphQLType);
Expand Down Expand Up @@ -65,8 +65,8 @@ describe('schema', () => {

describe('getMutationField', () => {
it('should return an addXyz and an updateXyz field', function getMutationFieldTest() {
this.sandbox.stub(query, 'getAddOneMutateHandler').returns(() => {});
this.sandbox.stub(query, 'getUpdateOneMutateHandler').returns(() => {});
this.sandbox.stub(query, 'getAddOneMutateHandler').returns(() => null);
this.sandbox.stub(query, 'getUpdateOneMutateHandler').returns(() => null);
const graphQLType = types.Qux;
const fields = getMutationField({Qux: {model: {}}}, graphQLType);
const args = {
Expand Down Expand Up @@ -147,14 +147,14 @@ describe('schema', () => {
this.sandbox.stub(type, 'getTypes').returns(types);
});

it('should return a GraphQL schema', function getSchemaTest() {
it('should return a GraphQL schema', () => {
const schema = getSchema({});
expect(schema).instanceOf(GraphQLSchema);
expect(schema._queryType.name).to.be.equal('RootQuery');
expect(schema._mutationType.name).to.be.equal('RootMutation');
});

it('should return a GraphQL schema without mutations', function getSchemaTest() {
it('should return a GraphQL schema without mutations', () => {
const schema = getSchema({}, {mutation: false});
expect(schema).instanceOf(GraphQLSchema);
expect(schema._queryType.name).to.be.equal('RootQuery');
Expand Down
2 changes: 1 addition & 1 deletion src/type/custom/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default new GraphQLScalarType({
parseValue: coerceBuffer,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw new GraphQLError('Query error: Can only parse strings to buffers but got a: ' + ast.kind, [ast]);
throw new GraphQLError(`Query error: Can only parse strings to buffers but got a: ${ast.kind}`, [ast]);
}

const result = new Buffer(ast.value);
Expand Down
4 changes: 1 addition & 3 deletions src/type/custom/buffer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ describe('GraphQL buffer type', () => {
type: GraphQLBuffer
}
},
resolve: (_, {bar}) => {
return new Buffer(bar.toString() + '-qux');
}
resolve: (_, {bar}) => new Buffer(`${bar.toString()}-qux`)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/type/custom/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default new GraphQLScalarType({
},
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw new GraphQLError('Query error: Can only parse strings to dates but got a: ' + ast.kind, [ast]);
throw new GraphQLError(`Query error: Can only parse strings to buffers but got a: ${ast.kind}`, [ast]);
}

const result = new Date(ast.value);
Expand Down
4 changes: 1 addition & 3 deletions src/type/custom/date.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ describe('GraphQL date type', () => {
type: GraphQlDate
}
},
resolve: (_, {date}) => {
return new Date(date.getTime() + 24 * 3600 * 1000);
}
resolve: (_, {date}) => new Date(date.getTime() + 24 * 3600 * 1000)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/type/custom/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default new GraphQLScalarType({
parseValue: coerceDate,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw new GraphQLError('Query error: Can only parse strings to JSON but got a: ' + ast.kind, [ast]);
throw new GraphQLError(`Query error: Can only parse strings to buffers but got a: ${ast.kind}`, [ast]);
}

const json = ast.value.replace(/\'/g, '"');
Expand Down
4 changes: 1 addition & 3 deletions src/type/custom/generic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ describe('GraphQL generic type', () => {
type: GraphQLGeneric
}
},
resolve: (_, {bar}) => {
return new Unknown(bar.field + '-qux');
}
resolve: (_, {bar}) => new Unknown(`${bar.field}-qux`)
}
}
})
Expand Down
10 changes: 4 additions & 6 deletions src/type/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ function addType(name, type) {
}

// Node interface
const {nodeInterface} = nodeDefinitions(null, (obj) => {
const {nodeInterface} = nodeDefinitions(null, (obj) => (
// Type resolver
return obj._type ? types[obj._type] : null;
});
obj._type ? types[obj._type] : null
));

// GraphQL Viewer type
const GraphQLViewer = new GraphQLObjectType({
Expand Down Expand Up @@ -245,9 +245,7 @@ export default function getType(graffitiModels, {name, description, fields}, pat
}

if (!graphQLField.resolve) {
graphQLField.resolve = addHooks((source) => {
return source[name];
}, hooks);
graphQLField.resolve = addHooks((source) => source[name], hooks);
}

graphQLFields[name] = graphQLField;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export default class Middleware {
await fn.call(this, next, ...result);
return lastResult;
};
}, () => {})();
}, () => null)();
}
}

0 comments on commit 22cebcb

Please sign in to comment.