mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 10:44:28 +11:00
Replaced tests with jest
This commit is contained in:
@@ -4,7 +4,7 @@ const { eatBlock, checkAlphaNumeric } = require('./utils');
|
||||
const parseInput = require('./parse-input');
|
||||
|
||||
//parse the schema into a type graph
|
||||
const buildTypeGraph = (schema, options) => {
|
||||
const buildTypeGraph = (schema, options = {}) => {
|
||||
//the default graph
|
||||
let graph = {
|
||||
String: { typeName: 'String', scalar: true },
|
||||
|
||||
@@ -40,7 +40,7 @@ const sineQL = (schema, { queryHandlers, createHandlers }, options = {}) => {
|
||||
|
||||
case 'update':
|
||||
case 'delete':
|
||||
return [501, 'Keyword not implemented: ' + tokens[0]];
|
||||
return [501, 'Keyword not yet implemented: ' + tokens[0]];
|
||||
//TODO: implement these keywords
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//build the tokens into a single object of types representing the initial query
|
||||
const parseCreateTree = (tokens, typeGraph, options) => {
|
||||
const parseCreateTree = (tokens, typeGraph, options = {}) => {
|
||||
let current = 1; //primed
|
||||
|
||||
//check this is a create command
|
||||
@@ -94,6 +94,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
|
||||
//insert the typename into the block
|
||||
block['typeName'] = typeGraph[superType][fieldName].typeName;
|
||||
|
||||
//insert the unique modifier if it's set
|
||||
block['unique'] = typeGraph[superType][fieldName].unique;
|
||||
|
||||
//insert the block-level modifier signal
|
||||
if (modifier) {
|
||||
block[modifier] = true;
|
||||
@@ -122,6 +125,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
|
||||
//save the typeGraph type into result
|
||||
result[fieldName] = JSON.parse(JSON.stringify( typeGraph[ typeGraph[superType][fieldName].typeName ] ));
|
||||
|
||||
//insert the unique modifier if it's set
|
||||
result[fieldName]['unique'] = typeGraph[superType][fieldName].unique;
|
||||
|
||||
//insert the block-level modifier signal
|
||||
if (modifier) {
|
||||
result[fieldName][modifier] = tokens[current++];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//break the body down into tokens
|
||||
const parseInput = (body, allowStrings, options) => {
|
||||
const parseInput = (body, allowStrings, options = {}) => {
|
||||
let current = 0;
|
||||
tokens = [];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//build the tokens into a single object of types representing the initial query
|
||||
const parseQueryTree = (tokens, typeGraph, options) => {
|
||||
const parseQueryTree = (tokens, typeGraph, options = {}) => {
|
||||
let current = 1; //primed
|
||||
|
||||
//get a token that matches a type
|
||||
@@ -60,6 +60,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
|
||||
//insert the typename into the block
|
||||
block['typeName'] = typeGraph[superType][fieldName].typeName;
|
||||
|
||||
//insert the unique modifier if it's set
|
||||
block['unique'] = typeGraph[superType][fieldName].unique;
|
||||
|
||||
//insert into result
|
||||
result[fieldName] = block;
|
||||
|
||||
@@ -83,6 +86,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
|
||||
//save the typeGraph type into result
|
||||
result[fieldName] = JSON.parse(JSON.stringify( typeGraph[ typeGraph[superType][fieldName].typeName ] ));
|
||||
|
||||
//insert the unique modifier if it's set
|
||||
result[fieldName]['unique'] = typeGraph[superType][fieldName].unique;
|
||||
|
||||
//insert the block-level modifier signal
|
||||
if (modifier) {
|
||||
result[fieldName][modifier] = tokens[current++];
|
||||
|
||||
Reference in New Issue
Block a user