Files
AFFiNE-Mirror/packages/frontend/graphql/src/index.ts
2024-04-17 15:09:09 +08:00

25 lines
602 B
TypeScript

export * from './error';
export * from './fetcher';
export * from './graphql';
export * from './schema';
import { setupGlobal } from '@affine/env/global';
import { gqlFetcherFactory } from './fetcher';
setupGlobal();
export function getBaseUrl(): string {
if (environment.isDesktop) {
return runtimeConfig.serverUrlPrefix;
}
if (typeof window === 'undefined') {
// is nodejs
return '';
}
const { protocol, hostname, port } = window.location;
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
}
export const fetcher = gqlFetcherFactory(getBaseUrl() + '/graphql');