aurelia-breeze icon indicating copy to clipboard operation
aurelia-breeze copied to clipboard

Extracting Metadata with error involving 'isPrototypeOf'

Open Catchops opened this issue 8 years ago • 0 comments

I am trying to implement the aurelia-breeze library into a new aurelia application, and when the first query is run, the library is trying to download the Metadata and it fails returning the error:

"Metadata query failed for: http://localhost:8080/api/CE/CE/Metadata; TypeError: Cannot read property 'isPrototypeOf' of undefined"

I have been successful in hitting that same service using basic Breeze, but I found this library and thought I would implement it to take advantage of some of the out of the box features. (e.g. removing Q from the list of libraries, etc)

I'm using the entity-manager-factory to encapsulate the entityManager as seen in the aureliea-breeze-northwind demo. It is used by a service object to extract the data from my web.api. Here is the service object:

import breeze from 'breeze';
import {createEntityManager} from '../entity-manager-factory';

export class PartyDataService {

    /**********************************************
     * loadExistingHospital
     * id - integer Id of the hospital you are needing
     **********************************************/
    loadExistingHospital(id) {

        var hospitalQuery = new breeze.EntityQuery().from('Hospitals')
            .where('HospitalId', '==', id)
            .select('Organization.Name', 'Organization.Url', 'Organization.IsActive', 'IsPending');

        return createEntityManager()
            .then(em => em.executeQuery(hospitalQuery))
            .then(queryResult => {
                return {
                    entity: queryResult.results[0],
                    entityManager: queryResult.entityManager
                };
            })
            .catch(error => {
                alert('error on Load by Id');
            });

    }

    /**********************************************
     * loadHospitalList - loads all hospitals from this list.
     **********************************************/
    loadHospitalList() {

        var hospitalQuery = new breeze.EntityQuery().from('Hospitals');
            //.select('Organization.Name', 'Organization.Url', 'Organization.IsActive', 'IsPending')
            //.orderBy('Organization.Name');

        return createEntityManager()
            .then(em => em.executeQuery(hospitalQuery))
            .then(queryResult => {
                return {
                    entity: queryResult.results,
                    entityManager: queryResult.entityManager
                };
            })
            .catch(error => {
                alert('error on Load List');
            });


    }


}

I have the plugin being instantiated from my main.js file:

import {LogManager} from 'aurelia-framework';
import {ConsoleAppender} from 'aurelia-logging-console';
import {ConventionalViewStrategy} from 'aurelia-framework';
import {Configure} from 'aurelia-configuration';

LogManager.addAppender(new ConsoleAppender());
LogManager.setLevel(LogManager.logLevel.debug);

export function configure(aurelia) {

    aurelia.use
        .standardConfiguration()
        .developmentLogging()
        .plugin('aurelia-configuration',
            config => {
                config.setCascadeMode(false);
                config.setEnvironments({
                    Code: ['localhost'],
                    Dev: ['zzzzzzzzzz'],
                    QA: ['yyyyyyyyy'],
                    Prod: ['xxxxxxxxxx']
                });
                config.setDirectory('CeApps/configs');
                config.setConfig('config.json');
            })
        .plugin('aurelia-kendoui-bridge', (kendo) => kendo.pro())
        .plugin('aurelia-breeze');   // install the aurelia-breeze integration plugin.
    ;

    aurelia.start().then(a => a.setRoot('CeApp/app'));

}

I must be missing something - any thoughts??

Catchops avatar Oct 12 '16 21:10 Catchops