mirror of
https://github.com/BradNut/gQuery
synced 2025-09-08 17:40:18 +00:00
minor changes to remove unused code
This commit is contained in:
parent
e6548a895d
commit
e2891e3a8d
4 changed files with 15 additions and 136 deletions
9
dist/gFetch.d.ts
vendored
9
dist/gFetch.d.ts
vendored
|
|
@ -32,13 +32,10 @@ declare type gFetchProperties = {
|
|||
queries: GFetchQueries[];
|
||||
fetch: typeof fetch;
|
||||
};
|
||||
export declare type ApolloClientOptions = {
|
||||
export declare type GClientOptions = {
|
||||
path?: string;
|
||||
};
|
||||
export declare type ApolloClient = {
|
||||
path?: string;
|
||||
};
|
||||
export declare type GFetchReturn<T> = {
|
||||
export declare type GReturn<T> = {
|
||||
data: T;
|
||||
errors?: Error;
|
||||
};
|
||||
|
|
@ -49,7 +46,7 @@ export declare type GGetParameters<Variables> = {
|
|||
export declare type GFetchReturnWithErrors<T> = Spread<[T, GFetchQueryDefault]>;
|
||||
export declare class GFetch extends Object {
|
||||
path: string;
|
||||
constructor(options: ApolloClientOptions);
|
||||
constructor(options: GClientOptions);
|
||||
fetch<T>({ queries, fetch, }?: gFetchProperties | {}): Promise<GFetchReturnWithErrors<T>>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
55
dist/gFetch.js
vendored
55
dist/gFetch.js
vendored
|
|
@ -1,5 +1,4 @@
|
|||
import { Kind, print, } from "graphql";
|
||||
import "svelte/store";
|
||||
import { Kind, print } from "graphql";
|
||||
import { formatDocument as addTypenameToDocument } from "./utils/format";
|
||||
// This function accepts a graphql document and returns a string to be used
|
||||
// in fetch calls
|
||||
|
|
@ -52,59 +51,11 @@ export class GFetch extends Object {
|
|||
const data = await res.json();
|
||||
return {
|
||||
...data.data,
|
||||
errors: data.errors,
|
||||
};
|
||||
// } as GFetchReturnWithErrors<T>;
|
||||
}
|
||||
}
|
||||
// * ogFetch
|
||||
// This function is a fetcher that returns a svelte readable subscription
|
||||
// This is to be used for client side fetching of data
|
||||
// public oFetch<F>({
|
||||
// queries,
|
||||
// }: {
|
||||
// queries: GFetchQueries[];
|
||||
// }): Readable<GFetchReturnWithErrors<F>> {
|
||||
// // 1. Build the store and initialize it as empty and error free
|
||||
// const initial = new Map();
|
||||
// // Creates a store that will be used to subscribe to the data
|
||||
// const store = readable(initial, this.makeSubscribe(initial, queries));
|
||||
// return store as unknown as Readable<GFetchReturnWithErrors<F>>;
|
||||
// }
|
||||
// // A dummy function that is used to make subscribe happy.
|
||||
// private unsubscribe() {
|
||||
// // Nothing to do in this case
|
||||
// }
|
||||
// // Part of ogFetch
|
||||
// // Designed this way to work will with Svelte's readable store
|
||||
// private makeSubscribe(data, queries) {
|
||||
// // Create a closure with access to the
|
||||
// // initial data and initialization arguments
|
||||
// return (set) => {
|
||||
// // 3. This won't get executed until the store has
|
||||
// // its first subscriber. Kick off retrieval.
|
||||
// this.fetchDataForSubscription(data, set, queries);
|
||||
// // We're not waiting for the response.
|
||||
// // Return the unsubscribe function which doesn't do
|
||||
// // do anything here (but is part of the stores protocol).
|
||||
// return this.unsubscribe;
|
||||
// };
|
||||
// }
|
||||
// // Part of ogFetch
|
||||
// // Runs gFetch and updates subscription
|
||||
// private async fetchDataForSubscription(data, set, queries: GFetchQueries[]) {
|
||||
// try {
|
||||
// // Dispatch the request for the users
|
||||
// // This code is ONLY run client side, so fetch comes globally from the browser
|
||||
// const response = await this.fetch({ queries, fetch });
|
||||
// set(response);
|
||||
// } catch (error) {
|
||||
// // 6b. if there is a fetch error - deal with it
|
||||
// // and let observers know
|
||||
// data.error = error;
|
||||
// set(data);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// export const data = writable();
|
||||
// ! IDEAS
|
||||
// Mutations should take care of updating a generated writeable.
|
||||
// $tutorial is auto updated site wide
|
||||
|
|
|
|||
2
dist/gFetch.js.map
vendored
2
dist/gFetch.js.map
vendored
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"gFetch.js","sourceRoot":"","sources":["../src/gFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EA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CAAC;CACF;AAED,UAAU;AACV,gEAAgE;AAChE,sCAAsC"}
|
||||
|
|
@ -1,13 +1,5 @@
|
|||
import {
|
||||
Location,
|
||||
DefinitionNode,
|
||||
DocumentNode,
|
||||
Kind,
|
||||
parse,
|
||||
print,
|
||||
} from "graphql";
|
||||
import { readable, writable } from "svelte/store";
|
||||
import type { Readable } from "svelte/store";
|
||||
import { DefinitionNode, DocumentNode, Kind, print } from "graphql";
|
||||
|
||||
import { formatDocument as addTypenameToDocument } from "./utils/format";
|
||||
|
||||
// What's the deal with *gFetch*?
|
||||
|
|
@ -76,10 +68,6 @@ export const getOperationName = (query: DocumentNode): string | undefined => {
|
|||
}
|
||||
};
|
||||
|
||||
interface WritableLocation {
|
||||
loc: Location | undefined;
|
||||
}
|
||||
|
||||
export const stringifyDocument = (
|
||||
node: string | DefinitionNode | DocumentNode
|
||||
): string => {
|
||||
|
|
@ -94,14 +82,11 @@ type gFetchProperties = {
|
|||
fetch: typeof fetch;
|
||||
};
|
||||
|
||||
export type ApolloClientOptions = {
|
||||
path?: string;
|
||||
};
|
||||
export type ApolloClient = {
|
||||
export type GClientOptions = {
|
||||
path?: string;
|
||||
};
|
||||
|
||||
export type GFetchReturn<T> = {
|
||||
export type GReturn<T> = {
|
||||
data: T;
|
||||
errors?: Error;
|
||||
};
|
||||
|
|
@ -116,7 +101,7 @@ export type GFetchReturnWithErrors<T> = Spread<[T, GFetchQueryDefault]>;
|
|||
export class GFetch extends Object {
|
||||
public path: string;
|
||||
|
||||
constructor(options: ApolloClientOptions) {
|
||||
constructor(options: GClientOptions) {
|
||||
super();
|
||||
const { path } = options;
|
||||
this.path = path;
|
||||
|
|
@ -151,66 +136,12 @@ export class GFetch extends Object {
|
|||
|
||||
return {
|
||||
...data.data,
|
||||
} as GFetchReturnWithErrors<T>;
|
||||
errors: data.errors,
|
||||
};
|
||||
// } as GFetchReturnWithErrors<T>;
|
||||
}
|
||||
}
|
||||
|
||||
// * ogFetch
|
||||
// This function is a fetcher that returns a svelte readable subscription
|
||||
// This is to be used for client side fetching of data
|
||||
// public oFetch<F>({
|
||||
// queries,
|
||||
// }: {
|
||||
// queries: GFetchQueries[];
|
||||
// }): Readable<GFetchReturnWithErrors<F>> {
|
||||
// // 1. Build the store and initialize it as empty and error free
|
||||
// const initial = new Map();
|
||||
// // Creates a store that will be used to subscribe to the data
|
||||
// const store = readable(initial, this.makeSubscribe(initial, queries));
|
||||
// return store as unknown as Readable<GFetchReturnWithErrors<F>>;
|
||||
// }
|
||||
|
||||
// // A dummy function that is used to make subscribe happy.
|
||||
// private unsubscribe() {
|
||||
// // Nothing to do in this case
|
||||
// }
|
||||
|
||||
// // Part of ogFetch
|
||||
// // Designed this way to work will with Svelte's readable store
|
||||
// private makeSubscribe(data, queries) {
|
||||
// // Create a closure with access to the
|
||||
// // initial data and initialization arguments
|
||||
// return (set) => {
|
||||
// // 3. This won't get executed until the store has
|
||||
// // its first subscriber. Kick off retrieval.
|
||||
// this.fetchDataForSubscription(data, set, queries);
|
||||
|
||||
// // We're not waiting for the response.
|
||||
// // Return the unsubscribe function which doesn't do
|
||||
// // do anything here (but is part of the stores protocol).
|
||||
// return this.unsubscribe;
|
||||
// };
|
||||
// }
|
||||
|
||||
// // Part of ogFetch
|
||||
// // Runs gFetch and updates subscription
|
||||
// private async fetchDataForSubscription(data, set, queries: GFetchQueries[]) {
|
||||
// try {
|
||||
// // Dispatch the request for the users
|
||||
// // This code is ONLY run client side, so fetch comes globally from the browser
|
||||
// const response = await this.fetch({ queries, fetch });
|
||||
// set(response);
|
||||
// } catch (error) {
|
||||
// // 6b. if there is a fetch error - deal with it
|
||||
// // and let observers know
|
||||
// data.error = error;
|
||||
// set(data);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// export const data = writable();
|
||||
|
||||
// ! IDEAS
|
||||
// Mutations should take care of updating a generated writeable.
|
||||
// $tutorial is auto updated site wide
|
||||
|
|
|
|||
Loading…
Reference in a new issue