aboutsummaryrefslogtreecommitdiff
path: root/source/standalone/index.ts
blob: f6defca8d9858fb8cac23fc7214460fb7f3dd916 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*** IMPORT ------------------------------------------- ***/

import {
  mount as svelteMount,
  unmount as svelteUnmount,
  type ComponentProps
} from "svelte";

/*** UTILITY ------------------------------------------ ***/

import GraphiQL from "../library/GraphiQL.svelte";

import { createApqFetcher } from "../library/fetcher/apq.ts";
import { createHttpFetcher } from "../library/fetcher/http.ts";
import { createSseFetcher } from "../library/fetcher/sse.ts";
import { createWsFetcher } from "../library/fetcher/websocket.ts";
import { lightTheme } from "../library/themes/light.ts";

type Props = ComponentProps<typeof GraphiQL>;
type Instance = Record<string, unknown>;

/*** EXPORT ------------------------------------------- ***/

export function mount(target: HTMLElement, props: Props): Instance {
  return svelteMount(GraphiQL, { props, target });
}

export function unmount(instance: Instance): void {
  svelteUnmount(instance);
}

export {
  createApqFetcher,
  createHttpFetcher,
  createSseFetcher,
  createWsFetcher,
  lightTheme
};