stashapp-api
Version:
Easy to use adapter for interaction with a Stash server through GraphQL.
28 lines (27 loc) • 776 B
JavaScript
import { ApolloClient, InMemoryCache, HttpLink, } from "@apollo/client";
import { FindPerformers } from "./generated/graphql.js";
export class StashApollo {
static instance;
client;
constructor(config) {
this.client = new ApolloClient({
link: new HttpLink({
uri: config.url,
headers: { ApiKey: config.apiKey },
}),
cache: new InMemoryCache(),
});
}
static init(config) {
if (!StashApollo.instance) {
StashApollo.instance = new StashApollo(config);
}
return StashApollo.instance;
}
async findPerformers(variables) {
return this.client.query({
query: FindPerformers,
variables,
});
}
}