houdini 1.0.7 → 1.0.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 +214 -94
- package/build/cmd-esm/index.js +214 -94
- package/build/codegen-cjs/index.js +124 -16
- package/build/codegen-esm/index.js +124 -16
- package/build/lib/config.d.ts +4 -3
- package/build/lib/detectTools.d.ts +11 -0
- package/build/lib/index.d.ts +1 -0
- package/build/lib-cjs/index.js +139 -8
- package/build/lib-esm/index.js +136 -8
- package/build/runtime/client/plugins/throwOnError.d.ts +2 -2
- package/build/runtime/lib/config.d.ts +5 -1
- package/build/runtime/lib/types.d.ts +7 -1
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/throwOnError.js +1 -1
- package/build/runtime-cjs/lib/config.d.ts +5 -1
- package/build/runtime-cjs/lib/types.d.ts +7 -1
- package/build/runtime-cjs/lib/types.js +6 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +2 -2
- package/build/runtime-esm/client/plugins/throwOnError.js +1 -1
- package/build/runtime-esm/lib/config.d.ts +5 -1
- package/build/runtime-esm/lib/types.d.ts +7 -1
- package/build/runtime-esm/lib/types.js +5 -0
- package/build/test-cjs/index.js +131 -20
- package/build/test-esm/index.js +131 -20
- package/build/vite-cjs/index.js +131 -20
- package/build/vite-esm/index.js +131 -20
- package/package.json +1 -2
package/build/cmd-esm/index.js
CHANGED
|
@@ -43775,14 +43775,18 @@ var require_lib3 = __commonJS({
|
|
|
43775
43775
|
}
|
|
43776
43776
|
});
|
|
43777
43777
|
|
|
43778
|
-
// ../../node_modules/.pnpm/tslib@2.
|
|
43778
|
+
// ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
|
|
43779
43779
|
var require_tslib = __commonJS({
|
|
43780
|
-
"../../node_modules/.pnpm/tslib@2.
|
|
43780
|
+
"../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module) {
|
|
43781
43781
|
var __extends;
|
|
43782
43782
|
var __assign;
|
|
43783
43783
|
var __rest;
|
|
43784
43784
|
var __decorate;
|
|
43785
43785
|
var __param;
|
|
43786
|
+
var __esDecorate;
|
|
43787
|
+
var __runInitializers;
|
|
43788
|
+
var __propKey;
|
|
43789
|
+
var __setFunctionName;
|
|
43786
43790
|
var __metadata;
|
|
43787
43791
|
var __awaiter;
|
|
43788
43792
|
var __generator;
|
|
@@ -43879,6 +43883,65 @@ var require_tslib = __commonJS({
|
|
|
43879
43883
|
decorator(target, key, paramIndex);
|
|
43880
43884
|
};
|
|
43881
43885
|
};
|
|
43886
|
+
__esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
43887
|
+
function accept(f3) {
|
|
43888
|
+
if (f3 !== void 0 && typeof f3 !== "function")
|
|
43889
|
+
throw new TypeError("Function expected");
|
|
43890
|
+
return f3;
|
|
43891
|
+
}
|
|
43892
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
43893
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
43894
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
43895
|
+
var _, done = false;
|
|
43896
|
+
for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
|
|
43897
|
+
var context = {};
|
|
43898
|
+
for (var p in contextIn)
|
|
43899
|
+
context[p] = p === "access" ? {} : contextIn[p];
|
|
43900
|
+
for (var p in contextIn.access)
|
|
43901
|
+
context.access[p] = contextIn.access[p];
|
|
43902
|
+
context.addInitializer = function(f3) {
|
|
43903
|
+
if (done)
|
|
43904
|
+
throw new TypeError("Cannot add initializers after decoration has completed");
|
|
43905
|
+
extraInitializers.push(accept(f3 || null));
|
|
43906
|
+
};
|
|
43907
|
+
var result = (0, decorators[i2])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
43908
|
+
if (kind === "accessor") {
|
|
43909
|
+
if (result === void 0)
|
|
43910
|
+
continue;
|
|
43911
|
+
if (result === null || typeof result !== "object")
|
|
43912
|
+
throw new TypeError("Object expected");
|
|
43913
|
+
if (_ = accept(result.get))
|
|
43914
|
+
descriptor.get = _;
|
|
43915
|
+
if (_ = accept(result.set))
|
|
43916
|
+
descriptor.set = _;
|
|
43917
|
+
if (_ = accept(result.init))
|
|
43918
|
+
initializers.push(_);
|
|
43919
|
+
} else if (_ = accept(result)) {
|
|
43920
|
+
if (kind === "field")
|
|
43921
|
+
initializers.push(_);
|
|
43922
|
+
else
|
|
43923
|
+
descriptor[key] = _;
|
|
43924
|
+
}
|
|
43925
|
+
}
|
|
43926
|
+
if (target)
|
|
43927
|
+
Object.defineProperty(target, contextIn.name, descriptor);
|
|
43928
|
+
done = true;
|
|
43929
|
+
};
|
|
43930
|
+
__runInitializers = function(thisArg, initializers, value) {
|
|
43931
|
+
var useValue = arguments.length > 2;
|
|
43932
|
+
for (var i2 = 0; i2 < initializers.length; i2++) {
|
|
43933
|
+
value = useValue ? initializers[i2].call(thisArg, value) : initializers[i2].call(thisArg);
|
|
43934
|
+
}
|
|
43935
|
+
return useValue ? value : void 0;
|
|
43936
|
+
};
|
|
43937
|
+
__propKey = function(x2) {
|
|
43938
|
+
return typeof x2 === "symbol" ? x2 : "".concat(x2);
|
|
43939
|
+
};
|
|
43940
|
+
__setFunctionName = function(f3, name, prefix) {
|
|
43941
|
+
if (typeof name === "symbol")
|
|
43942
|
+
name = name.description ? "[".concat(name.description, "]") : "";
|
|
43943
|
+
return Object.defineProperty(f3, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
43944
|
+
};
|
|
43882
43945
|
__metadata = function(metadataKey, metadataValue) {
|
|
43883
43946
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
43884
43947
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -44113,7 +44176,7 @@ var require_tslib = __commonJS({
|
|
|
44113
44176
|
}, i2;
|
|
44114
44177
|
function verb(n, f3) {
|
|
44115
44178
|
i2[n] = o[n] ? function(v) {
|
|
44116
|
-
return (p = !p) ? { value: __await(o[n](v)), done:
|
|
44179
|
+
return (p = !p) ? { value: __await(o[n](v)), done: false } : f3 ? f3(v) : v;
|
|
44117
44180
|
} : f3;
|
|
44118
44181
|
}
|
|
44119
44182
|
};
|
|
@@ -44191,6 +44254,10 @@ var require_tslib = __commonJS({
|
|
|
44191
44254
|
exporter("__rest", __rest);
|
|
44192
44255
|
exporter("__decorate", __decorate);
|
|
44193
44256
|
exporter("__param", __param);
|
|
44257
|
+
exporter("__esDecorate", __esDecorate);
|
|
44258
|
+
exporter("__runInitializers", __runInitializers);
|
|
44259
|
+
exporter("__propKey", __propKey);
|
|
44260
|
+
exporter("__setFunctionName", __setFunctionName);
|
|
44194
44261
|
exporter("__metadata", __metadata);
|
|
44195
44262
|
exporter("__awaiter", __awaiter);
|
|
44196
44263
|
exporter("__generator", __generator);
|
|
@@ -68475,6 +68542,10 @@ var CachePolicy = {
|
|
|
68475
68542
|
NetworkOnly: "NetworkOnly",
|
|
68476
68543
|
CacheAndNetwork: "CacheAndNetwork"
|
|
68477
68544
|
};
|
|
68545
|
+
var PaginateMode = {
|
|
68546
|
+
Infinite: "Infinite",
|
|
68547
|
+
SinglePage: "SinglePage"
|
|
68548
|
+
};
|
|
68478
68549
|
var ArtifactKind = {
|
|
68479
68550
|
Query: "HoudiniQuery",
|
|
68480
68551
|
Subscription: "HoudiniSubscription",
|
|
@@ -72084,6 +72155,7 @@ var Config = class {
|
|
|
72084
72155
|
defaultPartial;
|
|
72085
72156
|
internalListPosition;
|
|
72086
72157
|
defaultListTarget = null;
|
|
72158
|
+
defaultPaginateMode;
|
|
72087
72159
|
definitionsFolder;
|
|
72088
72160
|
newDocuments = "";
|
|
72089
72161
|
defaultKeys = ["id"];
|
|
@@ -72120,6 +72192,7 @@ var Config = class {
|
|
|
72120
72192
|
defaultPartial = false,
|
|
72121
72193
|
defaultListPosition = "append",
|
|
72122
72194
|
defaultListTarget = null,
|
|
72195
|
+
defaultPaginateMode = PaginateMode.Infinite,
|
|
72123
72196
|
defaultKeys,
|
|
72124
72197
|
types: types16 = {},
|
|
72125
72198
|
logLevel,
|
|
@@ -72153,6 +72226,7 @@ var Config = class {
|
|
|
72153
72226
|
this.defaultPartial = defaultPartial;
|
|
72154
72227
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
72155
72228
|
this.defaultListTarget = defaultListTarget;
|
|
72229
|
+
this.defaultPaginateMode = defaultPaginateMode;
|
|
72156
72230
|
this.definitionsFolder = definitionsPath;
|
|
72157
72231
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
72158
72232
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
@@ -72416,7 +72490,7 @@ var Config = class {
|
|
|
72416
72490
|
get listAllListsDirective() {
|
|
72417
72491
|
return "allLists";
|
|
72418
72492
|
}
|
|
72419
|
-
get
|
|
72493
|
+
get listOrPaginateNameArg() {
|
|
72420
72494
|
return "name";
|
|
72421
72495
|
}
|
|
72422
72496
|
get insertFragmentSuffix() {
|
|
@@ -72449,8 +72523,8 @@ var Config = class {
|
|
|
72449
72523
|
get paginateDirective() {
|
|
72450
72524
|
return "paginate";
|
|
72451
72525
|
}
|
|
72452
|
-
get
|
|
72453
|
-
return "
|
|
72526
|
+
get paginateModeArg() {
|
|
72527
|
+
return "mode";
|
|
72454
72528
|
}
|
|
72455
72529
|
get cacheDirective() {
|
|
72456
72530
|
return "cache";
|
|
@@ -72492,7 +72566,7 @@ var Config = class {
|
|
|
72492
72566
|
return name + this.removeFragmentSuffix;
|
|
72493
72567
|
}
|
|
72494
72568
|
isInternalEnum(node) {
|
|
72495
|
-
return node.name.value === "CachePolicy";
|
|
72569
|
+
return node.name.value === "CachePolicy" || node.name.value === "PaginateMode";
|
|
72496
72570
|
}
|
|
72497
72571
|
isInternalDirective(name) {
|
|
72498
72572
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
@@ -73013,6 +73087,57 @@ function deepMerge(filepath, ...targets) {
|
|
|
73013
73087
|
}
|
|
73014
73088
|
}
|
|
73015
73089
|
|
|
73090
|
+
// src/lib/detectTools.ts
|
|
73091
|
+
async function detectFromPackageJSON(cwd) {
|
|
73092
|
+
try {
|
|
73093
|
+
const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
|
|
73094
|
+
if (packageJSONFile) {
|
|
73095
|
+
var packageJSON = JSON.parse(packageJSONFile);
|
|
73096
|
+
} else {
|
|
73097
|
+
throw new Error("not found");
|
|
73098
|
+
}
|
|
73099
|
+
} catch {
|
|
73100
|
+
throw new Error(
|
|
73101
|
+
"\u274C houdini init must target an existing node project (with a package.json)"
|
|
73102
|
+
);
|
|
73103
|
+
}
|
|
73104
|
+
const { devDependencies, dependencies } = packageJSON;
|
|
73105
|
+
const hasDependency = (dep) => Boolean(devDependencies?.[dep] || dependencies?.[dep]);
|
|
73106
|
+
let framework = "svelte";
|
|
73107
|
+
if (hasDependency("@sveltejs/kit")) {
|
|
73108
|
+
framework = "kit";
|
|
73109
|
+
}
|
|
73110
|
+
return {
|
|
73111
|
+
framework,
|
|
73112
|
+
module: packageJSON["type"] === "module" ? "esm" : "commonjs"
|
|
73113
|
+
};
|
|
73114
|
+
}
|
|
73115
|
+
async function detectTools(cwd) {
|
|
73116
|
+
let typescript = false;
|
|
73117
|
+
try {
|
|
73118
|
+
await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
|
|
73119
|
+
typescript = true;
|
|
73120
|
+
} catch {
|
|
73121
|
+
}
|
|
73122
|
+
let package_manager = "npm";
|
|
73123
|
+
let dir = cwd;
|
|
73124
|
+
do {
|
|
73125
|
+
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
73126
|
+
package_manager = "pnpm";
|
|
73127
|
+
break;
|
|
73128
|
+
}
|
|
73129
|
+
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
73130
|
+
package_manager = "yarn";
|
|
73131
|
+
break;
|
|
73132
|
+
}
|
|
73133
|
+
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
73134
|
+
return {
|
|
73135
|
+
typescript,
|
|
73136
|
+
package_manager,
|
|
73137
|
+
...await detectFromPackageJSON(cwd)
|
|
73138
|
+
};
|
|
73139
|
+
}
|
|
73140
|
+
|
|
73016
73141
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
73017
73142
|
var WalkerBase = class {
|
|
73018
73143
|
constructor() {
|
|
@@ -74260,6 +74385,7 @@ async function paginate(config2, documents) {
|
|
|
74260
74385
|
let refetchQueryName = "";
|
|
74261
74386
|
let nodeQuery = false;
|
|
74262
74387
|
let fragment = "";
|
|
74388
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
74263
74389
|
doc.document = graphql10.visit(doc.document, {
|
|
74264
74390
|
OperationDefinition(node) {
|
|
74265
74391
|
if (node.operation !== "query") {
|
|
@@ -74325,6 +74451,14 @@ async function paginate(config2, documents) {
|
|
|
74325
74451
|
}
|
|
74326
74452
|
},
|
|
74327
74453
|
Directive(node) {
|
|
74454
|
+
if (node.name.value === config2.paginateDirective) {
|
|
74455
|
+
const paginateModeArg = node?.arguments?.find(
|
|
74456
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
74457
|
+
);
|
|
74458
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
74459
|
+
paginateMode = paginateModeArg.value.value;
|
|
74460
|
+
}
|
|
74461
|
+
}
|
|
74328
74462
|
if (node.name.value !== config2.argumentsDirective) {
|
|
74329
74463
|
return;
|
|
74330
74464
|
}
|
|
@@ -74369,7 +74503,8 @@ async function paginate(config2, documents) {
|
|
|
74369
74503
|
targetType,
|
|
74370
74504
|
paginated: true,
|
|
74371
74505
|
direction,
|
|
74372
|
-
start
|
|
74506
|
+
start,
|
|
74507
|
+
mode: paginateMode
|
|
74373
74508
|
};
|
|
74374
74509
|
if (!fragment) {
|
|
74375
74510
|
continue;
|
|
@@ -74718,7 +74853,9 @@ async function addListFragments(config2, documents) {
|
|
|
74718
74853
|
doc.document = graphql11.visit(doc.document, {
|
|
74719
74854
|
Directive(node, key, parent, path2, ancestors) {
|
|
74720
74855
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
74721
|
-
const nameArg = node.arguments?.find(
|
|
74856
|
+
const nameArg = node.arguments?.find(
|
|
74857
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
74858
|
+
);
|
|
74722
74859
|
let error = {
|
|
74723
74860
|
...new graphql11.GraphQLError(
|
|
74724
74861
|
"",
|
|
@@ -75018,14 +75155,23 @@ function fieldKey(config2, field) {
|
|
|
75018
75155
|
const attributeName = field.alias?.value || field.name.value;
|
|
75019
75156
|
const printed = graphql12.print(field);
|
|
75020
75157
|
const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
75021
|
-
|
|
75158
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
75159
|
+
const paginatedDirective = field.directives?.find(
|
|
75022
75160
|
(directive) => directive.name.value === config2.paginateDirective
|
|
75023
75161
|
);
|
|
75024
|
-
|
|
75162
|
+
if (paginatedDirective) {
|
|
75163
|
+
const paginateModeArg = paginatedDirective?.arguments?.find(
|
|
75164
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
75165
|
+
);
|
|
75166
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
75167
|
+
paginateMode = paginateModeArg.value.value;
|
|
75168
|
+
}
|
|
75169
|
+
}
|
|
75170
|
+
const paginationArgs = paginateMode === "SinglePage" ? [] : ["first", "after", "last", "before", "limit", "offset"];
|
|
75025
75171
|
const argObj = (secondParse.arguments || []).reduce((acc, arg) => {
|
|
75026
75172
|
const start = arg.value.loc?.start;
|
|
75027
75173
|
const end = arg.value.loc?.end;
|
|
75028
|
-
if (
|
|
75174
|
+
if (paginatedDirective && paginationArgs.includes(arg.name.value)) {
|
|
75029
75175
|
return acc;
|
|
75030
75176
|
}
|
|
75031
75177
|
if (!start || !end) {
|
|
@@ -75039,7 +75185,7 @@ function fieldKey(config2, field) {
|
|
|
75039
75185
|
const args = Object.keys(argObj);
|
|
75040
75186
|
args.sort();
|
|
75041
75187
|
let key = Object.values(argObj).length > 0 ? `${attributeName}(${args.map((key2) => `${key2}: ${argObj[key2]}`).join(", ")})` : attributeName;
|
|
75042
|
-
if (
|
|
75188
|
+
if (paginatedDirective) {
|
|
75043
75189
|
key = key + "::paginated";
|
|
75044
75190
|
}
|
|
75045
75191
|
return key;
|
|
@@ -75179,7 +75325,9 @@ function selection({
|
|
|
75179
75325
|
const listDirective = field.directives?.find(
|
|
75180
75326
|
(directive) => [config2.listDirective, config2.paginateDirective].includes(directive.name.value)
|
|
75181
75327
|
);
|
|
75182
|
-
const nameArg = listDirective?.arguments?.find(
|
|
75328
|
+
const nameArg = listDirective?.arguments?.find(
|
|
75329
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
75330
|
+
);
|
|
75183
75331
|
if (nameArg && nameArg.value.kind === "StringValue") {
|
|
75184
75332
|
const { connection, type: connectionType } = connectionSelection(
|
|
75185
75333
|
config2,
|
|
@@ -75298,7 +75446,7 @@ function artifactGenerator(stats) {
|
|
|
75298
75446
|
return;
|
|
75299
75447
|
}
|
|
75300
75448
|
const nameArg = node.arguments?.find(
|
|
75301
|
-
(arg) => arg.name.value === config2.
|
|
75449
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
75302
75450
|
);
|
|
75303
75451
|
if (!nameArg || nameArg.value.kind !== "StringValue") {
|
|
75304
75452
|
throw new HoudiniError({
|
|
@@ -76668,7 +76816,9 @@ function listDefinitions(config2, body, docs) {
|
|
|
76668
76816
|
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
76669
76817
|
return;
|
|
76670
76818
|
}
|
|
76671
|
-
const nameArg = node.arguments?.find(
|
|
76819
|
+
const nameArg = node.arguments?.find(
|
|
76820
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
76821
|
+
);
|
|
76672
76822
|
const nameValue = nameArg?.value?.value || "";
|
|
76673
76823
|
if (!nameValue || visitedLists.has(nameValue)) {
|
|
76674
76824
|
return;
|
|
@@ -76993,17 +77143,22 @@ enum CachePolicy {
|
|
|
76993
77143
|
${CachePolicy.NetworkOnly}
|
|
76994
77144
|
}
|
|
76995
77145
|
|
|
77146
|
+
enum PaginateMode {
|
|
77147
|
+
${PaginateMode.Infinite}
|
|
77148
|
+
${PaginateMode.SinglePage}
|
|
77149
|
+
}
|
|
77150
|
+
|
|
76996
77151
|
"""
|
|
76997
77152
|
@${config2.listDirective} is used to mark a field for the runtime as a place to add or remove
|
|
76998
77153
|
entities in mutations
|
|
76999
77154
|
"""
|
|
77000
|
-
directive @${config2.listDirective}(${config2.
|
|
77155
|
+
directive @${config2.listDirective}(${config2.listOrPaginateNameArg}: String!, connection: Boolean) on FIELD
|
|
77001
77156
|
|
|
77002
77157
|
"""
|
|
77003
77158
|
@${config2.paginateDirective} is used to to mark a field for pagination.
|
|
77004
77159
|
More info in the [doc](${siteURL}/guides/pagination).
|
|
77005
77160
|
"""
|
|
77006
|
-
directive @${config2.paginateDirective}(${config2.
|
|
77161
|
+
directive @${config2.paginateDirective}(${config2.listOrPaginateNameArg}: String, ${config2.paginateModeArg}: PaginateMode) on FIELD
|
|
77007
77162
|
|
|
77008
77163
|
"""
|
|
77009
77164
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
@@ -77269,7 +77424,7 @@ async function typeCheck(config2, docs) {
|
|
|
77269
77424
|
}
|
|
77270
77425
|
needsParent = needsParent || definition.kind === "FragmentDefinition";
|
|
77271
77426
|
const nameArg = directive.arguments?.find(
|
|
77272
|
-
({ name }) => name.value === config2.
|
|
77427
|
+
({ name }) => name.value === config2.listOrPaginateNameArg
|
|
77273
77428
|
);
|
|
77274
77429
|
if (!nameArg) {
|
|
77275
77430
|
if (directive.name.value === config2.listDirective) {
|
|
@@ -77749,7 +77904,14 @@ function paginateArgs(config2, filepath) {
|
|
|
77749
77904
|
)
|
|
77750
77905
|
);
|
|
77751
77906
|
}
|
|
77752
|
-
|
|
77907
|
+
const paginateModeArg = node?.arguments?.find(
|
|
77908
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
77909
|
+
);
|
|
77910
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
77911
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
77912
|
+
paginateMode = paginateModeArg.value.value;
|
|
77913
|
+
}
|
|
77914
|
+
if (forward && backwards && paginateMode === "Infinite") {
|
|
77753
77915
|
ctx.reportError(
|
|
77754
77916
|
new graphql25.GraphQLError(
|
|
77755
77917
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
@@ -78527,15 +78689,15 @@ async function init(_path, args) {
|
|
|
78527
78689
|
module,
|
|
78528
78690
|
url: is_remote_endpoint ? url : null
|
|
78529
78691
|
});
|
|
78530
|
-
await fs_exports.writeFile(houdiniClientPath, networkFile(url
|
|
78692
|
+
await fs_exports.writeFile(houdiniClientPath, networkFile(url));
|
|
78531
78693
|
await graphqlRCFile(targetPath);
|
|
78532
78694
|
await gitIgnore(targetPath);
|
|
78533
78695
|
if (framework === "kit") {
|
|
78534
78696
|
await updateSvelteConfig(targetPath, typescript);
|
|
78535
78697
|
} else if (framework === "svelte") {
|
|
78536
|
-
await updateSvelteMainJs(targetPath);
|
|
78698
|
+
await updateSvelteMainJs(targetPath, typescript);
|
|
78537
78699
|
}
|
|
78538
|
-
await updateViteConfig(targetPath, framework);
|
|
78700
|
+
await updateViteConfig(targetPath, framework, typescript);
|
|
78539
78701
|
await tjsConfig(targetPath, framework);
|
|
78540
78702
|
console.log();
|
|
78541
78703
|
console.log("\u{1F3A9} Welcome to Houdini!");
|
|
@@ -78554,16 +78716,16 @@ async function init(_path, args) {
|
|
|
78554
78716
|
2\uFE0F\u20E3 Start your application: ${logGreen(cmd_run)}
|
|
78555
78717
|
`);
|
|
78556
78718
|
}
|
|
78557
|
-
var networkFile = (url
|
|
78719
|
+
var networkFile = (url) => `import { HoudiniClient } from '$houdini';
|
|
78558
78720
|
|
|
78559
78721
|
export default new HoudiniClient({
|
|
78560
78722
|
url: '${url}'
|
|
78561
|
-
|
|
78723
|
+
|
|
78562
78724
|
// uncomment this to configure the network call (for things like authentication)
|
|
78563
|
-
|
|
78725
|
+
// for more information, please visit here: https://www.houdinigraphql.com/guides/authentication
|
|
78564
78726
|
// fetchParams({ session }) {
|
|
78565
78727
|
// return {
|
|
78566
|
-
|
|
78728
|
+
// headers: {
|
|
78567
78729
|
// Authentication: \`Bearer \${session.token}\`,
|
|
78568
78730
|
// }
|
|
78569
78731
|
// }
|
|
@@ -78642,27 +78804,30 @@ async function tjsConfig(targetPath, framework) {
|
|
|
78642
78804
|
}
|
|
78643
78805
|
return false;
|
|
78644
78806
|
}
|
|
78645
|
-
async function updateViteConfig(targetPath, framework) {
|
|
78646
|
-
const viteConfigPath = path_exports.join(targetPath, "vite.config.js");
|
|
78647
|
-
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite'
|
|
78648
|
-
import houdini from 'houdini/vite'
|
|
78649
|
-
|
|
78650
|
-
|
|
78651
|
-
|
|
78652
|
-
plugins: [houdini(), sveltekit()]
|
|
78653
|
-
}
|
|
78654
|
-
|
|
78655
|
-
export default config;
|
|
78807
|
+
async function updateViteConfig(targetPath, framework, typescript) {
|
|
78808
|
+
const viteConfigPath = path_exports.join(targetPath, typescript ? "vite.config.ts" : "vite.config.js");
|
|
78809
|
+
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite'
|
|
78810
|
+
import houdini from 'houdini/vite'
|
|
78811
|
+
import { defineConfig } from 'vite'
|
|
78812
|
+
|
|
78813
|
+
export default defineConfig({
|
|
78814
|
+
plugins: [houdini(), sveltekit()]
|
|
78815
|
+
});
|
|
78656
78816
|
`;
|
|
78657
|
-
const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
78658
|
-
import houdini from 'houdini/vite'
|
|
78817
|
+
const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
78818
|
+
import houdini from 'houdini/vite'
|
|
78819
|
+
import * as path from 'path'
|
|
78820
|
+
import { defineConfig } from 'vite'
|
|
78659
78821
|
|
|
78660
|
-
|
|
78661
|
-
const config = {
|
|
78822
|
+
export default defineConfig({
|
|
78662
78823
|
plugins: [houdini(), svelte()],
|
|
78663
|
-
}
|
|
78664
78824
|
|
|
78665
|
-
|
|
78825
|
+
resolve: {
|
|
78826
|
+
alias: {
|
|
78827
|
+
$houdini: path.resolve('$houdini'),
|
|
78828
|
+
},
|
|
78829
|
+
},
|
|
78830
|
+
})
|
|
78666
78831
|
`;
|
|
78667
78832
|
let content;
|
|
78668
78833
|
if (framework === "kit") {
|
|
@@ -78717,12 +78882,11 @@ export default config;
|
|
|
78717
78882
|
content: typescript ? newContentTs : newContentJs
|
|
78718
78883
|
});
|
|
78719
78884
|
}
|
|
78720
|
-
async function updateSvelteMainJs(targetPath) {
|
|
78721
|
-
const svelteMainJsPath = path_exports.join(targetPath, "main.js");
|
|
78722
|
-
const newContent = `import client from "
|
|
78885
|
+
async function updateSvelteMainJs(targetPath, typescript) {
|
|
78886
|
+
const svelteMainJsPath = path_exports.join(targetPath, "src", typescript ? "main.ts" : "main.js");
|
|
78887
|
+
const newContent = `import client from "./client";
|
|
78723
78888
|
import './app.css'
|
|
78724
78889
|
import App from './App.svelte'
|
|
78725
|
-
import { logGreen } from '@kitql/helper'
|
|
78726
78890
|
|
|
78727
78891
|
client.init();
|
|
78728
78892
|
|
|
@@ -78746,8 +78910,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78746
78910
|
}
|
|
78747
78911
|
packageJSON.devDependencies = {
|
|
78748
78912
|
...packageJSON.devDependencies,
|
|
78749
|
-
houdini: "^1.0.
|
|
78750
|
-
"houdini-svelte": "^1.0.
|
|
78913
|
+
houdini: "^1.0.9",
|
|
78914
|
+
"houdini-svelte": "^1.0.9"
|
|
78751
78915
|
};
|
|
78752
78916
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78753
78917
|
}
|
|
@@ -78775,50 +78939,6 @@ async function gitIgnore(targetPath) {
|
|
|
78775
78939
|
await fs_exports.writeFile(filepath, existing + "\n$houdini\n");
|
|
78776
78940
|
}
|
|
78777
78941
|
}
|
|
78778
|
-
async function detectTools(cwd) {
|
|
78779
|
-
try {
|
|
78780
|
-
const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
|
|
78781
|
-
if (packageJSONFile) {
|
|
78782
|
-
var packageJSON = JSON.parse(packageJSONFile);
|
|
78783
|
-
} else {
|
|
78784
|
-
throw new Error("not found");
|
|
78785
|
-
}
|
|
78786
|
-
} catch {
|
|
78787
|
-
throw new Error(
|
|
78788
|
-
"\u274C houdini init must target an existing node project (with a package.json)"
|
|
78789
|
-
);
|
|
78790
|
-
}
|
|
78791
|
-
const { devDependencies, dependencies } = packageJSON;
|
|
78792
|
-
const hasDependency = (dep) => Boolean(devDependencies?.[dep] || dependencies?.[dep]);
|
|
78793
|
-
let framework = "svelte";
|
|
78794
|
-
if (hasDependency("@sveltejs/kit")) {
|
|
78795
|
-
framework = "kit";
|
|
78796
|
-
}
|
|
78797
|
-
let typescript = false;
|
|
78798
|
-
try {
|
|
78799
|
-
await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
|
|
78800
|
-
typescript = true;
|
|
78801
|
-
} catch {
|
|
78802
|
-
}
|
|
78803
|
-
let package_manager = "npm";
|
|
78804
|
-
let dir = cwd;
|
|
78805
|
-
do {
|
|
78806
|
-
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
78807
|
-
package_manager = "pnpm";
|
|
78808
|
-
break;
|
|
78809
|
-
}
|
|
78810
|
-
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
78811
|
-
package_manager = "yarn";
|
|
78812
|
-
break;
|
|
78813
|
-
}
|
|
78814
|
-
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
78815
|
-
return {
|
|
78816
|
-
typescript,
|
|
78817
|
-
framework,
|
|
78818
|
-
module: packageJSON["type"] === "module" ? "esm" : "commonjs",
|
|
78819
|
-
package_manager
|
|
78820
|
-
};
|
|
78821
|
-
}
|
|
78822
78942
|
async function updateFile({ filepath, content }) {
|
|
78823
78943
|
await fs_exports.writeFile(filepath, content);
|
|
78824
78944
|
}
|