mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 02:34:28 +11:00
I remember why I stopped working on this, read more
it's because the query parser is impossible to understand, and the handlers are too long for this to be usable. It's a nice idea, but I can't do this while drinking.
This commit is contained in:
@@ -3,7 +3,7 @@ const parseInput = require('./parse-input');
|
||||
const parseQuery = require('./parse-query');
|
||||
|
||||
//the main function to be returned (sineQL())
|
||||
const main = (schema, handler, options = {}) => {
|
||||
const sineQL = (schema, handler, options = {}) => {
|
||||
let typeGraph;
|
||||
|
||||
try {
|
||||
@@ -21,8 +21,8 @@ const main = (schema, handler, options = {}) => {
|
||||
const tokens = parseInput(reqBody, true, options);
|
||||
let pos = 0;
|
||||
|
||||
//check for keywords
|
||||
switch(tokens[pos]) {
|
||||
//check for keywords
|
||||
case 'create':
|
||||
case 'update':
|
||||
case 'delete':
|
||||
@@ -40,8 +40,6 @@ const main = (schema, handler, options = {}) => {
|
||||
}
|
||||
|
||||
return [200, result];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
@@ -52,4 +50,4 @@ const main = (schema, handler, options = {}) => {
|
||||
};
|
||||
|
||||
//return to the caller
|
||||
module.exports = main;
|
||||
module.exports = sineQL;
|
||||
|
||||
@@ -13,7 +13,7 @@ const parseInput = (body, allowStrings, options) => {
|
||||
|
||||
case '"': {
|
||||
if (!allowStrings) {
|
||||
throw 'Can\'t lex strings';
|
||||
throw 'Can\'t parse strings';
|
||||
}
|
||||
|
||||
const start = current;
|
||||
@@ -50,4 +50,4 @@ const parseInput = (body, allowStrings, options) => {
|
||||
return tokens;
|
||||
};
|
||||
|
||||
module.exports = parseInput;
|
||||
module.exports = parseInput;
|
||||
|
||||
@@ -53,7 +53,7 @@ const parseQuery = async (handler, tokens, pos, typeGraph, parent = null, superM
|
||||
//push the scalar object to the queryFields
|
||||
scalarFields.push({ typeName: typeGraph[superType][tokens[pos - 1]].typeName, name: tokens[pos - 1], filter: matching ? tokens[pos++] : null });
|
||||
|
||||
//if I am a scalar child of a match amd I do not match
|
||||
//if I am a scalar child of a match and I do not match
|
||||
if (parent && superMatching && !matching) {
|
||||
throw 'Broken match chain in scalar type ' + tokens[pos - 1];
|
||||
}
|
||||
@@ -114,4 +114,4 @@ const parseQuery = async (handler, tokens, pos, typeGraph, parent = null, superM
|
||||
return [results, pos];
|
||||
};
|
||||
|
||||
module.exports = parseQuery;
|
||||
module.exports = parseQuery;
|
||||
|
||||
Reference in New Issue
Block a user