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-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({
|
|
@@ -75966,6 +76114,12 @@ function inlineType({
|
|
|
75966
76114
|
includeFragments,
|
|
75967
76115
|
allOptional
|
|
75968
76116
|
});
|
|
76117
|
+
const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
|
|
76118
|
+
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
76119
|
+
).length > 0;
|
|
76120
|
+
if (hasIncludeOrSkipDirective) {
|
|
76121
|
+
attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
|
|
76122
|
+
}
|
|
75969
76123
|
const prop = readonlyProperty(
|
|
75970
76124
|
AST10.tsPropertySignature(
|
|
75971
76125
|
AST10.identifier(attributeName),
|
|
@@ -76662,7 +76816,9 @@ function listDefinitions(config2, body, docs) {
|
|
|
76662
76816
|
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
76663
76817
|
return;
|
|
76664
76818
|
}
|
|
76665
|
-
const nameArg = node.arguments?.find(
|
|
76819
|
+
const nameArg = node.arguments?.find(
|
|
76820
|
+
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
76821
|
+
);
|
|
76666
76822
|
const nameValue = nameArg?.value?.value || "";
|
|
76667
76823
|
if (!nameValue || visitedLists.has(nameValue)) {
|
|
76668
76824
|
return;
|
|
@@ -76987,17 +77143,22 @@ enum CachePolicy {
|
|
|
76987
77143
|
${CachePolicy.NetworkOnly}
|
|
76988
77144
|
}
|
|
76989
77145
|
|
|
77146
|
+
enum PaginateMode {
|
|
77147
|
+
${PaginateMode.Infinite}
|
|
77148
|
+
${PaginateMode.SinglePage}
|
|
77149
|
+
}
|
|
77150
|
+
|
|
76990
77151
|
"""
|
|
76991
77152
|
@${config2.listDirective} is used to mark a field for the runtime as a place to add or remove
|
|
76992
77153
|
entities in mutations
|
|
76993
77154
|
"""
|
|
76994
|
-
directive @${config2.listDirective}(${config2.
|
|
77155
|
+
directive @${config2.listDirective}(${config2.listOrPaginateNameArg}: String!, connection: Boolean) on FIELD
|
|
76995
77156
|
|
|
76996
77157
|
"""
|
|
76997
77158
|
@${config2.paginateDirective} is used to to mark a field for pagination.
|
|
76998
77159
|
More info in the [doc](${siteURL}/guides/pagination).
|
|
76999
77160
|
"""
|
|
77000
|
-
directive @${config2.paginateDirective}(${config2.
|
|
77161
|
+
directive @${config2.paginateDirective}(${config2.listOrPaginateNameArg}: String, ${config2.paginateModeArg}: PaginateMode) on FIELD
|
|
77001
77162
|
|
|
77002
77163
|
"""
|
|
77003
77164
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
@@ -77263,7 +77424,7 @@ async function typeCheck(config2, docs) {
|
|
|
77263
77424
|
}
|
|
77264
77425
|
needsParent = needsParent || definition.kind === "FragmentDefinition";
|
|
77265
77426
|
const nameArg = directive.arguments?.find(
|
|
77266
|
-
({ name }) => name.value === config2.
|
|
77427
|
+
({ name }) => name.value === config2.listOrPaginateNameArg
|
|
77267
77428
|
);
|
|
77268
77429
|
if (!nameArg) {
|
|
77269
77430
|
if (directive.name.value === config2.listDirective) {
|
|
@@ -77743,7 +77904,14 @@ function paginateArgs(config2, filepath) {
|
|
|
77743
77904
|
)
|
|
77744
77905
|
);
|
|
77745
77906
|
}
|
|
77746
|
-
|
|
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") {
|
|
77747
77915
|
ctx.reportError(
|
|
77748
77916
|
new graphql25.GraphQLError(
|
|
77749
77917
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
@@ -78521,15 +78689,15 @@ async function init(_path, args) {
|
|
|
78521
78689
|
module,
|
|
78522
78690
|
url: is_remote_endpoint ? url : null
|
|
78523
78691
|
});
|
|
78524
|
-
await fs_exports.writeFile(houdiniClientPath, networkFile(url
|
|
78692
|
+
await fs_exports.writeFile(houdiniClientPath, networkFile(url));
|
|
78525
78693
|
await graphqlRCFile(targetPath);
|
|
78526
78694
|
await gitIgnore(targetPath);
|
|
78527
78695
|
if (framework === "kit") {
|
|
78528
78696
|
await updateSvelteConfig(targetPath, typescript);
|
|
78529
78697
|
} else if (framework === "svelte") {
|
|
78530
|
-
await updateSvelteMainJs(targetPath);
|
|
78698
|
+
await updateSvelteMainJs(targetPath, typescript);
|
|
78531
78699
|
}
|
|
78532
|
-
await updateViteConfig(targetPath, framework);
|
|
78700
|
+
await updateViteConfig(targetPath, framework, typescript);
|
|
78533
78701
|
await tjsConfig(targetPath, framework);
|
|
78534
78702
|
console.log();
|
|
78535
78703
|
console.log("\u{1F3A9} Welcome to Houdini!");
|
|
@@ -78548,16 +78716,16 @@ async function init(_path, args) {
|
|
|
78548
78716
|
2\uFE0F\u20E3 Start your application: ${logGreen(cmd_run)}
|
|
78549
78717
|
`);
|
|
78550
78718
|
}
|
|
78551
|
-
var networkFile = (url
|
|
78719
|
+
var networkFile = (url) => `import { HoudiniClient } from '$houdini';
|
|
78552
78720
|
|
|
78553
78721
|
export default new HoudiniClient({
|
|
78554
78722
|
url: '${url}'
|
|
78555
|
-
|
|
78723
|
+
|
|
78556
78724
|
// uncomment this to configure the network call (for things like authentication)
|
|
78557
|
-
|
|
78725
|
+
// for more information, please visit here: https://www.houdinigraphql.com/guides/authentication
|
|
78558
78726
|
// fetchParams({ session }) {
|
|
78559
78727
|
// return {
|
|
78560
|
-
|
|
78728
|
+
// headers: {
|
|
78561
78729
|
// Authentication: \`Bearer \${session.token}\`,
|
|
78562
78730
|
// }
|
|
78563
78731
|
// }
|
|
@@ -78636,27 +78804,30 @@ async function tjsConfig(targetPath, framework) {
|
|
|
78636
78804
|
}
|
|
78637
78805
|
return false;
|
|
78638
78806
|
}
|
|
78639
|
-
async function updateViteConfig(targetPath, framework) {
|
|
78640
|
-
const viteConfigPath = path_exports.join(targetPath, "vite.config.js");
|
|
78641
|
-
const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite'
|
|
78642
|
-
import houdini from 'houdini/vite'
|
|
78643
|
-
|
|
78644
|
-
|
|
78645
|
-
|
|
78646
|
-
plugins: [houdini(), sveltekit()]
|
|
78647
|
-
}
|
|
78648
|
-
|
|
78649
|
-
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
|
+
});
|
|
78650
78816
|
`;
|
|
78651
|
-
const viteConfigSvelte = `import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
78652
|
-
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'
|
|
78653
78821
|
|
|
78654
|
-
|
|
78655
|
-
const config = {
|
|
78822
|
+
export default defineConfig({
|
|
78656
78823
|
plugins: [houdini(), svelte()],
|
|
78657
|
-
}
|
|
78658
78824
|
|
|
78659
|
-
|
|
78825
|
+
resolve: {
|
|
78826
|
+
alias: {
|
|
78827
|
+
$houdini: path.resolve('$houdini'),
|
|
78828
|
+
},
|
|
78829
|
+
},
|
|
78830
|
+
})
|
|
78660
78831
|
`;
|
|
78661
78832
|
let content;
|
|
78662
78833
|
if (framework === "kit") {
|
|
@@ -78711,12 +78882,11 @@ export default config;
|
|
|
78711
78882
|
content: typescript ? newContentTs : newContentJs
|
|
78712
78883
|
});
|
|
78713
78884
|
}
|
|
78714
|
-
async function updateSvelteMainJs(targetPath) {
|
|
78715
|
-
const svelteMainJsPath = path_exports.join(targetPath, "main.js");
|
|
78716
|
-
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";
|
|
78717
78888
|
import './app.css'
|
|
78718
78889
|
import App from './App.svelte'
|
|
78719
|
-
import { logGreen } from '@kitql/helper'
|
|
78720
78890
|
|
|
78721
78891
|
client.init();
|
|
78722
78892
|
|
|
@@ -78740,8 +78910,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78740
78910
|
}
|
|
78741
78911
|
packageJSON.devDependencies = {
|
|
78742
78912
|
...packageJSON.devDependencies,
|
|
78743
|
-
houdini: "^1.0.
|
|
78744
|
-
"houdini-svelte": "^1.0.
|
|
78913
|
+
houdini: "^1.0.8",
|
|
78914
|
+
"houdini-svelte": "^1.0.8"
|
|
78745
78915
|
};
|
|
78746
78916
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78747
78917
|
}
|
|
@@ -78769,50 +78939,6 @@ async function gitIgnore(targetPath) {
|
|
|
78769
78939
|
await fs_exports.writeFile(filepath, existing + "\n$houdini\n");
|
|
78770
78940
|
}
|
|
78771
78941
|
}
|
|
78772
|
-
async function detectTools(cwd) {
|
|
78773
|
-
try {
|
|
78774
|
-
const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
|
|
78775
|
-
if (packageJSONFile) {
|
|
78776
|
-
var packageJSON = JSON.parse(packageJSONFile);
|
|
78777
|
-
} else {
|
|
78778
|
-
throw new Error("not found");
|
|
78779
|
-
}
|
|
78780
|
-
} catch {
|
|
78781
|
-
throw new Error(
|
|
78782
|
-
"\u274C houdini init must target an existing node project (with a package.json)"
|
|
78783
|
-
);
|
|
78784
|
-
}
|
|
78785
|
-
const { devDependencies, dependencies } = packageJSON;
|
|
78786
|
-
const hasDependency = (dep) => Boolean(devDependencies?.[dep] || dependencies?.[dep]);
|
|
78787
|
-
let framework = "svelte";
|
|
78788
|
-
if (hasDependency("@sveltejs/kit")) {
|
|
78789
|
-
framework = "kit";
|
|
78790
|
-
}
|
|
78791
|
-
let typescript = false;
|
|
78792
|
-
try {
|
|
78793
|
-
await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
|
|
78794
|
-
typescript = true;
|
|
78795
|
-
} catch {
|
|
78796
|
-
}
|
|
78797
|
-
let package_manager = "npm";
|
|
78798
|
-
let dir = cwd;
|
|
78799
|
-
do {
|
|
78800
|
-
if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
|
|
78801
|
-
package_manager = "pnpm";
|
|
78802
|
-
break;
|
|
78803
|
-
}
|
|
78804
|
-
if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
|
|
78805
|
-
package_manager = "yarn";
|
|
78806
|
-
break;
|
|
78807
|
-
}
|
|
78808
|
-
} while (dir !== (dir = path_exports.dirname(dir)));
|
|
78809
|
-
return {
|
|
78810
|
-
typescript,
|
|
78811
|
-
framework,
|
|
78812
|
-
module: packageJSON["type"] === "module" ? "esm" : "commonjs",
|
|
78813
|
-
package_manager
|
|
78814
|
-
};
|
|
78815
|
-
}
|
|
78816
78942
|
async function updateFile({ filepath, content }) {
|
|
78817
78943
|
await fs_exports.writeFile(filepath, content);
|
|
78818
78944
|
}
|