@obelisk/client
Version:
Typescript client to interact with Obelisk on a higher level than the regular ReST API calls.
43 lines (42 loc) • 1.29 kB
TypeScript
import { Observable } from 'rxjs';
import { ObeliskClient } from '../obelisk-client';
/**
* Endpoint class represents an Obelisk API Endpoint.
* For now just get(), but will support all http methods.
*/
export declare class GraphQLEndpoint {
private client;
private _url;
/**
* Absolute url to use in requests
*/
get url(): string;
/**
* Creates an Endpoint instance, the client is used to add tokens and uri is relative path starting after /api/<version>.
* Examples are: <code>/things/my_thing/metrics/my_metric/events?from=1530089953000</code> or <code>/locations/my_loc/metrics/my_metric/stats/unit</code>
*/
static create(client: ObeliskClient): GraphQLEndpoint;
private constructor();
/**
* Execute a GraphQLQuery
* @param request The GraphQL request
*/
execute(request: GraphQLRequest): Observable<GraphQLResult>;
}
export interface GraphQLRequest {
/**
* The actual query as a string
*/
query: string;
/**
* Only required if multiple operations are present in the query.
*/
operationName?: string;
variables?: {
[key: string]: any;
};
}
export interface GraphQLResult {
data?: any;
errors?: any[];
}