houdini 1.0.0-next.8 → 1.0.0-next.9
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-cjs/index.js +50 -22
- package/build/cmd-esm/index.js +50 -22
- package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
- package/build/codegen/generators/typescript/types.d.ts +0 -1
- package/build/codegen-cjs/index.js +48 -20
- package/build/codegen-esm/index.js +48 -20
- package/build/runtime/client/index.d.ts +1 -1
- package/build/runtime/client/plugins/cache.d.ts +1 -1
- package/build/runtime/client/plugins/fetch.d.ts +1 -1
- package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime/client/plugins/mutation.d.ts +1 -1
- package/build/runtime/client/plugins/query.d.ts +1 -1
- package/build/runtime/client/plugins/subscription.d.ts +1 -1
- package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +1 -0
- package/build/runtime-cjs/client/documentStore.js +1 -1
- package/build/runtime-cjs/client/index.d.ts +1 -1
- package/build/runtime-cjs/client/index.js +13 -13
- package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/cache.js +3 -3
- package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetch.js +7 -7
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetchParams.js +3 -3
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/mutation.js +3 -3
- package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/query.js +3 -3
- package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/subscription.js +3 -3
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
- package/build/runtime-cjs/lib/types.d.ts +1 -0
- package/build/runtime-esm/client/documentStore.js +2 -2
- package/build/runtime-esm/client/index.d.ts +1 -1
- package/build/runtime-esm/client/index.js +10 -10
- package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
- package/build/runtime-esm/client/plugins/cache.js +2 -2
- package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetch.js +6 -6
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
- package/build/runtime-esm/client/plugins/mutation.js +2 -2
- package/build/runtime-esm/client/plugins/query.d.ts +1 -1
- package/build/runtime-esm/client/plugins/query.js +2 -2
- package/build/runtime-esm/client/plugins/subscription.d.ts +1 -1
- package/build/runtime-esm/client/plugins/subscription.js +2 -2
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
- package/build/runtime-esm/lib/types.d.ts +1 -0
- package/build/test-cjs/index.js +48 -20
- package/build/test-esm/index.js +48 -20
- package/build/vite-cjs/index.js +48 -20
- package/build/vite-esm/index.js +48 -20
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { flatten } from "../lib/flatten";
|
|
2
2
|
import { DocumentStore } from "./documentStore";
|
|
3
3
|
import {
|
|
4
|
-
fetchParamsPlugin,
|
|
5
|
-
fetchPlugin,
|
|
6
|
-
mutationPlugin,
|
|
7
|
-
queryPlugin,
|
|
8
|
-
throwOnErrorPlugin
|
|
4
|
+
fetchParams as fetchParamsPlugin,
|
|
5
|
+
fetch as fetchPlugin,
|
|
6
|
+
mutation as mutationPlugin,
|
|
7
|
+
query as queryPlugin,
|
|
8
|
+
throwOnError as throwOnErrorPlugin
|
|
9
9
|
} from "./plugins";
|
|
10
10
|
import pluginsFromPlugins from "./plugins/injectedPlugins";
|
|
11
11
|
import { DocumentStore as DocumentStore2 } from "./documentStore";
|
|
12
|
-
import {
|
|
12
|
+
import { fetch, mutation, query, subscription } from "./plugins";
|
|
13
13
|
class HoudiniClient {
|
|
14
14
|
url;
|
|
15
15
|
#plugins;
|
|
@@ -76,8 +76,8 @@ export {
|
|
|
76
76
|
DocumentStore2 as DocumentStore,
|
|
77
77
|
HoudiniClient,
|
|
78
78
|
createPluginHooks,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
fetch,
|
|
80
|
+
mutation,
|
|
81
|
+
query,
|
|
82
|
+
subscription
|
|
83
83
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cache from '../../cache';
|
|
2
2
|
import type { Cache } from '../../cache/cache';
|
|
3
3
|
import type { ClientPlugin } from '../documentStore';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, }: {
|
|
5
5
|
enabled: boolean;
|
|
6
6
|
setFetching: (val: boolean) => void;
|
|
7
7
|
cache?: Cache | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cache from "../../cache";
|
|
2
2
|
import { ArtifactKind, CachePolicy, DataSource } from "../../lib/types";
|
|
3
|
-
const
|
|
3
|
+
const cachePolicy = ({
|
|
4
4
|
enabled,
|
|
5
5
|
setFetching,
|
|
6
6
|
cache: localCache = cache
|
|
@@ -67,5 +67,5 @@ const cachePolicyPlugin = ({
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
export {
|
|
70
|
-
|
|
70
|
+
cachePolicy
|
|
71
71
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestPayload } from '../../lib/types';
|
|
2
2
|
import type { ClientPlugin } from '../documentStore';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const fetch: (target?: RequestHandler | string) => ClientPlugin;
|
|
4
4
|
export type FetchContext = {
|
|
5
5
|
fetch: typeof globalThis.fetch;
|
|
6
6
|
metadata?: App.Metadata | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DataSource } from "../../lib/types";
|
|
2
|
-
const
|
|
2
|
+
const fetch = (target) => {
|
|
3
3
|
return () => {
|
|
4
4
|
return {
|
|
5
5
|
async network(ctx, { client, resolve, marshalVariables }) {
|
|
6
|
-
const
|
|
6
|
+
const fetch2 = ctx.fetch ?? globalThis.fetch;
|
|
7
7
|
const fetchParams = {
|
|
8
8
|
text: ctx.text,
|
|
9
9
|
hash: ctx.hash,
|
|
@@ -20,7 +20,7 @@ const fetchPlugin = (target) => {
|
|
|
20
20
|
const result = await fetchFn({
|
|
21
21
|
fetch: (url, args) => {
|
|
22
22
|
const newArgs = handleMultipart(fetchParams, args) ?? args;
|
|
23
|
-
return
|
|
23
|
+
return fetch2(url, newArgs);
|
|
24
24
|
},
|
|
25
25
|
metadata: ctx.metadata,
|
|
26
26
|
session: ctx.session || {},
|
|
@@ -45,8 +45,8 @@ const defaultFetch = (url, params) => {
|
|
|
45
45
|
"Could not find configured client url. Please specify one in your houdini.config.js file."
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
return async ({ fetch, text, variables }) => {
|
|
49
|
-
const result = await
|
|
48
|
+
return async ({ fetch: fetch2, text, variables }) => {
|
|
49
|
+
const result = await fetch2(url, {
|
|
50
50
|
method: "POST",
|
|
51
51
|
body: JSON.stringify({ query: text, variables }),
|
|
52
52
|
...params,
|
|
@@ -147,6 +147,6 @@ function isPlainObject(value) {
|
|
|
147
147
|
}
|
|
148
148
|
export {
|
|
149
149
|
extractFiles,
|
|
150
|
-
|
|
150
|
+
fetch,
|
|
151
151
|
isExtractableFile
|
|
152
152
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DocumentArtifact } from '../../lib/types';
|
|
2
2
|
import type { ClientPlugin, ClientPluginContext } from '../documentStore';
|
|
3
3
|
export type FetchParamFn = (ctx: FetchParamsInput) => Required<ClientPluginContext>['fetchParams'];
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const fetchParams: (fn?: FetchParamFn) => ClientPlugin;
|
|
5
5
|
export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
|
|
6
6
|
text: string;
|
|
7
7
|
hash: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fetchParams = (fn = () => ({})) => () => ({
|
|
2
2
|
beforeNetwork(ctx, { next, marshalVariables }) {
|
|
3
3
|
next({
|
|
4
4
|
...ctx,
|
|
@@ -17,5 +17,5 @@ const fetchParamsPlugin = (fn = () => ({})) => () => ({
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
fetchParams
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const mutation: import("..").ClientPlugin;
|
|
@@ -2,7 +2,7 @@ import cache from "../../cache";
|
|
|
2
2
|
import { marshalSelection } from "../../lib/scalars";
|
|
3
3
|
import { ArtifactKind } from "../../lib/types";
|
|
4
4
|
import { documentPlugin } from "../utils";
|
|
5
|
-
const
|
|
5
|
+
const mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
6
6
|
return {
|
|
7
7
|
async start(ctx, { next, marshalVariables }) {
|
|
8
8
|
const layer = cache._internal_unstable.storage.createLayer(true);
|
|
@@ -52,5 +52,5 @@ const mutationPlugin = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
mutation
|
|
56
56
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ClientPlugin } from '../documentStore';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const query: ClientPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cache from "../../cache";
|
|
2
2
|
import { ArtifactKind, DataSource } from "../../lib/types";
|
|
3
3
|
import { documentPlugin } from "../utils";
|
|
4
|
-
const
|
|
4
|
+
const query = documentPlugin(ArtifactKind.Query, function() {
|
|
5
5
|
let subscriptionSpec = null;
|
|
6
6
|
let lastVariables = null;
|
|
7
7
|
let artifactName = "";
|
|
@@ -49,5 +49,5 @@ const queryPlugin = documentPlugin(ArtifactKind.Query, function() {
|
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
export {
|
|
52
|
-
|
|
52
|
+
query
|
|
53
53
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClientPluginContext } from '../documentStore';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
|
|
3
3
|
export type SubscriptionHandler = (ctx: ClientPluginContext) => {
|
|
4
4
|
subscribe: (payload: {
|
|
5
5
|
query: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepEquals } from "../../lib/deepEquals";
|
|
2
2
|
import { ArtifactKind, DataSource } from "../../lib/types";
|
|
3
3
|
import { documentPlugin } from "../utils";
|
|
4
|
-
function
|
|
4
|
+
function subscription(factory) {
|
|
5
5
|
return documentPlugin(ArtifactKind.Subscription, () => {
|
|
6
6
|
let clearSubscription = null;
|
|
7
7
|
let socketClient = null;
|
|
@@ -72,5 +72,5 @@ function subscriptionPlugin(factory) {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
subscription
|
|
76
76
|
};
|
|
@@ -4,4 +4,4 @@ export type ThrowOnErrorParams = {
|
|
|
4
4
|
operations: ('all' | 'query' | 'mutation' | 'subscription')[];
|
|
5
5
|
error?: (errors: NonNullable<QueryResult<any, any>['errors']>) => unknown;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const throwOnError: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArtifactKind } from "../../lib";
|
|
2
|
-
const
|
|
2
|
+
const throwOnError = ({ operations, error }) => () => {
|
|
3
3
|
const all = operations.includes("all");
|
|
4
4
|
const throwOnKind = (kind) => all || {
|
|
5
5
|
[ArtifactKind.Query]: operations.includes("query"),
|
|
@@ -19,5 +19,5 @@ const throwOnErrorPlugin = ({ operations, error }) => () => {
|
|
|
19
19
|
};
|
|
20
20
|
const defaultErrorFn = async (errors) => new Error(errors.map((error) => error.message).join(". ") + ".");
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
throwOnError
|
|
23
23
|
};
|
package/build/test-cjs/index.js
CHANGED
|
@@ -3347,7 +3347,7 @@ var require_definition = __commonJS({
|
|
|
3347
3347
|
exports.assertInterfaceType = assertInterfaceType;
|
|
3348
3348
|
exports.isUnionType = isUnionType7;
|
|
3349
3349
|
exports.assertUnionType = assertUnionType;
|
|
3350
|
-
exports.isEnumType =
|
|
3350
|
+
exports.isEnumType = isEnumType6;
|
|
3351
3351
|
exports.assertEnumType = assertEnumType;
|
|
3352
3352
|
exports.isInputObjectType = isInputObjectType2;
|
|
3353
3353
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -3418,7 +3418,7 @@ var require_definition = __commonJS({
|
|
|
3418
3418
|
return Constructor;
|
|
3419
3419
|
}
|
|
3420
3420
|
function isType(type) {
|
|
3421
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3421
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isInputObjectType2(type) || isListType3(type) || isNonNullType6(type);
|
|
3422
3422
|
}
|
|
3423
3423
|
function assertType(type) {
|
|
3424
3424
|
if (!isType(type)) {
|
|
@@ -3462,11 +3462,11 @@ var require_definition = __commonJS({
|
|
|
3462
3462
|
}
|
|
3463
3463
|
return type;
|
|
3464
3464
|
}
|
|
3465
|
-
function
|
|
3465
|
+
function isEnumType6(type) {
|
|
3466
3466
|
return (0, _instanceOf.default)(type, GraphQLEnumType);
|
|
3467
3467
|
}
|
|
3468
3468
|
function assertEnumType(type) {
|
|
3469
|
-
if (!
|
|
3469
|
+
if (!isEnumType6(type)) {
|
|
3470
3470
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
3471
3471
|
}
|
|
3472
3472
|
return type;
|
|
@@ -3499,7 +3499,7 @@ var require_definition = __commonJS({
|
|
|
3499
3499
|
return type;
|
|
3500
3500
|
}
|
|
3501
3501
|
function isInputType(type) {
|
|
3502
|
-
return isScalarType7(type) ||
|
|
3502
|
+
return isScalarType7(type) || isEnumType6(type) || isInputObjectType2(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
3503
3503
|
}
|
|
3504
3504
|
function assertInputType(type) {
|
|
3505
3505
|
if (!isInputType(type)) {
|
|
@@ -3508,7 +3508,7 @@ var require_definition = __commonJS({
|
|
|
3508
3508
|
return type;
|
|
3509
3509
|
}
|
|
3510
3510
|
function isOutputType(type) {
|
|
3511
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3511
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
3512
3512
|
}
|
|
3513
3513
|
function assertOutputType(type) {
|
|
3514
3514
|
if (!isOutputType(type)) {
|
|
@@ -3517,7 +3517,7 @@ var require_definition = __commonJS({
|
|
|
3517
3517
|
return type;
|
|
3518
3518
|
}
|
|
3519
3519
|
function isLeafType(type) {
|
|
3520
|
-
return isScalarType7(type) ||
|
|
3520
|
+
return isScalarType7(type) || isEnumType6(type);
|
|
3521
3521
|
}
|
|
3522
3522
|
function assertLeafType(type) {
|
|
3523
3523
|
if (!isLeafType(type)) {
|
|
@@ -3605,7 +3605,7 @@ var require_definition = __commonJS({
|
|
|
3605
3605
|
}
|
|
3606
3606
|
}
|
|
3607
3607
|
function isNamedType(type) {
|
|
3608
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3608
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isInputObjectType2(type);
|
|
3609
3609
|
}
|
|
3610
3610
|
function assertNamedType(type) {
|
|
3611
3611
|
if (!isNamedType(type)) {
|
|
@@ -57678,11 +57678,13 @@ function scalarPropertyValue(config2, missingScalars, target) {
|
|
|
57678
57678
|
|
|
57679
57679
|
// src/codegen/generators/typescript/typeReference.ts
|
|
57680
57680
|
var AST8 = recast8.types.builders;
|
|
57681
|
-
function tsTypeReference(config2, missingScalars, definition) {
|
|
57681
|
+
function tsTypeReference(config2, missingScalars, definition, body) {
|
|
57682
57682
|
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
57683
57683
|
let result;
|
|
57684
57684
|
if (graphql14.isScalarType(type)) {
|
|
57685
57685
|
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57686
|
+
} else if (graphql14.isEnumType(type)) {
|
|
57687
|
+
result = enumReference(config2, body, type.name);
|
|
57686
57688
|
} else {
|
|
57687
57689
|
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
57688
57690
|
}
|
|
@@ -57697,6 +57699,19 @@ function tsTypeReference(config2, missingScalars, definition) {
|
|
|
57697
57699
|
}
|
|
57698
57700
|
return result;
|
|
57699
57701
|
}
|
|
57702
|
+
function enumReference(config2, body, name) {
|
|
57703
|
+
ensureImports({
|
|
57704
|
+
config: config2,
|
|
57705
|
+
body,
|
|
57706
|
+
import: ["ValueOf"],
|
|
57707
|
+
importKind: "type",
|
|
57708
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
57709
|
+
});
|
|
57710
|
+
return AST8.tsTypeReference(
|
|
57711
|
+
AST8.identifier("ValueOf"),
|
|
57712
|
+
AST8.tsTypeParameterInstantiation([AST8.tsTypeQuery(AST8.identifier(name))])
|
|
57713
|
+
);
|
|
57714
|
+
}
|
|
57700
57715
|
|
|
57701
57716
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
57702
57717
|
var AST9 = recast9.types.builders;
|
|
@@ -57728,7 +57743,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
57728
57743
|
members.push(
|
|
57729
57744
|
AST9.tsPropertySignature(
|
|
57730
57745
|
AST9.identifier(field.name),
|
|
57731
|
-
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
57746
|
+
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field, body)),
|
|
57732
57747
|
graphql15.isNullableType(field.type)
|
|
57733
57748
|
)
|
|
57734
57749
|
);
|
|
@@ -57759,6 +57774,13 @@ function inlineType({
|
|
|
57759
57774
|
if (graphql16.isScalarType(type)) {
|
|
57760
57775
|
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57761
57776
|
} else if (graphql16.isEnumType(type)) {
|
|
57777
|
+
ensureImports({
|
|
57778
|
+
config: config2,
|
|
57779
|
+
body,
|
|
57780
|
+
importKind: "type",
|
|
57781
|
+
import: ["ValueOf"],
|
|
57782
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
57783
|
+
});
|
|
57762
57784
|
if (!visitedTypes.has(type.name)) {
|
|
57763
57785
|
ensureImports({
|
|
57764
57786
|
config: config2,
|
|
@@ -57768,7 +57790,7 @@ function inlineType({
|
|
|
57768
57790
|
});
|
|
57769
57791
|
visitedTypes.add(type.name);
|
|
57770
57792
|
}
|
|
57771
|
-
result =
|
|
57793
|
+
result = enumReference(config2, body, type.name);
|
|
57772
57794
|
} else if (selections) {
|
|
57773
57795
|
const rootObj = type;
|
|
57774
57796
|
const inlineFragments = {};
|
|
@@ -58201,7 +58223,7 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
58201
58223
|
return AST11.tsPropertySignature(
|
|
58202
58224
|
AST11.identifier(definition2.variable.name.value),
|
|
58203
58225
|
AST11.tsTypeAnnotation(
|
|
58204
|
-
tsTypeReference(config2, missingScalars, definition2)
|
|
58226
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
58205
58227
|
),
|
|
58206
58228
|
definition2.type.kind !== "NonNullType"
|
|
58207
58229
|
);
|
|
@@ -58268,7 +58290,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
58268
58290
|
return AST11.tsPropertySignature(
|
|
58269
58291
|
AST11.identifier(definition2.variable.name.value),
|
|
58270
58292
|
AST11.tsTypeAnnotation(
|
|
58271
|
-
tsTypeReference(
|
|
58293
|
+
tsTypeReference(
|
|
58294
|
+
config2,
|
|
58295
|
+
missingScalars,
|
|
58296
|
+
definition2,
|
|
58297
|
+
body
|
|
58298
|
+
)
|
|
58272
58299
|
),
|
|
58273
58300
|
definition2.type.kind !== "NonNullType"
|
|
58274
58301
|
);
|
|
@@ -58361,7 +58388,7 @@ async function imperativeCacheTypef(config2, docs) {
|
|
|
58361
58388
|
),
|
|
58362
58389
|
AST12.tsPropertySignature(
|
|
58363
58390
|
AST12.identifier("lists"),
|
|
58364
|
-
AST12.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
58391
|
+
AST12.tsTypeAnnotation(listDefinitions(config2, body, docs))
|
|
58365
58392
|
),
|
|
58366
58393
|
AST12.tsPropertySignature(
|
|
58367
58394
|
AST12.identifier("queries"),
|
|
@@ -58470,7 +58497,7 @@ function typeDefinitions(config2, body, docs, returnType) {
|
|
|
58470
58497
|
const prop = AST12.tsPropertySignature(
|
|
58471
58498
|
AST12.identifier(arg.name),
|
|
58472
58499
|
AST12.tsTypeAnnotation(
|
|
58473
|
-
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
58500
|
+
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg, body)
|
|
58474
58501
|
)
|
|
58475
58502
|
);
|
|
58476
58503
|
const unwrapped2 = unwrapType(config2, arg.type);
|
|
@@ -58520,7 +58547,7 @@ function typeDefinitions(config2, body, docs, returnType) {
|
|
|
58520
58547
|
})
|
|
58521
58548
|
);
|
|
58522
58549
|
}
|
|
58523
|
-
function listDefinitions(config2, docs) {
|
|
58550
|
+
function listDefinitions(config2, body, docs) {
|
|
58524
58551
|
const lists = [];
|
|
58525
58552
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
58526
58553
|
for (const doc of docs) {
|
|
@@ -58577,7 +58604,8 @@ function listDefinitions(config2, docs) {
|
|
|
58577
58604
|
tsTypeReference(
|
|
58578
58605
|
config2,
|
|
58579
58606
|
/* @__PURE__ */ new Set(),
|
|
58580
|
-
arg
|
|
58607
|
+
arg,
|
|
58608
|
+
body
|
|
58581
58609
|
)
|
|
58582
58610
|
)
|
|
58583
58611
|
);
|
|
@@ -58771,9 +58799,9 @@ async function definitionsGenerator(config2) {
|
|
|
58771
58799
|
).code;
|
|
58772
58800
|
const typeDefinitions2 = enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map(
|
|
58773
58801
|
(definition) => `
|
|
58774
|
-
export
|
|
58775
|
-
${definition.values?.map((value) => ` ${value.name.value}
|
|
58776
|
-
}
|
|
58802
|
+
export const ${definition.name.value} = {
|
|
58803
|
+
${definition.values?.map((value) => ` ${value.name.value}: "${value.name.value}"`).join(",\n")}
|
|
58804
|
+
} as const
|
|
58777
58805
|
`
|
|
58778
58806
|
).join("");
|
|
58779
58807
|
const definitionsIndex = `
|
package/build/test-esm/index.js
CHANGED
|
@@ -3352,7 +3352,7 @@ var require_definition = __commonJS({
|
|
|
3352
3352
|
exports.assertInterfaceType = assertInterfaceType;
|
|
3353
3353
|
exports.isUnionType = isUnionType7;
|
|
3354
3354
|
exports.assertUnionType = assertUnionType;
|
|
3355
|
-
exports.isEnumType =
|
|
3355
|
+
exports.isEnumType = isEnumType6;
|
|
3356
3356
|
exports.assertEnumType = assertEnumType;
|
|
3357
3357
|
exports.isInputObjectType = isInputObjectType2;
|
|
3358
3358
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -3423,7 +3423,7 @@ var require_definition = __commonJS({
|
|
|
3423
3423
|
return Constructor;
|
|
3424
3424
|
}
|
|
3425
3425
|
function isType(type) {
|
|
3426
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3426
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isInputObjectType2(type) || isListType3(type) || isNonNullType6(type);
|
|
3427
3427
|
}
|
|
3428
3428
|
function assertType(type) {
|
|
3429
3429
|
if (!isType(type)) {
|
|
@@ -3467,11 +3467,11 @@ var require_definition = __commonJS({
|
|
|
3467
3467
|
}
|
|
3468
3468
|
return type;
|
|
3469
3469
|
}
|
|
3470
|
-
function
|
|
3470
|
+
function isEnumType6(type) {
|
|
3471
3471
|
return (0, _instanceOf.default)(type, GraphQLEnumType);
|
|
3472
3472
|
}
|
|
3473
3473
|
function assertEnumType(type) {
|
|
3474
|
-
if (!
|
|
3474
|
+
if (!isEnumType6(type)) {
|
|
3475
3475
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
3476
3476
|
}
|
|
3477
3477
|
return type;
|
|
@@ -3504,7 +3504,7 @@ var require_definition = __commonJS({
|
|
|
3504
3504
|
return type;
|
|
3505
3505
|
}
|
|
3506
3506
|
function isInputType(type) {
|
|
3507
|
-
return isScalarType7(type) ||
|
|
3507
|
+
return isScalarType7(type) || isEnumType6(type) || isInputObjectType2(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
3508
3508
|
}
|
|
3509
3509
|
function assertInputType(type) {
|
|
3510
3510
|
if (!isInputType(type)) {
|
|
@@ -3513,7 +3513,7 @@ var require_definition = __commonJS({
|
|
|
3513
3513
|
return type;
|
|
3514
3514
|
}
|
|
3515
3515
|
function isOutputType(type) {
|
|
3516
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3516
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
3517
3517
|
}
|
|
3518
3518
|
function assertOutputType(type) {
|
|
3519
3519
|
if (!isOutputType(type)) {
|
|
@@ -3522,7 +3522,7 @@ var require_definition = __commonJS({
|
|
|
3522
3522
|
return type;
|
|
3523
3523
|
}
|
|
3524
3524
|
function isLeafType(type) {
|
|
3525
|
-
return isScalarType7(type) ||
|
|
3525
|
+
return isScalarType7(type) || isEnumType6(type);
|
|
3526
3526
|
}
|
|
3527
3527
|
function assertLeafType(type) {
|
|
3528
3528
|
if (!isLeafType(type)) {
|
|
@@ -3610,7 +3610,7 @@ var require_definition = __commonJS({
|
|
|
3610
3610
|
}
|
|
3611
3611
|
}
|
|
3612
3612
|
function isNamedType(type) {
|
|
3613
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3613
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType6(type) || isInputObjectType2(type);
|
|
3614
3614
|
}
|
|
3615
3615
|
function assertNamedType(type) {
|
|
3616
3616
|
if (!isNamedType(type)) {
|
|
@@ -57673,11 +57673,13 @@ function scalarPropertyValue(config2, missingScalars, target) {
|
|
|
57673
57673
|
|
|
57674
57674
|
// src/codegen/generators/typescript/typeReference.ts
|
|
57675
57675
|
var AST8 = recast8.types.builders;
|
|
57676
|
-
function tsTypeReference(config2, missingScalars, definition) {
|
|
57676
|
+
function tsTypeReference(config2, missingScalars, definition, body) {
|
|
57677
57677
|
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
57678
57678
|
let result;
|
|
57679
57679
|
if (graphql14.isScalarType(type)) {
|
|
57680
57680
|
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57681
|
+
} else if (graphql14.isEnumType(type)) {
|
|
57682
|
+
result = enumReference(config2, body, type.name);
|
|
57681
57683
|
} else {
|
|
57682
57684
|
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
57683
57685
|
}
|
|
@@ -57692,6 +57694,19 @@ function tsTypeReference(config2, missingScalars, definition) {
|
|
|
57692
57694
|
}
|
|
57693
57695
|
return result;
|
|
57694
57696
|
}
|
|
57697
|
+
function enumReference(config2, body, name) {
|
|
57698
|
+
ensureImports({
|
|
57699
|
+
config: config2,
|
|
57700
|
+
body,
|
|
57701
|
+
import: ["ValueOf"],
|
|
57702
|
+
importKind: "type",
|
|
57703
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
57704
|
+
});
|
|
57705
|
+
return AST8.tsTypeReference(
|
|
57706
|
+
AST8.identifier("ValueOf"),
|
|
57707
|
+
AST8.tsTypeParameterInstantiation([AST8.tsTypeQuery(AST8.identifier(name))])
|
|
57708
|
+
);
|
|
57709
|
+
}
|
|
57695
57710
|
|
|
57696
57711
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
57697
57712
|
var AST9 = recast9.types.builders;
|
|
@@ -57723,7 +57738,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
57723
57738
|
members.push(
|
|
57724
57739
|
AST9.tsPropertySignature(
|
|
57725
57740
|
AST9.identifier(field.name),
|
|
57726
|
-
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
57741
|
+
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field, body)),
|
|
57727
57742
|
graphql15.isNullableType(field.type)
|
|
57728
57743
|
)
|
|
57729
57744
|
);
|
|
@@ -57754,6 +57769,13 @@ function inlineType({
|
|
|
57754
57769
|
if (graphql16.isScalarType(type)) {
|
|
57755
57770
|
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57756
57771
|
} else if (graphql16.isEnumType(type)) {
|
|
57772
|
+
ensureImports({
|
|
57773
|
+
config: config2,
|
|
57774
|
+
body,
|
|
57775
|
+
importKind: "type",
|
|
57776
|
+
import: ["ValueOf"],
|
|
57777
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
57778
|
+
});
|
|
57757
57779
|
if (!visitedTypes.has(type.name)) {
|
|
57758
57780
|
ensureImports({
|
|
57759
57781
|
config: config2,
|
|
@@ -57763,7 +57785,7 @@ function inlineType({
|
|
|
57763
57785
|
});
|
|
57764
57786
|
visitedTypes.add(type.name);
|
|
57765
57787
|
}
|
|
57766
|
-
result =
|
|
57788
|
+
result = enumReference(config2, body, type.name);
|
|
57767
57789
|
} else if (selections) {
|
|
57768
57790
|
const rootObj = type;
|
|
57769
57791
|
const inlineFragments = {};
|
|
@@ -58196,7 +58218,7 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
58196
58218
|
return AST11.tsPropertySignature(
|
|
58197
58219
|
AST11.identifier(definition2.variable.name.value),
|
|
58198
58220
|
AST11.tsTypeAnnotation(
|
|
58199
|
-
tsTypeReference(config2, missingScalars, definition2)
|
|
58221
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
58200
58222
|
),
|
|
58201
58223
|
definition2.type.kind !== "NonNullType"
|
|
58202
58224
|
);
|
|
@@ -58263,7 +58285,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
58263
58285
|
return AST11.tsPropertySignature(
|
|
58264
58286
|
AST11.identifier(definition2.variable.name.value),
|
|
58265
58287
|
AST11.tsTypeAnnotation(
|
|
58266
|
-
tsTypeReference(
|
|
58288
|
+
tsTypeReference(
|
|
58289
|
+
config2,
|
|
58290
|
+
missingScalars,
|
|
58291
|
+
definition2,
|
|
58292
|
+
body
|
|
58293
|
+
)
|
|
58267
58294
|
),
|
|
58268
58295
|
definition2.type.kind !== "NonNullType"
|
|
58269
58296
|
);
|
|
@@ -58356,7 +58383,7 @@ async function imperativeCacheTypef(config2, docs) {
|
|
|
58356
58383
|
),
|
|
58357
58384
|
AST12.tsPropertySignature(
|
|
58358
58385
|
AST12.identifier("lists"),
|
|
58359
|
-
AST12.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
58386
|
+
AST12.tsTypeAnnotation(listDefinitions(config2, body, docs))
|
|
58360
58387
|
),
|
|
58361
58388
|
AST12.tsPropertySignature(
|
|
58362
58389
|
AST12.identifier("queries"),
|
|
@@ -58465,7 +58492,7 @@ function typeDefinitions(config2, body, docs, returnType) {
|
|
|
58465
58492
|
const prop = AST12.tsPropertySignature(
|
|
58466
58493
|
AST12.identifier(arg.name),
|
|
58467
58494
|
AST12.tsTypeAnnotation(
|
|
58468
|
-
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
58495
|
+
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg, body)
|
|
58469
58496
|
)
|
|
58470
58497
|
);
|
|
58471
58498
|
const unwrapped2 = unwrapType(config2, arg.type);
|
|
@@ -58515,7 +58542,7 @@ function typeDefinitions(config2, body, docs, returnType) {
|
|
|
58515
58542
|
})
|
|
58516
58543
|
);
|
|
58517
58544
|
}
|
|
58518
|
-
function listDefinitions(config2, docs) {
|
|
58545
|
+
function listDefinitions(config2, body, docs) {
|
|
58519
58546
|
const lists = [];
|
|
58520
58547
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
58521
58548
|
for (const doc of docs) {
|
|
@@ -58572,7 +58599,8 @@ function listDefinitions(config2, docs) {
|
|
|
58572
58599
|
tsTypeReference(
|
|
58573
58600
|
config2,
|
|
58574
58601
|
/* @__PURE__ */ new Set(),
|
|
58575
|
-
arg
|
|
58602
|
+
arg,
|
|
58603
|
+
body
|
|
58576
58604
|
)
|
|
58577
58605
|
)
|
|
58578
58606
|
);
|
|
@@ -58766,9 +58794,9 @@ async function definitionsGenerator(config2) {
|
|
|
58766
58794
|
).code;
|
|
58767
58795
|
const typeDefinitions2 = enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map(
|
|
58768
58796
|
(definition) => `
|
|
58769
|
-
export
|
|
58770
|
-
${definition.values?.map((value) => ` ${value.name.value}
|
|
58771
|
-
}
|
|
58797
|
+
export const ${definition.name.value} = {
|
|
58798
|
+
${definition.values?.map((value) => ` ${value.name.value}: "${value.name.value}"`).join(",\n")}
|
|
58799
|
+
} as const
|
|
58772
58800
|
`
|
|
58773
58801
|
).join("");
|
|
58774
58802
|
const definitionsIndex = `
|