active-db.ts

import { fetchFromGraphQL } from '../../utility/lib/fetch';

export async function setActiveDb(req) {
  const { id } = req.body;
  const query = `
    mutation UpdateActiveDb($id: Int!) {
      setActiveDb(id: $id) {
        id
      }
    }
  `;
  const variables = { id };
  const response = await fetchFromGraphQL({
    query,
    variables
  });
  return response;
}

export async function getActiveDb(req) {
  const query = `{
    getActiveDb {
      id
    }
  }
  `;
  const response = await fetchFromGraphQL({
    query
  });
  return response;
}