UNPKG

weaviate-client

Version:
31 lines (30 loc) • 919 B
import { CommandBase } from '../validation/commandBase.js'; export default class RawGraphQL extends 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); }; }