Skip to content

Commit

Permalink
refactor(objectid): remove bson-objectid from project
Browse files Browse the repository at this point in the history
  • Loading branch information
tothandras committed Sep 22, 2015
1 parent 5a2813d commit c4e7ad1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"ORM"
],
"dependencies": {
"bson-objectid": "^1.1.1",
"graphql": "0.2.2",
"lodash": "^3.10.0"
},
Expand All @@ -39,7 +38,7 @@
"co-mocha": "^1.1.2",
"eslint": "1.0.0",
"mocha": "^2.2.5",
"mongoose": "^4.0.6",
"mongoose": "^4.1.8",
"pre-commit": "^1.1.1",
"sinon": "^1.15.4",
"sinon-chai": "^2.8.0"
Expand Down
5 changes: 2 additions & 3 deletions src/field.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {isDate} from 'lodash';
import ObjectID from 'bson-objectid';

import {
GraphQLString,
Expand Down Expand Up @@ -52,10 +51,10 @@ function getField(field, types, models, model) {

graphQLfield.type = types[field.ref];
graphQLfield.resolve = (modelInstance, params, source, fieldASTs) => {
var projections = getProjection(fieldASTs);
var projections = getProjection(fieldASTs);

return models[field.ref].model.findOne({
_id: new ObjectID(modelInstance[field.name])
_id: modelInstance[field.name]
}, projections);
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/field.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {expect} from 'chai';
import ObjectID from 'bson-objectid';
import {
GraphQLString,
GraphQLFloat,
Expand Down Expand Up @@ -44,7 +43,7 @@ describe('field', () => {
});

expect(findOneStub).to.calledWith({
_id: new ObjectID(user._id.toString()),
_id: user._id.toString(),
}, {
name: 1
});
Expand Down
3 changes: 1 addition & 2 deletions src/query.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {reduce} from 'lodash';
import ObjectID from 'bson-objectid';

import {
GraphQLString,
Expand Down Expand Up @@ -74,7 +73,7 @@ function getRootFields (types, models) {

var filter = reduce(args, (args, arg, argName) => {
if (arg && argName === '_id') {
args[argName] = new ObjectID(arg);
args[argName] = arg;
} else if (arg) {
args[argName] = arg;
}
Expand Down
5 changes: 2 additions & 3 deletions src/schema.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {expect} from 'chai';
import {graphql} from 'graphql';
import ObjectID from 'bson-objectid';

import {getModels} from './model';
import {getSchema} from './schema';
Expand Down Expand Up @@ -35,7 +34,7 @@ describe('schema', () => {
}`);

expect(findByIdStub).to.calledWith({
_id: new ObjectID(user._id.toString())
_id: user._id.toString()
}, {
_id: 1
});
Expand Down Expand Up @@ -218,7 +217,7 @@ describe('schema', () => {
}`);

expect(findOneStub).to.calledWith({
_id: new ObjectID(user2._id.toString())
_id: user2._id.toString()
}, {
name: 1,
friends: 1
Expand Down

0 comments on commit c4e7ad1

Please sign in to comment.