Giter Club home page Giter Club logo

falcor-sql-router's People

Contributors

jameslaneconkling avatar

Watchers

 avatar

falcor-sql-router's Issues

500 error is reported on every pathSet

{
  "jsonGraph": {
    "foldersById": {
      "1": {
        "id": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "name": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "parentId": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        }
      },
      "3": {
        "id": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "name": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "parentId": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        }
      },
      "5": {
        "id": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "name": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "parentId": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        }
      },
      "15": {
        "id": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "name": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        },
        "parentId": {
          "$type": "error",
          "value": {
            "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
          }
        }
      }
    }
  }
}

might be more efficient to report on every object, rather than every object field. e.g.

{
  "jsonGraph": {
    "foldersById": {
      "1": {
        "$type": "error",
        "value": {
          "message": "SQLITE_ERROR: near \"SSELECT\": syntax error"
        }
      }
    }
  }
}

call createSubFolder route doesn't return refPaths, necessitating subsequent route calls

{
  route: 'foldersById[{keys:ids}].folders.createSubFolder',
  call(callPath, args, refPaths, thisPaths) {
    const ids = callPath.ids;
    const name = args[0].name;

    return Rx.Observable.from(ids)
      .concatMap(id => {
        // create folder
        // TODO - how to better create two observables in sequence (second is created only after the first completes) and combine their results
        return Folder.create(name, id)
          .flatMap(folder => {
            // get new count of parent folder's subfolders
            return Folder.getSubfolderCount(id)
              .map(data => Object.assign(folder, {parentSubFolderCount: data.count}));
          });
      })
      .map(folder => {
        // return pathValue ref linking parentFolder to new folder
        // TODO - this assumes the new folder is inserted at the end of the parentFolder.folders list
        const folderPathValue = {
          path: ['foldersById', folder.parentId, 'folders', folder.parentSubFolderCount -1],
          value: $ref(['foldersById', folder.id])
        };

        return [folderPathValue];

        // return pathValues for refPaths, if known
        // TODO - this doesn't actually prevent a subsequent call to folderById.newFolderId[refPaths]
        //        though the equivalent jsonGraphEnvelope does...
        // const folderFieldPathValues = refPaths
        //   .filter(path => path.length === 1 && ['id', 'name', 'parentId'].indexOf(path[0]) >= 0)
        //   .map(path => path[0])
        //   .map(field => ({
        //     path: ['foldersById', folder.parentId, 'folders', folder.parentSubFolderCount -1, field],
        //     value: folder[field]
        //   }));

        // return [folderPathValue, ...folderFieldPathValues];

        // TODO - thought hardcoded, this does prevent a subsequent call to folderById.newFolderId[refPaths]
        // const jsonGraphEnvelope = {
        //   jsonGraph: {
        //     foldersById: {
        //       1: {
        //         folders: {
        //           length: folder.parentSubFolderCount,
        //           3: $ref(['foldersById', 10])
        //         }
        //       },
        //       10: {id: folder.id, parentId: folder.parentId, name: folder.name}
        //     }
        //   },
        //   paths: [
        //     ['foldersById', 1, 'folders', 'length'],
        //     ['foldersById', 1, 'folders', folder.parentSubFolderCount -1, 'id'],
        //     ['foldersById', 1, 'folders', folder.parentSubFolderCount -1, 'parentId'],
        //     ['foldersById', 1, 'folders', folder.parentSubFolderCount -1, 'name']
        //   ],
        //   invalidated: [[]]
        // };

        // return jsonGraphEnvelope;
      });

db query callback prevents Rx.Observable error handling

exports.getByIds = (ids, fields) => {
  return Rx.Observable.create(observer => {
    // this error is properly handled
    throw new Error('ERERERERERE')
    db.all(`SELECT id, ${fields.join(', ')} FROM folder WHERE id IN (${ids.join(', ')})`, [], (err, rows) => {
      if (err) {
        // this error is of course properly handled
        observer.onError(err);
      } else {
        // this error is not properly handled
        throw new Error('HEREHERE');

        observer.onCompleted();
      }
    });
  });
};

On not properly handled error, app crashes, rather than causing Observable to emit an error

error nodes do not contain messages

and return on the field, when they arguably should return on the object

{
  "jsonGraph": {
    "foldersById": {
      "1": {
        "id": {
          "$type": "error",
          "value": {}
        },
        "name": {
          "$type": "error",
          "value": {}
        },
        "parentId": {
          "$type": "error",
          "value": {}
        }
      },
      "3": {
        "id": {
          "$type": "error",
          "value": {}
        },
        "name": {
          "$type": "error",
          "value": {}
        },
        "parentId": {
          "$type": "error",
          "value": {}
        }
      }
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.