diff --git a/README.md b/README.md index 0c7bcd4..8f36fe5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ sineQL consists of two languages - the schema language, and the query language. The handler's definition is left up to the user. +## Feature List + +* Easy to use schema language +* Easy to use query language +* Simple to set-up a server +* Each top-level keyword (and queries) is optional + ## Example Server A simple express server using sineQL. @@ -15,6 +22,7 @@ A simple express server using sineQL. const express = require('express'); const app = express(); +//uses text input app.use(express.text()); //test the library @@ -22,6 +30,7 @@ const sineQL = require('sineql'); const schema = require('./schema.js'); const queryHandler = require('./query-handler.js'); +//omit 'queryHandler', 'createHandler', 'updateHandler' or 'deleteHandler' to disable those methods const sine = sineQL(schema, { queryHandler }, { debug: true }); //open the endpoint diff --git a/source/index.js b/source/index.js index baf3f5b..2ffaa86 100644 --- a/source/index.js +++ b/source/index.js @@ -31,7 +31,16 @@ const sineQL = (schema, { queryHandlers }, options = {}) => { //no leading keyword - regular query default: { + if (!queryHandlers) { + return [501, 'Query handlers not implemented']; + } + const queryTree = parseQueryTree(tokens, typeGraph, options); + + if (!queryHandlers[queryTree.typeName]) { + throw `Query handler not implemented for that type: ${queryTree.typeName}`; + } + const result = await queryHandlers[queryTree.typeName](queryTree, typeGraph); if (options.debug) {