weaviate-client
Version:
JS/TS client for Weaviate
34 lines (33 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commandBase_js_1 = require("../validation/commandBase.js");
class RawGraphQL extends commandBase_js_1.CommandBase {
query;
constructor(client) {
super(client);
}
withQuery = (query) => {
this.query = query;
return this;
};
validateIsSet = (prop, name, setter) => {
if (prop == undefined || prop == null || prop.length == 0) {
this.addError(`${name} must be set - set with ${setter}`);
}
};
validate = () => {
this.validateIsSet(this.query, 'query', '.raw().withQuery(query)');
};
do = () => {
const params = '';
this.validate();
if (this.errors.length > 0) {
return Promise.reject(new Error('invalid usage: ' + this.errors.join(', ')));
}
if (this.query) {
return this.client.query(this.query);
}
return Promise.resolve(undefined);
};
}
exports.default = RawGraphQL;