houdini 1.0.6 → 1.0.8
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 +220 -94
- package/build/cmd-esm/index.js +220 -94
- package/build/codegen-cjs/index.js +130 -16
- package/build/codegen-esm/index.js +130 -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 +137 -20
- package/build/test-esm/index.js +137 -20
- package/build/vite-cjs/index.js +137 -20
- package/build/vite-esm/index.js +137 -20
- package/package.json +1 -2
package/build/cmd-cjs/index.js
CHANGED
|
@@ -43769,14 +43769,18 @@ var require_lib3 = __commonJS({
|
|
|
43769
43769
|
}
|
|
43770
43770
|
});
|
|
43771
43771
|
|
|
43772
|
-
// ../../node_modules/.pnpm/tslib@2.
|
|
43772
|
+
// ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
|
|
43773
43773
|
var require_tslib = __commonJS({
|
|
43774
|
-
"../../node_modules/.pnpm/tslib@2.
|
|
43774
|
+
"../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module2) {
|
|
43775
43775
|
var __extends;
|
|
43776
43776
|
var __assign;
|
|
43777
43777
|
var __rest;
|
|
43778
43778
|
var __decorate;
|
|
43779
43779
|
var __param;
|
|
43780
|
+
var __esDecorate;
|
|
43781
|
+
var __runInitializers;
|
|
43782
|
+
var __propKey;
|
|
43783
|
+
var __setFunctionName;
|
|
43780
43784
|
var __metadata;
|
|
43781
43785
|
var __awaiter;
|
|
43782
43786
|
var __generator;
|
|
@@ -43873,6 +43877,65 @@ var require_tslib = __commonJS({
|
|
|
43873
43877
|
decorator(target, key, paramIndex);
|
|
43874
43878
|
};
|
|
43875
43879
|
};
|
|
43880
|
+
__esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
43881
|
+
function accept(f3) {
|
|
43882
|
+
if (f3 !== void 0 && typeof f3 !== "function")
|
|
43883
|
+
throw new TypeError("Function expected");
|
|
43884
|
+
return f3;
|
|
43885
|
+
}
|
|
43886
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
43887
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
43888
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
43889
|
+
var _, done = false;
|
|
43890
|
+
for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
|
|
43891
|
+
var context = {};
|
|
43892
|
+
for (var p in contextIn)
|
|
43893
|
+
context[p] = p === "access" ? {} : contextIn[p];
|
|
43894
|
+
for (var p in contextIn.access)
|
|
43895
|
+
context.access[p] = contextIn.access[p];
|
|
43896
|
+
context.addInitializer = function(f3) {
|
|
43897
|
+
if (done)
|
|
43898
|
+
throw new TypeError("Cannot add initializers after decoration has completed");
|
|
43899
|
+
extraInitializers.push(accept(f3 || null));
|
|
43900
|
+
};
|
|
43901
|
+
var result = (0, decorators[i2])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
43902
|
+
if (kind === "accessor") {
|
|
43903
|
+
if (result === void 0)
|
|
43904
|
+
continue;
|
|
43905
|
+
if (result === null || typeof result !== "object")
|
|
43906
|
+
throw new TypeError("Object expected");
|
|
43907
|
+
if (_ = accept(result.get))
|
|
43908
|
+
descriptor.get = _;
|
|
43909
|
+
if (_ = accept(result.set))
|
|
43910
|
+
descriptor.set = _;
|
|
43911
|
+
if (_ = accept(result.init))
|
|
43912
|
+
initializers.push(_);
|
|
43913
|
+
} else if (_ = accept(result)) {
|
|
43914
|
+
if (kind === "field")
|
|
43915
|
+
initializers.push(_);
|
|
43916
|
+
else
|
|
43917
|
+
descriptor[key] = _;
|
|
43918
|
+
}
|
|
43919
|
+
}
|
|
43920
|
+
if (target)
|
|
43921
|
+
Object.defineProperty(target, contextIn.name, descriptor);
|
|
43922
|
+
done = true;
|
|
43923
|
+
};
|
|
43924
|
+
__runInitializers = function(thisArg, initializers, value) {
|
|
43925
|
+
var useValue = arguments.length > 2;
|
|
43926
|
+
for (var i2 = 0; i2 < initializers.length; i2++) {
|
|
43927
|
+
value = useValue ? initializers[i2].call(thisArg, value) : initializers[i2].call(thisArg);
|
|
43928
|
+
}
|
|
43929
|
+
return useValue ? value : void 0;
|
|
43930
|
+
};
|
|
43931
|
+
__propKey = function(x2) {
|
|
43932
|
+
return typeof x2 === "symbol" ? x2 : "".concat(x2);
|
|
43933
|
+
};
|
|
43934
|
+
__setFunctionName = function(f3, name, prefix) {
|
|
43935
|
+
if (typeof name === "symbol")
|
|
43936
|
+
name = name.description ? "[".concat(name.description, "]") : "";
|
|
43937
|
+
return Object.defineProperty(f3, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
43938
|
+
};
|
|
43876
43939
|
__metadata = function(metadataKey, metadataValue) {
|
|
43877
43940
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
43878
43941
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -44107,7 +44170,7 @@ var require_tslib = __commonJS({
|
|
|
44107
44170
|
}, i2;
|
|
44108
44171
|
function verb(n, f3) {
|
|
44109
44172
|
i2[n] = o[n] ? function(v) {
|
|
44110
|
-
return (p = !p) ? { value: __await(o[n](v)), done:
|
|
44173
|
+
return (p = !p) ? { value: __await(o[n](v)), done: false } : f3 ? f3(v) : v;
|
|
44111
44174
|
} : f3;
|
|
44112
44175
|
}
|
|
44113
44176
|
};
|
|
@@ -44185,6 +44248,10 @@ var require_tslib = __commonJS({
|
|
|
44185
44248
|
exporter("__rest", __rest);
|
|
44186
44249
|
exporter("__decorate", __decorate);
|
|
44187
44250
|
exporter("__param", __param);
|
|
44251
|
+
exporter("__esDecorate", __esDecorate);
|
|
44252
|
+
exporter("__runInitializers", __runInitializers);
|
|
44253
|
+
exporter("__propKey", __propKey);
|
|
44254
|
+
exporter("__setFunctionName", __setFunctionName);
|
|
44188
44255
|
exporter("__metadata", __metadata);
|
|
44189
44256
|
exporter("__awaiter", __awaiter);
|
|
44190
44257
|
exporter("__generator", __generator);
|
|
@@ -68469,6 +68536,10 @@ var CachePolicy = {
|
|
|
68469
68536
|
NetworkOnly: "NetworkOnly",
|
|
68470
68537
|
CacheAndNetwork: "CacheAndNetwork"
|
|
68471
68538
|
};
|
|
68539
|
+
var PaginateMode = {
|
|
68540
|
+
Infinite: "Infinite",
|
|
68541
|
+
SinglePage: "SinglePage"
|
|
68542
|
+
};
|
|
68472
68543
|
var ArtifactKind = {
|
|
68473
68544
|
Query: "HoudiniQuery",
|
|
68474
68545
|
Subscription: "HoudiniSubscription",
|
|
@@ -72079,6 +72150,7 @@ var Config = class {
|
|
|
72079
72150
|
defaultPartial;
|
|
72080
72151
|
internalListPosition;
|
|
72081
72152
|
defaultListTarget = null;
|
|
72153
|
+
defaultPaginateMode;
|
|
72082
72154
|
definitionsFolder;
|
|
72083
72155
|
newDocuments = "";
|
|
72084
72156
|
defaultKeys = ["id"];
|
|
@@ -72115,6 +72187,7 @@ var Config = class {
|
|
|
72115
72187
|
defaultPartial = false,
|
|
72116
72188
|
defaultListPosition = "append",
|
|
72117
72189
|
defaultListTarget = null,
|
|
72190
|
+
defaultPaginateMode = PaginateMode.Infinite,
|
|
72118
72191
|
defaultKeys,
|
|
72119
72192
|
types: types16 = {},
|
|
72120
72193
|
logLevel,
|
|
@@ -72148,6 +72221,7 @@ var Config = class {
|
|
|
72148
72221
|
this.defaultPartial = defaultPartial;
|
|
72149
72222
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
72150
72223
|
this.defaultListTarget = defaultListTarget;
|
|
72224
|
+
this.defaultPaginateMode = defaultPaginateMode;
|
|
72151
72225
|
this.definitionsFolder = definitionsPath;
|
|
72152
72226
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
72153
72227
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
@@ -72411,7 +72485,7 @@ var Config = class {
|
|
|
72411
72485
|
get listAllListsDirective() {
|
|
72412
72486
|
return "allLists";
|
|
72413
72487
|
}
|
|
72414
|
-
get
|
|
72488
|
+
get listOrPaginateNameArg() {
|
|
72415
72489
|
return "name";
|
|
72416
72490
|
}
|
|
72417
72491
|
get insertFragmentSuffix() {
|
|
@@ -72444,8 +72518,8 @@ var Config = class {
|
|
|
72444
72518
|
get paginateDirective() {
|
|
72445
72519
|
return "paginate";
|
|
72446
72520
|
}
|
|
72447
|
-
get
|
|
72448
|
-
return "
|
|
72521
|
+
get paginateModeArg() {
|
|
72522
|
+
return "mode";
|
|
72449
72523
|
}
|
|
72450
72524
|
get cacheDirective() {
|
|
72451
72525
|
return "cache";
|
|
@@ -72487,7 +72561,7 @@ var Config = class {
|
|
|
72487
72561
|
return name + this.removeFragmentSuffix;
|
|
72488
72562
|
}
|
|
72489
72563
|
isInternalEnum(node) {
|
|
72490
|
-
return node.name.value === "CachePolicy";
|
|
72564
|
+
return node.name.value === "CachePolicy" || node.name.value === "PaginateMode";
|
|
72491
72565
|
}
|
|
72492
72566
|
isInternalDirective(name) {
|
|
72493
72567
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
@@ -73008,6 +73082,57 @@ function deepMerge(filepath, ...targets) {
|
|
|
73008
73082
|
}
|
|
73009
73083
|
}
|
|
73010
73084
|
|
|
73085
|
+
// src/lib/detectTools.ts
|
|
73086
|
+
async function detectFromPackageJSON(cwd) {
|
|
73087
|
+
try {
|
|
73088
|
+
const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
|
|
73089
|
+
if (packageJSONFile) {
|
|
73090
|
+
var packageJSON = JSON.parse(packageJSONFile);
|
|
73091
|
+
} else {
|
|
73092
|
+
throw new Error("not found");
|
|
73093
|
+
}
|
|
73094
|
+
} catch {
|
|
73095
|
+
throw new Error(
|
|
73096
|
+
"\u274C houdini init must target an existing node project (with a package.json)"
|
|
73097
|
+
);
|
|
73098
|
+
}
|
|
73099
|
+
const { devDependencies, dependencies } = packageJSON;
|
|
73100
|
+
const hasDependency = (dep) => Boolean(devDependencies?.[dep] || dependencies?.[dep]);
|
|
73101
|
+
let framework = "svelte";
|
|
73102
|
+
if (hasDependency("@sveltejs/kit")) {
|
|
73103
|
+
framework = "kit";
|
|
73104
|
+
}
|
|
73105
|
+
return {
|
|
73106
|
+
framework,
|
|
73107
|
+
module: packageJSON["type"] === "module" ? "esm" : "commonjs"
|
|
73108
|
+
};
|
|
73109
|
+
}
|
|
73110
|
+
async function detectTools(cwd) {
|
|
73111
|
+
let typescript = false;
|
|
73112
|
+
try {
|
|
73113
|
+
await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
|
|
73114
|
+
typescript = true;
|
|
73115
|
+
} catch {
|
|
73116
|
+
}
|
|
73117
|
+
let package_manager = "npm";
|
|
73118
|
+
let dir = cwd;
|
|
73119
|
+
do {
|
|
73120
|
+
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
73121
|
+
package_manager = "pnpm";
|
|
73122
|
+
break;
|
|
73123
|
+
}
|
|
73124
|
+
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
73125
|
+
package_manager = "yarn";
|
|
73126
|
+
break;
|
|
73127
|
+
}
|
|
73128
|
+
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
73129
|
+
return {
|
|
73130
|
+
typescript,
|
|
73131
|
+
package_manager,
|
|
73132
|
+
...await detectFromPackageJSON(cwd)
|
|
73133
|
+
};
|
|
73134
|
+
}
|
|
73135
|
+
|
|
73011
73136
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
73012
73137
|
var WalkerBase = class {
|
|
73013
73138
|
constructor() {
|
|
@@ -74255,6 +74380,7 @@ async function paginate(config2, documents) {
|
|
|
74255
74380
|
let refetchQueryName = "";
|
|
74256
74381
|
let nodeQuery = false;
|
|
74257
74382
|
let fragment = "";
|
|
74383
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
74258
74384
|
doc.document = graphql10.visit(doc.document, {
|
|
74259
74385
|
OperationDefinition(node) {
|
|
74260
74386
|
if (node.operation !== "query") {
|
|
@@ -74320,6 +74446,14 @@ async function paginate(config2, documents) {
|
|
|
74320
74446
|
}
|
|
74321
74447
|
},
|
|
74322
74448
|
Directive(node) {
|
|
74449
|
+
if (node.name.value === config2.paginateDirective) {
|
|
74450
|
+
const paginateModeArg = node?.arguments?.find(
|
|
74451
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
74452
|
+
);
|
|
74453
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
74454
|
+
paginateMode = paginateModeArg.value.value;
|
|
74455
|
+
}
|
|
74456
|
+
}
|
|
74323
74457
|
if (node.name.value !== config2.argumentsDirective) {
|
|
74324
74458
|
return;
|
|
74325
74459
|
}
|
|
@@ -74364,7 +74498,8 @@ async function paginate(config2, documents) {
|
|
|
74364
74498
|
targetType,
|
|
74365
74499
|
paginated: true,
|
|
74366
74500
|
direction,
|
|
74367
|
-
start
|
|
74501
|
+
start,
|
|
74502
|
+
mode: paginateMode
|
|
74368
74503
|
};
|
|
74369
74504
|
if (!fragment) {
|
|
74370
74505
|
continue;
|
|
@@ -74713,7 +74848,9 @@ async function addListFragments(config2, documents) {
|
|
|
74713
74848
|
doc.document = graphql11.visit(doc.document, {
|
|
74714
74849
|
Directive(node, key, parent, path2, ancestors) {
|
|
74715
74850
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
74716
|
-
const nameArg = node.arguments?.find(
|
|
74851
|
+
const nameArg = node.arguments?.find(
|
|
74852
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
74853
|
+
);
|
|
74717
74854
|
let error = {
|
|
74718
74855
|
...new graphql11.GraphQLError(
|
|
74719
74856
|
"",
|
|
@@ -75013,14 +75150,23 @@ function fieldKey(config2, field) {
|
|
|
75013
75150
|
const attributeName = field.alias?.value || field.name.value;
|
|
75014
75151
|
const printed = graphql12.print(field);
|
|
75015
75152
|
const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
75016
|
-
|
|
75153
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
75154
|
+
const paginatedDirective = field.directives?.find(
|
|
75017
75155
|
(directive) => directive.name.value === config2.paginateDirective
|
|
75018
75156
|
);
|
|
75019
|
-
|
|
75157
|
+
if (paginatedDirective) {
|
|
75158
|
+
const paginateModeArg = paginatedDirective?.arguments?.find(
|
|
75159
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
75160
|
+
);
|
|
75161
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
75162
|
+
paginateMode = paginateModeArg.value.value;
|
|
75163
|
+
}
|
|
75164
|
+
}
|
|
75165
|
+
const paginationArgs = paginateMode === "SinglePage" ? [] : ["first", "after", "last", "before", "limit", "offset"];
|
|
75020
75166
|
const argObj = (secondParse.arguments || []).reduce((acc, arg) => {
|
|
75021
75167
|
const start = arg.value.loc?.start;
|
|
75022
75168
|
const end = arg.value.loc?.end;
|
|
75023
|
-
if (
|
|
75169
|
+
if (paginatedDirective && paginationArgs.includes(arg.name.value)) {
|
|
75024
75170
|
return acc;
|
|
75025
75171
|
}
|
|
75026
75172
|
if (!start || !end) {
|
|
@@ -75034,7 +75180,7 @@ function fieldKey(config2, field) {
|
|
|
75034
75180
|
const args = Object.keys(argObj);
|
|
75035
75181
|
args.sort();
|
|
75036
75182
|
let key = Object.values(argObj).length > 0 ? `${attributeName}(${args.map((key2) => `${key2}: ${argObj[key2]}`).join(", ")})` : attributeName;
|
|
75037
|
-
if (
|
|
75183
|
+
if (paginatedDirective) {
|
|
75038
75184
|
key = key + "::paginated";
|
|
75039
75185
|
}
|
|
75040
75186
|
return key;
|
|
@@ -75174,7 +75320,9 @@ function selection({
|
|
|
75174
75320
|
const listDirective = field.directives?.find(
|
|
75175
75321
|
(directive) => [config2.listDirective, config2.paginateDirective].includes(directive.name.value)
|
|
75176
75322
|
);
|
|
75177
|
-
const nameArg = listDirective?.arguments?.find(
|
|
75323
|
+
const nameArg = listDirective?.arguments?.find(
|
|
75324
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
75325
|
+
);
|
|
75178
75326
|
if (nameArg && nameArg.value.kind === "StringValue") {
|
|
75179
75327
|
const { connection, type: connectionType } = connectionSelection(
|
|
75180
75328
|
config2,
|
|
@@ -75293,7 +75441,7 @@ function artifactGenerator(stats) {
|
|
|
75293
75441
|
return;
|
|
75294
75442
|
}
|
|
75295
75443
|
const nameArg = node.arguments?.find(
|
|
75296
|
-
(arg) => arg.name.value === config2.
|
|
75444
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
75297
75445
|
);
|
|
75298
75446
|
if (!nameArg || nameArg.value.kind !== "StringValue") {
|
|
75299
75447
|
throw new HoudiniError({
|
|
@@ -75961,6 +76109,12 @@ function inlineType({
|
|
|
75961
76109
|
includeFragments,
|
|
75962
76110
|
allOptional
|
|
75963
76111
|
});
|
|
76112
|
+
const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
|
|
76113
|
+
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
76114
|
+
).length > 0;
|
|
76115
|
+
if (hasIncludeOrSkipDirective) {
|
|
76116
|
+
attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
|
|
76117
|
+
}
|
|
75964
76118
|
const prop = readonlyProperty(
|
|
75965
76119
|
AST10.tsPropertySignature(
|
|
75966
76120
|
AST10.identifier(attributeName),
|
|
@@ -76657,7 +76811,9 @@ function listDefinitions(config2, body, docs) {
|
|
|
76657
76811
|
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
76658
76812
|
return;
|
|
76659
76813
|
}
|
|
76660
|
-
const nameArg = node.arguments?.find(
|
|
76814
|
+
const nameArg = node.arguments?.find(
|
|
76815
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
76816
|
+
);
|
|
76661
76817
|
const nameValue = nameArg?.value?.value || "";
|
|
76662
76818
|
if (!nameValue || visitedLists.has(nameValue)) {
|
|
76663
76819
|
return;
|
|
@@ -76982,17 +77138,22 @@ enum CachePolicy {
|
|
|
76982
77138
|
${CachePolicy.NetworkOnly}
|
|
76983
77139
|
}
|
|
76984
77140
|
|
|
77141
|
+
enum PaginateMode {
|
|
77142
|
+
${PaginateMode.Infinite}
|
|
77143
|
+
${PaginateMode.SinglePage}
|
|
77144
|
+
}
|
|
77145
|
+
|
|
76985
77146
|
"""
|
|
76986
77147
|
@${config2.listDirective} is used to mark a field for the runtime as a place to add or remove
|
|
76987
77148
|
entities in mutations
|
|
76988
77149
|
"""
|
|
76989
|
-
directive @${config2.listDirective}(${config2.
|
|
77150
|
+
directive @${config2.listDirective}(${config2.listOrPaginateNameArg}: String!, connection: Boolean) on FIELD
|
|
76990
77151
|
|
|
76991
77152
|
"""
|
|
76992
77153
|
@${config2.paginateDirective} is used to to mark a field for pagination.
|
|
76993
77154
|
More info in the [doc](${siteURL}/guides/pagination).
|
|
76994
77155
|
"""
|
|
76995
|
-
directive @${config2.paginateDirective}(${config2.
|
|
77156
|
+
directive @${config2.paginateDirective}(${config2.listOrPaginateNameArg}: String, ${config2.paginateModeArg}: PaginateMode) on FIELD
|
|
76996
77157
|
|
|
76997
77158
|
"""
|
|
76998
77159
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
@@ -77258,7 +77419,7 @@ async function typeCheck(config2, docs) {
|
|
|
77258
77419
|
}
|
|
77259
77420
|
needsParent = needsParent || definition.kind === "FragmentDefinition";
|
|
77260
77421
|
const nameArg = directive.arguments?.find(
|
|
77261
|
-
({ name }) => name.value === config2.
|
|
77422
|
+
({ name }) => name.value === config2.listOrPaginateNameArg
|
|
77262
77423
|
);
|
|
77263
77424
|
if (!nameArg) {
|
|
77264
77425
|
if (directive.name.value === config2.listDirective) {
|
|
@@ -77738,7 +77899,14 @@ function paginateArgs(config2, filepath) {
|
|
|
77738
77899
|
)
|
|
77739
77900
|
);
|
|
77740
77901
|
}
|
|
77741
|
-
|
|
77902
|
+
const paginateModeArg = node?.arguments?.find(
|
|
77903
|
+
(arg) => arg.name.value === config2.paginateModeArg
|
|
77904
|
+
);
|
|
77905
|
+
let paginateMode = config2.defaultPaginateMode;
|
|
77906
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
77907
|
+
paginateMode = paginateModeArg.value.value;
|
|
77908
|
+
}
|
|
77909
|
+
if (forward && backwards && paginateMode === "Infinite") {
|
|
77742
77910
|
ctx.reportError(
|
|
77743
77911
|
new graphql25.GraphQLError(
|
|
77744
77912
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
@@ -78516,15 +78684,15 @@ async function init(_path, args) {
|
|
|
78516
78684
|
module: module2,
|
|
78517
78685
|
url: is_remote_endpoint ? url : null
|
|
78518
78686
|
});
|
|
78519
|
-
await fs_exports.writeFile(houdiniClientPath, networkFile(url
|
|
78687
|
+
await fs_exports.writeFile(houdiniClientPath, networkFile(url));
|
|
78520
78688
|
await graphqlRCFile(targetPath);
|
|
78521
78689
|
await gitIgnore(targetPath);
|
|
78522
78690
|
if (framework === "kit") {
|
|
78523
78691
|
await updateSvelteConfig(targetPath, typescript);
|
|
78524
78692
|
} else if (framework === "svelte") {
|
|
78525
|
-
await updateSvelteMainJs(targetPath);
|
|
78693
|
+
await updateSvelteMainJs(targetPath, typescript);
|
|
78526
78694
|
}
|
|
78527
|
-
await updateViteConfig(targetPath, framework);
|
|
78695
|
+
await updateViteConfig(targetPath, framework, typescript);
|
|
78528
78696
|
await tjsConfig(targetPath, framework);
|
|
78529
78697
|
console.log();
|
|
78530
78698
|
console.log("\u{1F3A9} Welcome to Houdini!");
|
|
@@ -78543,16 +78711,16 @@ async function init(_path, args) {
|
|
|
78543
78711
|
2\uFE0F\u20E3 Start your application: ${logGreen(cmd_run)}
|
|
78544
78712
|
`);
|
|
78545
78713
|
}
|
|
78546
|
-
var networkFile = (url
|
|
78714
|
+
var networkFile = (url) => `import { HoudiniClient } from '$houdini';
|
|
78547
78715
|
|
|
78548
78716
|
export default new HoudiniClient({
|
|
78549
78717
|
url: '${url}'
|
|
78550
|
-
|
|
78718
|
+
|
|
78551
78719
|
// uncomment this to configure the network call (for things like authentication)
|
|
78552
|
-
|
|
78720
|
+
// for more information, please visit here: https://www.houdinigraphql.com/guides/authentication
|
|
78553
78721
|
// fetchParams({ session }) {
|
|
78554
78722
|
// return {
|
|
78555
|
-
|
|
78723
|
+
// headers: {
|
|
78556
78724
|
// Authentication: \`Bearer \${session.token}\`,
|
|
78557
78725
|
// }
|
|
78558
78726
|
// }
|
|
@@ -78631,27 +78799,30 @@ async function tjsConfig(targetPath, framework) {
|
|
|
78631
78799
|
}
|
|
78632
78800
|
return false;
|
|
78633
78801
|
}
|
|
78634
|
-
async function updateViteConfig(targetPath, framework) {
|
|
78635
|
-
const viteConfigPath = path_exports.join(targetPath, "vite.config.js");
|
|
78636
|
-
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite'
|
|
78637
|
-
import houdini from 'houdini/vite'
|
|
78638
|
-
|
|
78639
|
-
|
|
78640
|
-
|
|
78641
|
-
plugins: [houdini(), sveltekit()]
|
|
78642
|
-
}
|
|
78643
|
-
|
|
78644
|
-
export default config;
|
|
78802
|
+
async function updateViteConfig(targetPath, framework, typescript) {
|
|
78803
|
+
const viteConfigPath = path_exports.join(targetPath, typescript ? "vite.config.ts" : "vite.config.js");
|
|
78804
|
+
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite'
|
|
78805
|
+
import houdini from 'houdini/vite'
|
|
78806
|
+
import { defineConfig } from 'vite'
|
|
78807
|
+
|
|
78808
|
+
export default defineConfig({
|
|
78809
|
+
plugins: [houdini(), sveltekit()]
|
|
78810
|
+
});
|
|
78645
78811
|
`;
|
|
78646
|
-
const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
78647
|
-
import houdini from 'houdini/vite'
|
|
78812
|
+
const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
78813
|
+
import houdini from 'houdini/vite'
|
|
78814
|
+
import * as path from 'path'
|
|
78815
|
+
import { defineConfig } from 'vite'
|
|
78648
78816
|
|
|
78649
|
-
|
|
78650
|
-
const config = {
|
|
78817
|
+
export default defineConfig({
|
|
78651
78818
|
plugins: [houdini(), svelte()],
|
|
78652
|
-
}
|
|
78653
78819
|
|
|
78654
|
-
|
|
78820
|
+
resolve: {
|
|
78821
|
+
alias: {
|
|
78822
|
+
$houdini: path.resolve('$houdini'),
|
|
78823
|
+
},
|
|
78824
|
+
},
|
|
78825
|
+
})
|
|
78655
78826
|
`;
|
|
78656
78827
|
let content;
|
|
78657
78828
|
if (framework === "kit") {
|
|
@@ -78706,12 +78877,11 @@ export default config;
|
|
|
78706
78877
|
content: typescript ? newContentTs : newContentJs
|
|
78707
78878
|
});
|
|
78708
78879
|
}
|
|
78709
|
-
async function updateSvelteMainJs(targetPath) {
|
|
78710
|
-
const svelteMainJsPath = path_exports.join(targetPath, "main.js");
|
|
78711
|
-
const newContent = `import client from "
|
|
78880
|
+
async function updateSvelteMainJs(targetPath, typescript) {
|
|
78881
|
+
const svelteMainJsPath = path_exports.join(targetPath, "src", typescript ? "main.ts" : "main.js");
|
|
78882
|
+
const newContent = `import client from "./client";
|
|
78712
78883
|
import './app.css'
|
|
78713
78884
|
import App from './App.svelte'
|
|
78714
|
-
import { logGreen } from '@kitql/helper'
|
|
78715
78885
|
|
|
78716
78886
|
client.init();
|
|
78717
78887
|
|
|
@@ -78735,8 +78905,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78735
78905
|
}
|
|
78736
78906
|
packageJSON.devDependencies = {
|
|
78737
78907
|
...packageJSON.devDependencies,
|
|
78738
|
-
houdini: "^1.0.
|
|
78739
|
-
"houdini-svelte": "^1.0.
|
|
78908
|
+
houdini: "^1.0.8",
|
|
78909
|
+
"houdini-svelte": "^1.0.8"
|
|
78740
78910
|
};
|
|
78741
78911
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78742
78912
|
}
|
|
@@ -78764,50 +78934,6 @@ async function gitIgnore(targetPath) {
|
|
|
78764
78934
|
await fs_exports.writeFile(filepath, existing + "\n$houdini\n");
|
|
78765
78935
|
}
|
|
78766
78936
|
}
|
|
78767
|
-
async function detectTools(cwd) {
|
|
78768
|
-
try {
|
|
78769
|
-
const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
|
|
78770
|
-
if (packageJSONFile) {
|
|
78771
|
-
var packageJSON = JSON.parse(packageJSONFile);
|
|
78772
|
-
} else {
|
|
78773
|
-
throw new Error("not found");
|
|
78774
|
-
}
|
|
78775
|
-
} catch {
|
|
78776
|
-
throw new Error(
|
|
78777
|
-
"\u274C houdini init must target an existing node project (with a package.json)"
|
|
78778
|
-
);
|
|
78779
|
-
}
|
|
78780
|
-
const { devDependencies, dependencies } = packageJSON;
|
|
78781
|
-
const hasDependency = (dep) => Boolean(devDependencies?.[dep] || dependencies?.[dep]);
|
|
78782
|
-
let framework = "svelte";
|
|
78783
|
-
if (hasDependency("@sveltejs/kit")) {
|
|
78784
|
-
framework = "kit";
|
|
78785
|
-
}
|
|
78786
|
-
let typescript = false;
|
|
78787
|
-
try {
|
|
78788
|
-
await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
|
|
78789
|
-
typescript = true;
|
|
78790
|
-
} catch {
|
|
78791
|
-
}
|
|
78792
|
-
let package_manager = "npm";
|
|
78793
|
-
let dir = cwd;
|
|
78794
|
-
do {
|
|
78795
|
-
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
78796
|
-
package_manager = "pnpm";
|
|
78797
|
-
break;
|
|
78798
|
-
}
|
|
78799
|
-
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
78800
|
-
package_manager = "yarn";
|
|
78801
|
-
break;
|
|
78802
|
-
}
|
|
78803
|
-
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
78804
|
-
return {
|
|
78805
|
-
typescript,
|
|
78806
|
-
framework,
|
|
78807
|
-
module: packageJSON["type"] === "module" ? "esm" : "commonjs",
|
|
78808
|
-
package_manager
|
|
78809
|
-
};
|
|
78810
|
-
}
|
|
78811
78937
|
async function updateFile({ filepath, content }) {
|
|
78812
78938
|
await fs_exports.writeFile(filepath, content);
|
|
78813
78939
|
}
|