mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 02:34:28 +11:00
Updated readme
This commit is contained in:
@@ -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.
|
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
|
## Example Server
|
||||||
|
|
||||||
A simple express server using sineQL.
|
A simple express server using sineQL.
|
||||||
@@ -15,6 +22,7 @@ A simple express server using sineQL.
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
//uses text input
|
||||||
app.use(express.text());
|
app.use(express.text());
|
||||||
|
|
||||||
//test the library
|
//test the library
|
||||||
@@ -22,6 +30,7 @@ const sineQL = require('sineql');
|
|||||||
const schema = require('./schema.js');
|
const schema = require('./schema.js');
|
||||||
const queryHandler = require('./query-handler.js');
|
const queryHandler = require('./query-handler.js');
|
||||||
|
|
||||||
|
//omit 'queryHandler', 'createHandler', 'updateHandler' or 'deleteHandler' to disable those methods
|
||||||
const sine = sineQL(schema, { queryHandler }, { debug: true });
|
const sine = sineQL(schema, { queryHandler }, { debug: true });
|
||||||
|
|
||||||
//open the endpoint
|
//open the endpoint
|
||||||
|
|||||||
@@ -31,7 +31,16 @@ const sineQL = (schema, { queryHandlers }, options = {}) => {
|
|||||||
|
|
||||||
//no leading keyword - regular query
|
//no leading keyword - regular query
|
||||||
default: {
|
default: {
|
||||||
|
if (!queryHandlers) {
|
||||||
|
return [501, 'Query handlers not implemented'];
|
||||||
|
}
|
||||||
|
|
||||||
const queryTree = parseQueryTree(tokens, typeGraph, options);
|
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);
|
const result = await queryHandlers[queryTree.typeName](queryTree, typeGraph);
|
||||||
|
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
|
|||||||
Reference in New Issue
Block a user