import { gql } from "graphql-request";
import { DataFetcher } from "../DataFetcher";
export default class ApplicationConfigFetcher {
  constructor() {
    this.templateByQuery = new Map();
    this.buldTemplates();
  }
  buldTemplates() {
    this.templateByQuery.set("getResource", gql `query($name: String!) {
            $queryAlias$: getResource(name: $name){
              name
              resource
            }
        }`);
  }
  getResource(name, resourceID) {
    const completPath = `cfg://app/${resourceID}/${name}`;
    return DataFetcher.get().callGraphQL({
      values: { name: completPath },
      query: this.templateByQuery.get("getResource"),
    });
  }
}
