Created
January 15, 2020 17:26
-
-
Save jancorg/4da593e3e6a5ad2a062b5abfa187e7d3 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const modelList = [ 'oneModel', | |
'anotherModel' ] | |
let modelClasses = modelList.map((c,i,a) => require(`../models/${c}`)) | |
// let datetime = require('../lib/graphQl-dateTime') | |
const graphql = require('graphql').graphql | |
const graphQlBuilder = require('objection-graphql').builder | |
const graphQlSchema = graphQlBuilder().allModels(modelClasses) | |
.build() | |
module.exports.graphQl = async (event) => { | |
let query = JSON.parse(event.body) | |
let result = graphql(graphQlSchema, query ) | |
.catch(e => undefined) | |
return { | |
statusCode: result == undefined ? 404 : 200, | |
body: JSON.stringify(result) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment