Skip to content

Commit

Permalink
fix(schema): handle float like numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jul 27, 2015
1 parent 26e642f commit 5fcc91a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GraphQLNonNull,
GraphQLSchema,
GraphQLString,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean,
GraphQLList
} from 'graphql/lib/type';
Expand Down Expand Up @@ -70,7 +70,7 @@ function getSchema (models) {
// Number
} else if (path.instance === 'Number') {
return {
type: GraphQLInt
type: GraphQLFloat
};

// Date
Expand Down Expand Up @@ -118,7 +118,7 @@ function getSchema (models) {
} else {
if (path.caster.instance === 'Number') {
return {
type: new GraphQLList(GraphQLInt)
type: new GraphQLList(GraphQLFloat)
};
} else if (path.caster.instance === 'String') {
return {
Expand Down
4 changes: 4 additions & 0 deletions src/schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('schema', () => {
type: String
},
age: Number,
weight: Number, // to test "floatish" numbers
createdAt: Date,
removed: Boolean,
nums: [Number],
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('schema', () => {
var user = new User({
name: 'Foo',
age: 24,
weight: 64.7,
removed: false,
createdAt: new Date(1437911686190)
});
Expand All @@ -76,6 +78,7 @@ describe('schema', () => {
user(_id: "${user._id}") {
name
age
weight
createdAt
removed
}
Expand All @@ -86,6 +89,7 @@ describe('schema', () => {
user: {
name: 'Foo',
age: 24,
weight: 64.7,
createdAt: '2015-07-26T11:54:46.190Z',
removed: false
}
Expand Down

0 comments on commit 5fcc91a

Please sign in to comment.