aboutsummaryrefslogtreecommitdiff
path: root/source/library/state/schema.svelte.ts
diff options
context:
space:
mode:
authornetop://ウィビ <paul@webb.page>2026-04-24 11:33:25 -0700
committernetop://ウィビ <paul@webb.page>2026-04-24 11:33:25 -0700
commit8a59f92d031963e23ecc84b75feecf43eb4dd146 (patch)
tree75de5768885583897061a3b1795e4c987ce90039 /source/library/state/schema.svelte.ts
downloadgraphiql-8a59f92d031963e23ecc84b75feecf43eb4dd146.tar.gz
graphiql-8a59f92d031963e23ecc84b75feecf43eb4dd146.zip
Initial commit: @eol/graphiql v0.3
Svelte 5 GraphiQL alternative for JSR. Covers: - HTTP fetcher with injectable fetch; SSE/WS stubs - Session store with tabs, auto-titling, persistence, rename - Operation detection via graphql parse(); Toolbar picker - CodeMirror 6 editor via cm6-graphql with theme prop - Light theme preset (hand-rolled EditorView.theme) - Doc explorer with breadcrumb nav and type guards - History panel with 100-entry cap, favorite pinning - Deno tests for operations, storage, and history eviction
Diffstat (limited to 'source/library/state/schema.svelte.ts')
-rw-r--r--source/library/state/schema.svelte.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/source/library/state/schema.svelte.ts b/source/library/state/schema.svelte.ts
new file mode 100644
index 0000000..c5f148f
--- /dev/null
+++ b/source/library/state/schema.svelte.ts
@@ -0,0 +1,41 @@
+
+
+
+/*** IMPORT ------------------------------------------- ***/
+
+import {
+ buildClientSchema,
+ getIntrospectionQuery,
+ printSchema,
+ type GraphQLSchema,
+ type IntrospectionQuery
+} from "graphql";
+
+/*** UTILITY ------------------------------------------ ***/
+
+import type { Fetcher } from "../fetcher/types.ts";
+
+/*** EXPORT ------------------------------------------- ***/
+
+export class SchemaStore {
+ error = $state<string | null>(null);
+ loading = $state(false);
+ schema = $state<GraphQLSchema | null>(null);
+ sdl = $state<string>("");
+
+ async introspect(fetcher: Fetcher) {
+ this.loading = true;
+ this.error = null;
+
+ try {
+ const result = await fetcher({ query: getIntrospectionQuery() });
+ const data = (result as { data: IntrospectionQuery }).data;
+ this.schema = buildClientSchema(data);
+ this.sdl = printSchema(this.schema);
+ } catch(err) {
+ this.error = String(err);
+ } finally {
+ this.loading = false;
+ }
+ }
+}