houdini 1.0.0-next.1 → 1.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd/generate.d.ts +0 -1
- package/build/cmd-cjs/index.js +1400 -2836
- package/build/cmd-esm/index.js +1400 -2836
- package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
- package/build/codegen/generators/artifacts/index.d.ts +1 -1
- package/build/codegen/generators/artifacts/indexFile.d.ts +1 -1
- package/build/codegen/generators/artifacts/inputs.d.ts +2 -2
- package/build/codegen/generators/artifacts/operations.d.ts +2 -2
- package/build/codegen/generators/artifacts/selection.d.ts +1 -1
- package/build/codegen/generators/artifacts/utils.d.ts +1 -1
- package/build/codegen/generators/definitions/enums.d.ts +1 -1
- package/build/codegen/generators/definitions/index.d.ts +1 -1
- package/build/codegen/generators/indexFile/index.d.ts +1 -1
- package/build/codegen/generators/persistedQueries/index.d.ts +1 -1
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
- package/build/codegen/generators/runtime/index.d.ts +1 -1
- package/build/codegen/generators/runtime/injectPlugins.d.ts +7 -0
- package/build/codegen/generators/runtime/pluginIndex.d.ts +5 -0
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
- package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
- package/build/codegen/generators/typescript/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
- package/build/codegen/generators/typescript/index.d.ts +1 -1
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
- package/build/codegen/generators/typescript/types.d.ts +1 -1
- package/build/codegen/index.d.ts +1 -1
- package/build/codegen/transforms/addID.d.ts +1 -1
- package/build/codegen/transforms/composeQueries.d.ts +2 -2
- package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
- package/build/codegen/transforms/list.d.ts +1 -1
- package/build/codegen/transforms/paginate.d.ts +1 -1
- package/build/codegen/transforms/schema.d.ts +1 -1
- package/build/codegen/transforms/typename.d.ts +1 -1
- package/build/codegen/utils/commonjs.d.ts +2 -0
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen/utils/moduleExport.d.ts +1 -1
- package/build/codegen/utils/objectIdentificationSelection.d.ts +1 -1
- package/build/codegen/validators/noIDAlias.d.ts +1 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -1
- package/build/codegen-cjs/index.js +1320 -2779
- package/build/codegen-esm/index.js +1320 -2779
- package/build/lib/config.d.ts +9 -4
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/imports.d.ts +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/walk.d.ts +8 -5
- package/build/lib-cjs/index.js +155 -1856
- package/build/lib-esm/index.js +155 -1856
- package/build/runtime/cache/cache.d.ts +10 -8
- package/build/runtime/cache/gc.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -2
- package/build/runtime/cache/schema.d.ts +2 -2
- package/build/runtime/cache/stuff.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +19 -11
- package/build/runtime/client/documentStore.d.ts +87 -0
- package/build/runtime/client/index.d.ts +25 -0
- package/build/runtime/client/plugins/cache.d.ts +8 -0
- package/build/runtime/client/plugins/fetch.d.ts +37 -0
- package/build/runtime/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime/client/plugins/index.d.ts +7 -0
- package/build/runtime/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime/client/plugins/mutation.d.ts +1 -0
- package/build/runtime/client/plugins/query.d.ts +2 -0
- package/build/runtime/client/plugins/subscription.d.ts +18 -0
- package/build/runtime/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime/client/utils/index.d.ts +1 -0
- package/build/runtime/generated.d.ts +1 -0
- package/build/runtime/imports/config.d.ts +3 -0
- package/build/runtime/index.d.ts +3 -2
- package/build/runtime/lib/config.d.ts +26 -25
- package/build/runtime/lib/index.d.ts +1 -2
- package/build/runtime/lib/scalars.d.ts +6 -5
- package/build/runtime/lib/selection.d.ts +1 -1
- package/build/runtime/lib/store.d.ts +19 -0
- package/build/runtime/lib/types.d.ts +22 -9
- package/build/runtime/public/cache.d.ts +20 -7
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +18 -18
- package/build/runtime/public/tests/test.d.ts +44 -1
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/cache.d.ts +10 -8
- package/build/runtime-cjs/cache/cache.js +5 -11
- package/build/runtime-cjs/cache/gc.d.ts +1 -1
- package/build/runtime-cjs/cache/lists.d.ts +3 -2
- package/build/runtime-cjs/cache/lists.js +5 -2
- package/build/runtime-cjs/cache/schema.d.ts +2 -2
- package/build/runtime-cjs/cache/stuff.d.ts +2 -2
- package/build/runtime-cjs/cache/subscription.d.ts +19 -11
- package/build/runtime-cjs/cache/subscription.js +95 -56
- package/build/runtime-cjs/client/documentStore.d.ts +87 -0
- package/build/runtime-cjs/client/documentStore.js +360 -0
- package/build/runtime-cjs/client/index.d.ts +25 -0
- package/build/runtime-cjs/client/index.js +87 -0
- package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
- package/build/runtime-cjs/client/plugins/cache.js +99 -0
- package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +95 -3
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-cjs/client/plugins/fetchParams.js +40 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/index.js +24 -0
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-cjs/{lib/errors.js → client/plugins/injectedPlugins.js} +7 -15
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/mutation.js +86 -0
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/query.js +83 -0
- package/build/runtime-cjs/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-cjs/client/plugins/subscription.js +98 -0
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/throwOnError.js +47 -0
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-cjs/client/utils/documentPlugins.js +56 -0
- package/build/runtime-cjs/client/utils/index.d.ts +1 -0
- package/build/runtime-cjs/client/utils/index.js +18 -0
- package/build/runtime-cjs/generated.d.ts +1 -0
- package/build/runtime-cjs/imports/config.d.ts +3 -0
- package/build/runtime-cjs/imports/config.js +26 -0
- package/build/runtime-cjs/index.d.ts +3 -2
- package/build/runtime-cjs/index.js +1 -0
- package/build/runtime-cjs/lib/config.d.ts +26 -25
- package/build/runtime-cjs/lib/config.js +5 -4
- package/build/runtime-cjs/lib/index.d.ts +1 -2
- package/build/runtime-cjs/lib/index.js +1 -2
- package/build/runtime-cjs/lib/scalars.d.ts +6 -5
- package/build/runtime-cjs/lib/scalars.js +20 -24
- package/build/runtime-cjs/lib/selection.d.ts +1 -1
- package/build/runtime-cjs/lib/store.d.ts +19 -0
- package/build/runtime-cjs/lib/store.js +81 -0
- package/build/runtime-cjs/lib/types.d.ts +22 -9
- package/build/runtime-cjs/public/cache.d.ts +20 -7
- package/build/runtime-cjs/public/cache.js +29 -32
- package/build/runtime-cjs/public/list.d.ts +2 -2
- package/build/runtime-cjs/public/list.js +6 -28
- package/build/runtime-cjs/public/record.d.ts +18 -18
- package/build/runtime-cjs/public/record.js +23 -189
- package/build/runtime-cjs/public/tests/test.d.ts +44 -1
- package/build/runtime-cjs/public/tests/test.js +27 -2
- package/build/runtime-cjs/public/types.d.ts +8 -0
- package/build/runtime-esm/cache/cache.d.ts +10 -8
- package/build/runtime-esm/cache/cache.js +5 -11
- package/build/runtime-esm/cache/gc.d.ts +1 -1
- package/build/runtime-esm/cache/lists.d.ts +3 -2
- package/build/runtime-esm/cache/lists.js +5 -2
- package/build/runtime-esm/cache/schema.d.ts +2 -2
- package/build/runtime-esm/cache/stuff.d.ts +2 -2
- package/build/runtime-esm/cache/subscription.d.ts +19 -11
- package/build/runtime-esm/cache/subscription.js +95 -56
- package/build/runtime-esm/client/documentStore.d.ts +87 -0
- package/build/runtime-esm/client/documentStore.js +336 -0
- package/build/runtime-esm/client/index.d.ts +25 -0
- package/build/runtime-esm/client/index.js +58 -0
- package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
- package/build/runtime-esm/client/plugins/cache.js +69 -0
- package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-esm/client/plugins/fetch.js +151 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-esm/client/plugins/fetchParams.js +16 -0
- package/build/runtime-esm/client/plugins/index.d.ts +7 -0
- package/build/runtime-esm/client/plugins/index.js +7 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.js +5 -0
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-esm/client/plugins/mutation.js +56 -0
- package/build/runtime-esm/client/plugins/query.d.ts +2 -0
- package/build/runtime-esm/client/plugins/query.js +53 -0
- package/build/runtime-esm/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-esm/client/plugins/subscription.js +74 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-esm/client/plugins/throwOnError.js +23 -0
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-esm/client/utils/documentPlugins.js +32 -0
- package/build/runtime-esm/client/utils/index.d.ts +1 -0
- package/build/runtime-esm/client/utils/index.js +1 -0
- package/build/runtime-esm/generated.d.ts +1 -0
- package/build/runtime-esm/imports/config.d.ts +3 -0
- package/build/runtime-esm/imports/config.js +4 -0
- package/build/runtime-esm/index.d.ts +3 -2
- package/build/runtime-esm/index.js +1 -0
- package/build/runtime-esm/lib/config.d.ts +26 -25
- package/build/runtime-esm/lib/config.js +5 -4
- package/build/runtime-esm/lib/index.d.ts +1 -2
- package/build/runtime-esm/lib/index.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +6 -5
- package/build/runtime-esm/lib/scalars.js +20 -24
- package/build/runtime-esm/lib/selection.d.ts +1 -1
- package/build/runtime-esm/lib/store.d.ts +19 -0
- package/build/runtime-esm/lib/store.js +57 -0
- package/build/runtime-esm/lib/types.d.ts +22 -9
- package/build/runtime-esm/public/cache.d.ts +20 -7
- package/build/runtime-esm/public/cache.js +28 -30
- package/build/runtime-esm/public/list.d.ts +2 -2
- package/build/runtime-esm/public/list.js +6 -28
- package/build/runtime-esm/public/record.d.ts +18 -18
- package/build/runtime-esm/public/record.js +22 -185
- package/build/runtime-esm/public/tests/test.d.ts +44 -1
- package/build/runtime-esm/public/tests/test.js +26 -1
- package/build/runtime-esm/public/types.d.ts +8 -0
- package/build/test/index.d.ts +4 -3
- package/build/test-cjs/index.js +1334 -2766
- package/build/test-esm/index.js +1334 -2766
- package/build/vite/ast.d.ts +1 -1
- package/build/vite/houdini.d.ts +1 -1
- package/build/vite/imports.d.ts +3 -3
- package/build/vite/index.d.ts +1 -1
- package/build/vite/schema.d.ts +1 -1
- package/build/vite-cjs/index.js +1395 -2821
- package/build/vite-esm/index.js +1395 -2821
- package/package.json +1 -1
- package/build/runtime/lib/errors.d.ts +0 -3
- package/build/runtime/lib/network.d.ts +0 -79
- package/build/runtime/lib/networkUtils.d.ts +0 -8
- package/build/runtime-cjs/lib/errors.d.ts +0 -3
- package/build/runtime-cjs/lib/network.d.ts +0 -79
- package/build/runtime-cjs/lib/network.js +0 -200
- package/build/runtime-cjs/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/errors.d.ts +0 -3
- package/build/runtime-esm/lib/errors.js +0 -11
- package/build/runtime-esm/lib/network.d.ts +0 -79
- package/build/runtime-esm/lib/network.js +0 -170
- package/build/runtime-esm/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/networkUtils.js +0 -60
package/package.json
CHANGED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../../houdini.d.ts" />
|
|
2
|
-
import type { ConfigFile } from './config';
|
|
3
|
-
import { CachePolicy, GraphQLObject, MutationArtifact, QueryArtifact, FetchQueryResult, RequestPayload, RequestPayloadMagic } from './types';
|
|
4
|
-
export declare class HoudiniClient {
|
|
5
|
-
private fetchFn;
|
|
6
|
-
socket: SubscriptionHandler | null | undefined;
|
|
7
|
-
constructor(requestHandler: RequestHandler<any>, subscriptionHandler?: SubscriptionHandler | null);
|
|
8
|
-
handleMultipart(params: FetchParams, args: Parameters<FetchContext['fetch']>): Parameters<FetchContext['fetch']> | undefined;
|
|
9
|
-
sendRequest<_Data>(ctx: FetchContext, params: FetchParams): Promise<RequestPayloadMagic<_Data>>;
|
|
10
|
-
}
|
|
11
|
-
export declare class Environment extends HoudiniClient {
|
|
12
|
-
constructor(...args: ConstructorParameters<typeof HoudiniClient>);
|
|
13
|
-
}
|
|
14
|
-
export type SubscriptionHandler = {
|
|
15
|
-
subscribe: (payload: {
|
|
16
|
-
query: string;
|
|
17
|
-
variables?: {};
|
|
18
|
-
}, handlers: {
|
|
19
|
-
next: (payload: {
|
|
20
|
-
data?: {};
|
|
21
|
-
errors?: readonly {
|
|
22
|
-
message: string;
|
|
23
|
-
}[];
|
|
24
|
-
}) => void;
|
|
25
|
-
error: (data: {}) => void;
|
|
26
|
-
complete: () => void;
|
|
27
|
-
}) => () => void;
|
|
28
|
-
};
|
|
29
|
-
export type FetchParams = {
|
|
30
|
-
text: string;
|
|
31
|
-
hash: string;
|
|
32
|
-
variables: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export type FetchContext = {
|
|
37
|
-
fetch: typeof window.fetch;
|
|
38
|
-
metadata?: App.Metadata | null;
|
|
39
|
-
session: App.Session | null;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* ## Tip 👇
|
|
43
|
-
*
|
|
44
|
-
* To define types for your metadata, create a file `src/app.d.ts` containing the followingI:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* declare namespace App { *
|
|
48
|
-
* interface Metadata {}
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export type RequestHandlerArgs = FetchContext & FetchParams & {
|
|
54
|
-
session?: App.Session;
|
|
55
|
-
};
|
|
56
|
-
export type RequestHandler<_Data = any> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
57
|
-
export declare function executeQuery<_Data extends GraphQLObject, _Input extends {}>({ client, artifact, variables, session, setFetching, cached, fetch, metadata, }: {
|
|
58
|
-
client: HoudiniClient;
|
|
59
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
60
|
-
variables: _Input;
|
|
61
|
-
session: any;
|
|
62
|
-
setFetching: (fetching: boolean) => void;
|
|
63
|
-
cached: boolean;
|
|
64
|
-
config: ConfigFile;
|
|
65
|
-
fetch?: typeof globalThis.fetch;
|
|
66
|
-
metadata?: {};
|
|
67
|
-
}): Promise<{
|
|
68
|
-
result: RequestPayload;
|
|
69
|
-
partial: boolean;
|
|
70
|
-
}>;
|
|
71
|
-
export declare function fetchQuery<_Data extends GraphQLObject, _Input extends {}>({ client, context, artifact, variables, setFetching, cached, policy, }: {
|
|
72
|
-
client: HoudiniClient;
|
|
73
|
-
context: FetchContext;
|
|
74
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
75
|
-
variables: _Input;
|
|
76
|
-
setFetching: (fetching: boolean) => void;
|
|
77
|
-
cached?: boolean;
|
|
78
|
-
policy?: CachePolicy;
|
|
79
|
-
}): Promise<FetchQueryResult<_Data>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function isExtractableFile(value: any): value is ExtractableFile;
|
|
2
|
-
type ExtractableFile = File | Blob;
|
|
3
|
-
/** @typedef {import("./isExtractableFile.mjs").default} isExtractableFile */
|
|
4
|
-
export declare function extractFiles(value: any): {
|
|
5
|
-
clone: any;
|
|
6
|
-
files: Map<any, any>;
|
|
7
|
-
};
|
|
8
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../../houdini.d.ts" />
|
|
2
|
-
import type { ConfigFile } from './config';
|
|
3
|
-
import { CachePolicy, GraphQLObject, MutationArtifact, QueryArtifact, FetchQueryResult, RequestPayload, RequestPayloadMagic } from './types';
|
|
4
|
-
export declare class HoudiniClient {
|
|
5
|
-
private fetchFn;
|
|
6
|
-
socket: SubscriptionHandler | null | undefined;
|
|
7
|
-
constructor(requestHandler: RequestHandler<any>, subscriptionHandler?: SubscriptionHandler | null);
|
|
8
|
-
handleMultipart(params: FetchParams, args: Parameters<FetchContext['fetch']>): Parameters<FetchContext['fetch']> | undefined;
|
|
9
|
-
sendRequest<_Data>(ctx: FetchContext, params: FetchParams): Promise<RequestPayloadMagic<_Data>>;
|
|
10
|
-
}
|
|
11
|
-
export declare class Environment extends HoudiniClient {
|
|
12
|
-
constructor(...args: ConstructorParameters<typeof HoudiniClient>);
|
|
13
|
-
}
|
|
14
|
-
export type SubscriptionHandler = {
|
|
15
|
-
subscribe: (payload: {
|
|
16
|
-
query: string;
|
|
17
|
-
variables?: {};
|
|
18
|
-
}, handlers: {
|
|
19
|
-
next: (payload: {
|
|
20
|
-
data?: {};
|
|
21
|
-
errors?: readonly {
|
|
22
|
-
message: string;
|
|
23
|
-
}[];
|
|
24
|
-
}) => void;
|
|
25
|
-
error: (data: {}) => void;
|
|
26
|
-
complete: () => void;
|
|
27
|
-
}) => () => void;
|
|
28
|
-
};
|
|
29
|
-
export type FetchParams = {
|
|
30
|
-
text: string;
|
|
31
|
-
hash: string;
|
|
32
|
-
variables: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export type FetchContext = {
|
|
37
|
-
fetch: typeof window.fetch;
|
|
38
|
-
metadata?: App.Metadata | null;
|
|
39
|
-
session: App.Session | null;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* ## Tip 👇
|
|
43
|
-
*
|
|
44
|
-
* To define types for your metadata, create a file `src/app.d.ts` containing the followingI:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* declare namespace App { *
|
|
48
|
-
* interface Metadata {}
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export type RequestHandlerArgs = FetchContext & FetchParams & {
|
|
54
|
-
session?: App.Session;
|
|
55
|
-
};
|
|
56
|
-
export type RequestHandler<_Data = any> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
57
|
-
export declare function executeQuery<_Data extends GraphQLObject, _Input extends {}>({ client, artifact, variables, session, setFetching, cached, fetch, metadata, }: {
|
|
58
|
-
client: HoudiniClient;
|
|
59
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
60
|
-
variables: _Input;
|
|
61
|
-
session: any;
|
|
62
|
-
setFetching: (fetching: boolean) => void;
|
|
63
|
-
cached: boolean;
|
|
64
|
-
config: ConfigFile;
|
|
65
|
-
fetch?: typeof globalThis.fetch;
|
|
66
|
-
metadata?: {};
|
|
67
|
-
}): Promise<{
|
|
68
|
-
result: RequestPayload;
|
|
69
|
-
partial: boolean;
|
|
70
|
-
}>;
|
|
71
|
-
export declare function fetchQuery<_Data extends GraphQLObject, _Input extends {}>({ client, context, artifact, variables, setFetching, cached, policy, }: {
|
|
72
|
-
client: HoudiniClient;
|
|
73
|
-
context: FetchContext;
|
|
74
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
75
|
-
variables: _Input;
|
|
76
|
-
setFetching: (fetching: boolean) => void;
|
|
77
|
-
cached?: boolean;
|
|
78
|
-
policy?: CachePolicy;
|
|
79
|
-
}): Promise<FetchQueryResult<_Data>>;
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var network_exports = {};
|
|
26
|
-
__export(network_exports, {
|
|
27
|
-
Environment: () => Environment,
|
|
28
|
-
HoudiniClient: () => HoudiniClient,
|
|
29
|
-
executeQuery: () => executeQuery,
|
|
30
|
-
fetchQuery: () => fetchQuery
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(network_exports);
|
|
33
|
-
var import_cache = __toESM(require("../cache"), 1);
|
|
34
|
-
var log = __toESM(require("./log"), 1);
|
|
35
|
-
var import_networkUtils = require("./networkUtils");
|
|
36
|
-
var import_types = require("./types");
|
|
37
|
-
class HoudiniClient {
|
|
38
|
-
fetchFn;
|
|
39
|
-
socket;
|
|
40
|
-
constructor(requestHandler, subscriptionHandler) {
|
|
41
|
-
this.fetchFn = requestHandler;
|
|
42
|
-
this.socket = subscriptionHandler;
|
|
43
|
-
}
|
|
44
|
-
handleMultipart(params, args) {
|
|
45
|
-
const { clone, files } = (0, import_networkUtils.extractFiles)({
|
|
46
|
-
query: params.text,
|
|
47
|
-
variables: params.variables
|
|
48
|
-
});
|
|
49
|
-
if (files.size) {
|
|
50
|
-
const [url, req] = args;
|
|
51
|
-
let headers = {};
|
|
52
|
-
if (req?.headers) {
|
|
53
|
-
const filtered = Object.entries(req?.headers).filter(([key, value]) => {
|
|
54
|
-
return !(key.toLowerCase() == "content-type" && value.toLowerCase() == "application/json");
|
|
55
|
-
});
|
|
56
|
-
headers = Object.fromEntries(filtered);
|
|
57
|
-
}
|
|
58
|
-
const form = new FormData();
|
|
59
|
-
const operationJSON = JSON.stringify(clone);
|
|
60
|
-
form.set("operations", operationJSON);
|
|
61
|
-
const map = {};
|
|
62
|
-
let i = 0;
|
|
63
|
-
files.forEach((paths) => {
|
|
64
|
-
map[++i] = paths;
|
|
65
|
-
});
|
|
66
|
-
form.set("map", JSON.stringify(map));
|
|
67
|
-
i = 0;
|
|
68
|
-
files.forEach((paths, file) => {
|
|
69
|
-
form.set(`${++i}`, file, file.name);
|
|
70
|
-
});
|
|
71
|
-
return [url, { ...req, headers, body: form }];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async sendRequest(ctx, params) {
|
|
75
|
-
let url = "";
|
|
76
|
-
const result = await this.fetchFn({
|
|
77
|
-
fetch: async (...args) => {
|
|
78
|
-
const newArgs = this.handleMultipart(params, args);
|
|
79
|
-
const response = await ctx.fetch(...newArgs || args);
|
|
80
|
-
if (response.url) {
|
|
81
|
-
url = response.url;
|
|
82
|
-
}
|
|
83
|
-
return response;
|
|
84
|
-
},
|
|
85
|
-
...params,
|
|
86
|
-
metadata: ctx.metadata,
|
|
87
|
-
session: ctx.session || {}
|
|
88
|
-
});
|
|
89
|
-
return {
|
|
90
|
-
body: result,
|
|
91
|
-
ssr: !url
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
class Environment extends HoudiniClient {
|
|
96
|
-
constructor(...args) {
|
|
97
|
-
super(...args);
|
|
98
|
-
log.info(
|
|
99
|
-
`${log.red("\u26A0\uFE0F Environment has been renamed to HoudiniClient. \u26A0\uFE0F")}
|
|
100
|
-
You should update your client to look something like the following:
|
|
101
|
-
|
|
102
|
-
import { HoudiniClient } from '$houdini/runtime'
|
|
103
|
-
|
|
104
|
-
export default new HoudiniClient(fetchQuery)
|
|
105
|
-
`
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async function executeQuery({
|
|
110
|
-
client,
|
|
111
|
-
artifact,
|
|
112
|
-
variables,
|
|
113
|
-
session,
|
|
114
|
-
setFetching,
|
|
115
|
-
cached,
|
|
116
|
-
fetch,
|
|
117
|
-
metadata
|
|
118
|
-
}) {
|
|
119
|
-
const { result: res, partial } = await fetchQuery({
|
|
120
|
-
client,
|
|
121
|
-
context: {
|
|
122
|
-
fetch: fetch ?? globalThis.fetch.bind(globalThis),
|
|
123
|
-
metadata,
|
|
124
|
-
session
|
|
125
|
-
},
|
|
126
|
-
artifact,
|
|
127
|
-
setFetching,
|
|
128
|
-
variables,
|
|
129
|
-
cached
|
|
130
|
-
});
|
|
131
|
-
if (res.errors && res.errors.length > 0) {
|
|
132
|
-
throw res.errors;
|
|
133
|
-
}
|
|
134
|
-
if (!res.data) {
|
|
135
|
-
throw new Error("Encountered empty data response in payload");
|
|
136
|
-
}
|
|
137
|
-
return { result: res, partial };
|
|
138
|
-
}
|
|
139
|
-
async function fetchQuery({
|
|
140
|
-
client,
|
|
141
|
-
context,
|
|
142
|
-
artifact,
|
|
143
|
-
variables,
|
|
144
|
-
setFetching,
|
|
145
|
-
cached = true,
|
|
146
|
-
policy
|
|
147
|
-
}) {
|
|
148
|
-
if (!client) {
|
|
149
|
-
throw new Error("could not find houdini environment");
|
|
150
|
-
}
|
|
151
|
-
if (cached && artifact.kind === "HoudiniQuery") {
|
|
152
|
-
if (!policy) {
|
|
153
|
-
policy = artifact.policy;
|
|
154
|
-
}
|
|
155
|
-
if (policy !== import_types.CachePolicy.NetworkOnly) {
|
|
156
|
-
const value = import_cache.default.read({ selection: artifact.selection, variables });
|
|
157
|
-
const allowed = !value.partial || artifact.partial;
|
|
158
|
-
if (value.data !== null && allowed) {
|
|
159
|
-
return {
|
|
160
|
-
result: {
|
|
161
|
-
data: value.data,
|
|
162
|
-
errors: []
|
|
163
|
-
},
|
|
164
|
-
source: import_types.DataSource.Cache,
|
|
165
|
-
partial: value.partial
|
|
166
|
-
};
|
|
167
|
-
} else if (policy === import_types.CachePolicy.CacheOnly) {
|
|
168
|
-
return {
|
|
169
|
-
result: {
|
|
170
|
-
data: null,
|
|
171
|
-
errors: []
|
|
172
|
-
},
|
|
173
|
-
source: import_types.DataSource.Cache,
|
|
174
|
-
partial: false
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
setTimeout(() => {
|
|
180
|
-
import_cache.default._internal_unstable.collectGarbage();
|
|
181
|
-
}, 0);
|
|
182
|
-
setFetching(true);
|
|
183
|
-
const result = await client.sendRequest(context, {
|
|
184
|
-
text: artifact.raw,
|
|
185
|
-
hash: artifact.hash,
|
|
186
|
-
variables
|
|
187
|
-
});
|
|
188
|
-
return {
|
|
189
|
-
result: result.body,
|
|
190
|
-
source: result.ssr ? import_types.DataSource.Ssr : import_types.DataSource.Network,
|
|
191
|
-
partial: false
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
-
0 && (module.exports = {
|
|
196
|
-
Environment,
|
|
197
|
-
HoudiniClient,
|
|
198
|
-
executeQuery,
|
|
199
|
-
fetchQuery
|
|
200
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function isExtractableFile(value: any): value is ExtractableFile;
|
|
2
|
-
type ExtractableFile = File | Blob;
|
|
3
|
-
/** @typedef {import("./isExtractableFile.mjs").default} isExtractableFile */
|
|
4
|
-
export declare function extractFiles(value: any): {
|
|
5
|
-
clone: any;
|
|
6
|
-
files: Map<any, any>;
|
|
7
|
-
};
|
|
8
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../../houdini.d.ts" />
|
|
2
|
-
import type { ConfigFile } from './config';
|
|
3
|
-
import { CachePolicy, GraphQLObject, MutationArtifact, QueryArtifact, FetchQueryResult, RequestPayload, RequestPayloadMagic } from './types';
|
|
4
|
-
export declare class HoudiniClient {
|
|
5
|
-
private fetchFn;
|
|
6
|
-
socket: SubscriptionHandler | null | undefined;
|
|
7
|
-
constructor(requestHandler: RequestHandler<any>, subscriptionHandler?: SubscriptionHandler | null);
|
|
8
|
-
handleMultipart(params: FetchParams, args: Parameters<FetchContext['fetch']>): Parameters<FetchContext['fetch']> | undefined;
|
|
9
|
-
sendRequest<_Data>(ctx: FetchContext, params: FetchParams): Promise<RequestPayloadMagic<_Data>>;
|
|
10
|
-
}
|
|
11
|
-
export declare class Environment extends HoudiniClient {
|
|
12
|
-
constructor(...args: ConstructorParameters<typeof HoudiniClient>);
|
|
13
|
-
}
|
|
14
|
-
export type SubscriptionHandler = {
|
|
15
|
-
subscribe: (payload: {
|
|
16
|
-
query: string;
|
|
17
|
-
variables?: {};
|
|
18
|
-
}, handlers: {
|
|
19
|
-
next: (payload: {
|
|
20
|
-
data?: {};
|
|
21
|
-
errors?: readonly {
|
|
22
|
-
message: string;
|
|
23
|
-
}[];
|
|
24
|
-
}) => void;
|
|
25
|
-
error: (data: {}) => void;
|
|
26
|
-
complete: () => void;
|
|
27
|
-
}) => () => void;
|
|
28
|
-
};
|
|
29
|
-
export type FetchParams = {
|
|
30
|
-
text: string;
|
|
31
|
-
hash: string;
|
|
32
|
-
variables: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export type FetchContext = {
|
|
37
|
-
fetch: typeof window.fetch;
|
|
38
|
-
metadata?: App.Metadata | null;
|
|
39
|
-
session: App.Session | null;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* ## Tip 👇
|
|
43
|
-
*
|
|
44
|
-
* To define types for your metadata, create a file `src/app.d.ts` containing the followingI:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* declare namespace App { *
|
|
48
|
-
* interface Metadata {}
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export type RequestHandlerArgs = FetchContext & FetchParams & {
|
|
54
|
-
session?: App.Session;
|
|
55
|
-
};
|
|
56
|
-
export type RequestHandler<_Data = any> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
57
|
-
export declare function executeQuery<_Data extends GraphQLObject, _Input extends {}>({ client, artifact, variables, session, setFetching, cached, fetch, metadata, }: {
|
|
58
|
-
client: HoudiniClient;
|
|
59
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
60
|
-
variables: _Input;
|
|
61
|
-
session: any;
|
|
62
|
-
setFetching: (fetching: boolean) => void;
|
|
63
|
-
cached: boolean;
|
|
64
|
-
config: ConfigFile;
|
|
65
|
-
fetch?: typeof globalThis.fetch;
|
|
66
|
-
metadata?: {};
|
|
67
|
-
}): Promise<{
|
|
68
|
-
result: RequestPayload;
|
|
69
|
-
partial: boolean;
|
|
70
|
-
}>;
|
|
71
|
-
export declare function fetchQuery<_Data extends GraphQLObject, _Input extends {}>({ client, context, artifact, variables, setFetching, cached, policy, }: {
|
|
72
|
-
client: HoudiniClient;
|
|
73
|
-
context: FetchContext;
|
|
74
|
-
artifact: QueryArtifact | MutationArtifact;
|
|
75
|
-
variables: _Input;
|
|
76
|
-
setFetching: (fetching: boolean) => void;
|
|
77
|
-
cached?: boolean;
|
|
78
|
-
policy?: CachePolicy;
|
|
79
|
-
}): Promise<FetchQueryResult<_Data>>;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import cache from "../cache";
|
|
2
|
-
import * as log from "./log";
|
|
3
|
-
import { extractFiles } from "./networkUtils";
|
|
4
|
-
import {
|
|
5
|
-
CachePolicy,
|
|
6
|
-
DataSource
|
|
7
|
-
} from "./types";
|
|
8
|
-
class HoudiniClient {
|
|
9
|
-
fetchFn;
|
|
10
|
-
socket;
|
|
11
|
-
constructor(requestHandler, subscriptionHandler) {
|
|
12
|
-
this.fetchFn = requestHandler;
|
|
13
|
-
this.socket = subscriptionHandler;
|
|
14
|
-
}
|
|
15
|
-
handleMultipart(params, args) {
|
|
16
|
-
const { clone, files } = extractFiles({
|
|
17
|
-
query: params.text,
|
|
18
|
-
variables: params.variables
|
|
19
|
-
});
|
|
20
|
-
if (files.size) {
|
|
21
|
-
const [url, req] = args;
|
|
22
|
-
let headers = {};
|
|
23
|
-
if (req?.headers) {
|
|
24
|
-
const filtered = Object.entries(req?.headers).filter(([key, value]) => {
|
|
25
|
-
return !(key.toLowerCase() == "content-type" && value.toLowerCase() == "application/json");
|
|
26
|
-
});
|
|
27
|
-
headers = Object.fromEntries(filtered);
|
|
28
|
-
}
|
|
29
|
-
const form = new FormData();
|
|
30
|
-
const operationJSON = JSON.stringify(clone);
|
|
31
|
-
form.set("operations", operationJSON);
|
|
32
|
-
const map = {};
|
|
33
|
-
let i = 0;
|
|
34
|
-
files.forEach((paths) => {
|
|
35
|
-
map[++i] = paths;
|
|
36
|
-
});
|
|
37
|
-
form.set("map", JSON.stringify(map));
|
|
38
|
-
i = 0;
|
|
39
|
-
files.forEach((paths, file) => {
|
|
40
|
-
form.set(`${++i}`, file, file.name);
|
|
41
|
-
});
|
|
42
|
-
return [url, { ...req, headers, body: form }];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async sendRequest(ctx, params) {
|
|
46
|
-
let url = "";
|
|
47
|
-
const result = await this.fetchFn({
|
|
48
|
-
fetch: async (...args) => {
|
|
49
|
-
const newArgs = this.handleMultipart(params, args);
|
|
50
|
-
const response = await ctx.fetch(...newArgs || args);
|
|
51
|
-
if (response.url) {
|
|
52
|
-
url = response.url;
|
|
53
|
-
}
|
|
54
|
-
return response;
|
|
55
|
-
},
|
|
56
|
-
...params,
|
|
57
|
-
metadata: ctx.metadata,
|
|
58
|
-
session: ctx.session || {}
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
body: result,
|
|
62
|
-
ssr: !url
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class Environment extends HoudiniClient {
|
|
67
|
-
constructor(...args) {
|
|
68
|
-
super(...args);
|
|
69
|
-
log.info(
|
|
70
|
-
`${log.red("\u26A0\uFE0F Environment has been renamed to HoudiniClient. \u26A0\uFE0F")}
|
|
71
|
-
You should update your client to look something like the following:
|
|
72
|
-
|
|
73
|
-
import { HoudiniClient } from '$houdini/runtime'
|
|
74
|
-
|
|
75
|
-
export default new HoudiniClient(fetchQuery)
|
|
76
|
-
`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async function executeQuery({
|
|
81
|
-
client,
|
|
82
|
-
artifact,
|
|
83
|
-
variables,
|
|
84
|
-
session,
|
|
85
|
-
setFetching,
|
|
86
|
-
cached,
|
|
87
|
-
fetch,
|
|
88
|
-
metadata
|
|
89
|
-
}) {
|
|
90
|
-
const { result: res, partial } = await fetchQuery({
|
|
91
|
-
client,
|
|
92
|
-
context: {
|
|
93
|
-
fetch: fetch ?? globalThis.fetch.bind(globalThis),
|
|
94
|
-
metadata,
|
|
95
|
-
session
|
|
96
|
-
},
|
|
97
|
-
artifact,
|
|
98
|
-
setFetching,
|
|
99
|
-
variables,
|
|
100
|
-
cached
|
|
101
|
-
});
|
|
102
|
-
if (res.errors && res.errors.length > 0) {
|
|
103
|
-
throw res.errors;
|
|
104
|
-
}
|
|
105
|
-
if (!res.data) {
|
|
106
|
-
throw new Error("Encountered empty data response in payload");
|
|
107
|
-
}
|
|
108
|
-
return { result: res, partial };
|
|
109
|
-
}
|
|
110
|
-
async function fetchQuery({
|
|
111
|
-
client,
|
|
112
|
-
context,
|
|
113
|
-
artifact,
|
|
114
|
-
variables,
|
|
115
|
-
setFetching,
|
|
116
|
-
cached = true,
|
|
117
|
-
policy
|
|
118
|
-
}) {
|
|
119
|
-
if (!client) {
|
|
120
|
-
throw new Error("could not find houdini environment");
|
|
121
|
-
}
|
|
122
|
-
if (cached && artifact.kind === "HoudiniQuery") {
|
|
123
|
-
if (!policy) {
|
|
124
|
-
policy = artifact.policy;
|
|
125
|
-
}
|
|
126
|
-
if (policy !== CachePolicy.NetworkOnly) {
|
|
127
|
-
const value = cache.read({ selection: artifact.selection, variables });
|
|
128
|
-
const allowed = !value.partial || artifact.partial;
|
|
129
|
-
if (value.data !== null && allowed) {
|
|
130
|
-
return {
|
|
131
|
-
result: {
|
|
132
|
-
data: value.data,
|
|
133
|
-
errors: []
|
|
134
|
-
},
|
|
135
|
-
source: DataSource.Cache,
|
|
136
|
-
partial: value.partial
|
|
137
|
-
};
|
|
138
|
-
} else if (policy === CachePolicy.CacheOnly) {
|
|
139
|
-
return {
|
|
140
|
-
result: {
|
|
141
|
-
data: null,
|
|
142
|
-
errors: []
|
|
143
|
-
},
|
|
144
|
-
source: DataSource.Cache,
|
|
145
|
-
partial: false
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
setTimeout(() => {
|
|
151
|
-
cache._internal_unstable.collectGarbage();
|
|
152
|
-
}, 0);
|
|
153
|
-
setFetching(true);
|
|
154
|
-
const result = await client.sendRequest(context, {
|
|
155
|
-
text: artifact.raw,
|
|
156
|
-
hash: artifact.hash,
|
|
157
|
-
variables
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
result: result.body,
|
|
161
|
-
source: result.ssr ? DataSource.Ssr : DataSource.Network,
|
|
162
|
-
partial: false
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
export {
|
|
166
|
-
Environment,
|
|
167
|
-
HoudiniClient,
|
|
168
|
-
executeQuery,
|
|
169
|
-
fetchQuery
|
|
170
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function isExtractableFile(value: any): value is ExtractableFile;
|
|
2
|
-
type ExtractableFile = File | Blob;
|
|
3
|
-
/** @typedef {import("./isExtractableFile.mjs").default} isExtractableFile */
|
|
4
|
-
export declare function extractFiles(value: any): {
|
|
5
|
-
clone: any;
|
|
6
|
-
files: Map<any, any>;
|
|
7
|
-
};
|
|
8
|
-
export {};
|