snowballtools-base/packages/gql-client/src/client.ts
prathamesh0 d4b0659307 Update instructions and general package cleanup (#29)
* Update root readme and setup depcheck

* Use fetched domain data in edit domain dialog box

* Use fetched project data in general tab

* Rename files in gql-client package

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-01 11:37:57 +05:30

46 lines
953 B
TypeScript

import { ApolloClient, InMemoryCache, NormalizedCacheObject } from '@apollo/client';
import { getUser, getOrganizations, getDeployments } from './queries';
export interface GraphQLConfig {
gqlEndpoint: string;
}
export class GQLClient {
private client: ApolloClient<NormalizedCacheObject>;
constructor (config: GraphQLConfig) {
this.client = new ApolloClient({
uri: config.gqlEndpoint,
cache: new InMemoryCache()
});
}
async getUser () : Promise<any> {
const { data } = await this.client.query({
query: getUser
});
return data;
}
async getOrganizations () : Promise<any> {
const { data } = await this.client.query({
query: getOrganizations
});
return data;
}
async getDeployments (projectId: string) : Promise<any> {
const { data } = await this.client.query({
query: getDeployments,
variables: {
projectId
}
});
return data;
}
}