Skip to content

Commit

Permalink
refactor(export): refactor export to support ES6 impots better
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jul 30, 2015
1 parent c37d5bf commit f3912d4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {graphql} from 'graphql';
import schema from './schema';
import type from './type';
import {getSchema} from './schema';
import {getTypes} from './type';

export default {
graphql,
getSchema: schema.get,
getTypes: type.get
getSchema,
getTypes
};

4 changes: 2 additions & 2 deletions src/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {expect} from 'chai';
import ObjectID from 'bson-objectid';
import {graphql} from 'graphql';

import {get} from './schema';
import {getSchema} from './schema';
import User from '../fixture/user';

describe('schema integration test', () => {
let schema = get([User]);
let schema = getSchema([User]);

describe('singular resource', () => {
it('should get data by id with selected fields', function* () {
Expand Down
17 changes: 8 additions & 9 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import {
GraphQLSchema
} from 'graphql/type';

import type from './type';
import query from './query';
import {getTypes} from './type';
import {getArgs, getRootFields} from './query';

/**
* @method get
* @method getSchema
* @param {Array} models - mongoose models
* @return {GraphQLSchema} schema
*/
function get (models) {
var types = type.get(models);
var queryArgs = query.getArgs(types, models);
var queryFields = query.getRootFields(types, models, queryArgs);
function getSchema (models) {
var types = getTypes(models);
var queryArgs = getArgs(types, models);
var queryFields = getRootFields(types, models, queryArgs);

// Create root schema
return new GraphQLSchema({
Expand All @@ -26,6 +26,5 @@ function get (models) {
}

export default {
get
getSchema
};

6 changes: 2 additions & 4 deletions src/schema.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {expect} from 'chai';
import ObjectID from 'bson-objectid';
import {graphql} from 'graphql';

import {get} from './schema';
import {getSchema} from './schema';
import User from '../fixture/user';

describe('schema', () => {
let schema = get([User]);
let schema = getSchema([User]);

it('should exist', () => {
expect(schema).to.be.not.undefined;
Expand Down
7 changes: 3 additions & 4 deletions src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
import field from './field';

/**
* @method get
* @method getTypes
* @param {Object} models
* @return {Object} types
*/
function get (models) {
function getTypes (models) {
var types = reduce(models, (types, model) => {
var modelName = model.modelName;

Expand Down Expand Up @@ -43,6 +43,5 @@ function get (models) {
}

export default {
get
getTypes
};

2 changes: 1 addition & 1 deletion src/type.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from 'chai';
import {get} from './type';
import {getTypes} from './type';

describe('type', () => {
it('should get types properly');
Expand Down

0 comments on commit f3912d4

Please sign in to comment.