Skip to content

Commit

Permalink
Merge pull request #125 from Funfunz/release/sprint9
Browse files Browse the repository at this point in the history
Release/sprint9
  • Loading branch information
JWebCoder authored Mar 31, 2021
2 parents 3149b0a + 6cee620 commit fe4488c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 14 deletions.
3 changes: 2 additions & 1 deletion docker/mysql/db/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ CREATE TABLE `products` (
`updatedAt` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`FamilyId` int(11) DEFAULT NULL,
`active` tinyint(1) DEFAULT NULL,
`price` DOUBLE(24,20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FamilyId` (`FamilyId`),
CONSTRAINT `products_ibfk_1` FOREIGN KEY (`FamilyId`) REFERENCES `families` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
Expand All @@ -133,7 +134,7 @@ CREATE TABLE `products` (

LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
INSERT INTO `products` VALUES (1,'name1','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(2,'name2','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(3,'name3','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(4,'name4','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(5,'name5','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(6,'name6','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(7,'name7','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(8,'name8','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(9,'name9','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(10,'name10','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(11,'name11','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(12,'name12','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(13,'name13','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(14,'name14','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(15,'name15','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0),(16,'name16','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0),(17,'name17','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(18,'name18','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(19,'name19','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(20,'name20','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(21,'name21','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(22,'name22','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(23,'name23','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(24,'name24','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(25,'name25','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(26,'name26','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(27,'name27','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(28,'name28','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(29,'name29','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(30,'name30','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(31,'name31','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(32,'name32','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(33,'name33','Yellow',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(34,'name34','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0);
INSERT INTO `products` VALUES (1,'name1','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(2,'name2','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.2),(3,'name3','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.3),(4,'name4','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.4),(5,'name5','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.5),(6,'name6','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.6),(7,'name7','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(8,'name8','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(9,'name9','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(10,'name10','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(11,'name11','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(12,'name12','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(13,'name13','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(14,'name14','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(15,'name15','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1),(16,'name16','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1),(17,'name17','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(18,'name18','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(19,'name19','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(20,'name20','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(21,'name21','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(22,'name22','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(23,'name23','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(24,'name24','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(25,'name25','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(26,'name26','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(27,'name27','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(28,'name28','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(29,'name29','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(30,'name30','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(31,'name31','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(32,'name32','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(33,'name33','Yellow',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(34,'name34','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1);
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/generator/configurationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type IRelation = IRelation1N | IRelationN1 | IRelationMN

export interface IProperty {
name: string
type: 'string' | 'number' | 'boolean' | 'file'
type: 'string' | 'number' | 'boolean' | 'file' | 'float'
isPk?: boolean
required?: boolean
filterable?: boolean | OperatorsType[]
Expand Down
3 changes: 2 additions & 1 deletion src/middleware/graphql/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLScalarType, GraphQLString, GraphQLInt, GraphQLBoolean } from 'graphql'
import { GraphQLScalarType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean } from 'graphql'
import { GraphQLUpload } from 'graphql-upload'

export const MATCHER: {
Expand All @@ -8,4 +8,5 @@ export const MATCHER: {
'number': GraphQLInt,
'boolean': GraphQLBoolean,
'file': GraphQLUpload,
'float': GraphQLFloat,
}
38 changes: 38 additions & 0 deletions src/test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,44 @@ describe('graphql', () => {
}
)
})
it('update product price', (done) => {
return request(authApplication)
.post('/api')
.send({
query: `
mutation {
updateProducts (
take: 1
skip: 0
filter: {
id: {
_eq: 1
}
}
data: {
price: 1.2
}
){
id
price
}
}`,
})
.set('Accept', 'application/json').end(
(err, response) => {
if (err) {
return done(err)
}
expect(response.status).toBe(200)
expect(response.body).toBeTruthy()
const data = response.body.data
expect(Array.isArray(data.updateProducts)).toBeTruthy()
expect(data.updateProducts[0].id).toBeTruthy()
expect(data.updateProducts[0].price).toEqual(1.2)
return done()
}
)
})
it('query data', (done) => {
return request(authApplication)
.post('/api')
Expand Down
6 changes: 5 additions & 1 deletion src/test/configs/models/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export default {
{
name: 'active',
type: 'boolean',
}
},
{
name: 'price',
type: 'float',
},
],
hooks: {
count: {
Expand Down
22 changes: 22 additions & 0 deletions src/test/graphql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('graphql', () => {
query: `{
products {
id
price
families {
id
}
Expand All @@ -76,6 +77,27 @@ describe('graphql', () => {
)
})

it('graphql foat values should be supported', (done) => {
return request(application)
.post('/')
.send({
query: `{
products {
price
}
}`,
})
.set('Accept', 'application/json').end(
(err, response) => {
if (err) {
return done(err)
}
expect(response.status).toBe(200)
return done()
}
)
})

it('graphql endpoint with recursive deep queries should return 200', (done) => {
return request(application)
.post('/')
Expand Down
3 changes: 2 additions & 1 deletion src/test/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ CREATE TABLE `products` (
`updatedAt` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`FamilyId` int(11) DEFAULT NULL,
`active` tinyint(1) DEFAULT NULL,
`price` DOUBLE(24,20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FamilyId` (`FamilyId`),
CONSTRAINT `products_ibfk_1` FOREIGN KEY (`FamilyId`) REFERENCES `families` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
Expand All @@ -133,7 +134,7 @@ CREATE TABLE `products` (

LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
INSERT INTO `products` VALUES (1,'name1','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(2,'name2','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(3,'name3','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(4,'name4','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(5,'name5','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(6,'name6','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(7,'name7','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(8,'name8','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(9,'name9','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(10,'name10','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1),(11,'name11','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(12,'name12','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(13,'name13','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(14,'name14','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0),(15,'name15','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0),(16,'name16','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0),(17,'name17','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(18,'name18','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(19,'name19','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(20,'name20','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(21,'name21','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(22,'name22','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(23,'name23','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(24,'name24','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(25,'name25','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(26,'name26','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(27,'name27','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(28,'name28','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(29,'name29','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(30,'name30','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(31,'name31','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(32,'name32','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(33,'name33','Yellow',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1),(34,'name34','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0);
INSERT INTO `products` VALUES (1,'name1','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(2,'name2','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.2),(3,'name3','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.3),(4,'name4','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.4),(5,'name5','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.5),(6,'name6','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.6),(7,'name7','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(8,'name8','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(9,'name9','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(10,'name10','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,1,1.1),(11,'name11','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(12,'name12','Blue',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(13,'name13','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(14,'name14','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',1,0,1.1),(15,'name15','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1),(16,'name16','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1),(17,'name17','Blue',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(18,'name18','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(19,'name19','Blue',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(20,'name20','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(21,'name21','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(22,'name22','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(23,'name23','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(24,'name24','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(25,'name25','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(26,'name26','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(27,'name27','Red',2,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(28,'name28','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(29,'name29','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(30,'name30','Red',3,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(31,'name31','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(32,'name32','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(33,'name33','Yellow',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,1,1.1),(34,'name34','Red',1,'2019-04-05 13:52:02','2019-04-05 13:52:02',2,0,1.1);
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down

0 comments on commit fe4488c

Please sign in to comment.