import { ApolloClient } from "@apollo/client";
import dotenv from "dotenv";
import uri from "./uri";
import resolvers from "./resolvers";
import cache from "./cache";
import { createUploadLink } from "apollo-upload-client";

const headers = {
  UTH: localStorage.getItem("UTH") || "",
  developer: sessionStorage.getItem("developer") || "",
  smsKey: localStorage.getItem("smskey") || ""
};

const fileUploadLink = createUploadLink({
  uri,
  headers,
});


dotenv.config({
  path: "../.env",
});

const client = new ApolloClient({
  resolvers,
  // @ts-ignore
  link: fileUploadLink,
  uri,
  cache,
  headers,
});

export default client;
