Skip to content

Commit

Permalink
feat(schema): expose graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jul 28, 2015
1 parent bae7e01 commit 65d1893
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
58 changes: 26 additions & 32 deletions example/app.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
import co from 'co';
import mongoose from 'mongoose';
import {graphql} from 'graphql';
import {getSchema} from '../src';
import {getSchema, graphql} from '../src';

import User from './user';

var schema = getSchema([User]);

mongoose.connect('mongodb://localhost/graphql');

function *run() {
var query = `{
user(_id: "559645cd1a38532d14349246") {
var query = `{
user(_id: "559645cd1a38532d14349246") {
name
age
createdAt
nums
bools
strings
removed
friends {
name
age
createdAt
nums
bools
strings
removed
friends {
name
age
}
}
}`;
}
}`;

// query = `{
// users(age: 19) {
// name
// age
// createdAt
// removed
// friends {
// name
// age
// }
// }
// }`;
// query = `{
// users(age: 19) {
// name
// age
// createdAt
// removed
// friends {
// name
// age
// }
// }
// }`;

return yield graphql(schema, query);
}

co(run)
graphql(schema, query)
.then((res) => console.log(JSON.stringify(res, false, 2)))
.catch((err) => console.error(err));
5 changes: 0 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"co": "^4.6.0",
"mongoose": "^4.0.6",
"graphql": "^0.1.0"
}
}
5 changes: 4 additions & 1 deletion src/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {map, reduce, each, isDate, isArray} from 'lodash';
import ObjectID from 'bson-objectid';

import {graphql} from 'graphql';

import {
GraphQLObjectType,
GraphQLNonNull,
Expand Down Expand Up @@ -248,4 +250,5 @@ function getSchema (models) {
});
}

export var getSchema;
module.exports.getSchema = getSchema;
module.exports.graphql = graphql;

0 comments on commit 65d1893

Please sign in to comment.