Skip to content

Commit ae6d3ae

Browse files
committed
GraphQL: Added Creation Date (c_date) and Last update (u_date) to field list for all objects.
1 parent fcd1142 commit ae6d3ae

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ Configuration options are set in the file [config.js](https://github.com/evolute
8282
| wComments | Allow for user comments. |
8383
| wRating | Allow for user ratings. |
8484
| wTimestamp | Timestamp columns u_date and c_date w/ date of record creation and last update. |
85-
8685
| schemaQueries | Enables endpoints to query for lists of tables and columns in the database schema. |
86+
| GraphQL | Set GraphQL = true to unable GraphQL (Work In Progress) |
8787

8888
<a name="Models"></a>
8989
## Models

js/graphql-schema.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
const graphql = require('graphql'),
10-
{ connectionString } = require('../config'),
10+
config = require('../config'),
1111
pgp = require('pg-promise')(),
1212
crud = require('./crud'),
1313
logger = require('./utils/logger'),
@@ -17,9 +17,8 @@ const graphql = require('graphql'),
1717
errors = require('./utils/errors')
1818

1919
const mIds = dico.modelIds
20-
2120
const db = {}
22-
db.conn = pgp(connectionString);
21+
db.conn = pgp(config.connectionString);
2322

2423
const {
2524
GraphQLObjectType,
@@ -78,7 +77,13 @@ const model2gqlObjectType = m => {
7877
// - add "shadow field" for text value of list/lov item
7978
fields[f.id+'_txt'] = gqlFieldLOVText(f)
8079
}
81-
});
80+
})
81+
82+
// - "timestamp" columns to track creation and last modification.
83+
if(config.wTimestamp){
84+
fields['c_date'] = gqlField({type: ft.datetime})
85+
fields['u_date'] = gqlField({type: ft.datetime})
86+
}
8287
return new GraphQLObjectType({
8388
name: m.id,
8489
fields: fields,

0 commit comments

Comments
 (0)