forked from cerc-io/snowballtools-base
d4b0659307
* 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>
46 lines
953 B
TypeScript
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;
|
|
}
|
|
}
|