-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Terminal-Systems/develop
Develop
- Loading branch information
Showing
15 changed files
with
349 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
var _apolloServer = require("apollo-server"); | ||
|
||
var _schema = _interopRequireDefault(require("./schema")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
// import createLoaders from './loaders'; | ||
const server = new _apolloServer.ApolloServer({ | ||
schema: _schema.default, | ||
formatError: error => { | ||
console.log(error); | ||
return error; | ||
}, | ||
formatResponse: response => { | ||
console.log(response); | ||
return response; | ||
}, | ||
engine: false, | ||
tracing: true, | ||
cacheControl: true | ||
}); | ||
server.listen().then(({ | ||
url | ||
}) => { | ||
console.log(`🚀 Cats server ready at ${url}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const BaseModel = require('./base-model'); | ||
|
||
const knex = require('./db'); | ||
|
||
BaseModel.knex(knex); | ||
|
||
class Cat extends BaseModel { | ||
static get tableName() { | ||
return 'cats'; | ||
} | ||
|
||
} | ||
|
||
module.exports = Cat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
const { | ||
Model | ||
} = require('objection'); // models/BaseModel.js | ||
|
||
|
||
class BaseModel extends Model { | ||
static get modelPaths() { | ||
return [__dirname]; | ||
} | ||
|
||
$beforeUpdate() { | ||
this.updatedAt = new Date().toISOString(); | ||
} | ||
|
||
$beforeInsert() { | ||
this.createdAt = new Date().toISOString(); | ||
} | ||
|
||
} | ||
|
||
module.exports = BaseModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const Knex = require('knex'); | ||
|
||
const knexOptions = require('../../knexfile'); | ||
|
||
const env = process.env.NODE_ENV || 'development'; | ||
const knex = Knex(knexOptions[env]); | ||
module.exports = knex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
var _catsConnection = _interopRequireDefault(require("./root/cats-connection")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
module.exports = { | ||
Query: { | ||
catsConnection: _catsConnection.default | ||
}, | ||
Cat: {} | ||
}; |
33 changes: 33 additions & 0 deletions
33
tests/test-app/compiled-dist/queries/cat/root/cats-connection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _apolloCursorPagination = require("apollo-cursor-pagination"); | ||
|
||
var _Cat = _interopRequireDefault(require("../../../models/Cat")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var _default = async (_, args) => { | ||
// const { | ||
// first, last, before, after, orderBy, orderDirection, orderByMultiple, orderDirectionMultiple | ||
// } = args; | ||
const orderBy = args.orderBy || args.orderByMultiple; | ||
const orderDirection = args.orderDirection || args.orderDirectionMultiple; | ||
|
||
const baseQuery = _Cat.default.query().sum('id as idsum').select('cats.*').groupBy('id'); | ||
|
||
const result = await (0, _apolloCursorPagination.knexPaginator)(baseQuery, { ...args, | ||
orderBy, | ||
orderDirection | ||
}, { | ||
isAggregateFn: column => column === 'idsum', | ||
formatColumnFn: column => column === 'idsum' ? 'sum(id)' : column | ||
}); | ||
return result; | ||
}; | ||
|
||
exports.default = _default; |
Oops, something went wrong.