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/vite-esm/index.js
CHANGED
|
@@ -45406,14 +45406,18 @@ var require_lib3 = __commonJS({
|
|
|
45406
45406
|
}
|
|
45407
45407
|
});
|
|
45408
45408
|
|
|
45409
|
-
// ../../node_modules/.pnpm/tslib@2.
|
|
45409
|
+
// ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
|
|
45410
45410
|
var require_tslib = __commonJS({
|
|
45411
|
-
"../../node_modules/.pnpm/tslib@2.
|
|
45411
|
+
"../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module) {
|
|
45412
45412
|
var __extends;
|
|
45413
45413
|
var __assign;
|
|
45414
45414
|
var __rest;
|
|
45415
45415
|
var __decorate;
|
|
45416
45416
|
var __param;
|
|
45417
|
+
var __esDecorate;
|
|
45418
|
+
var __runInitializers;
|
|
45419
|
+
var __propKey;
|
|
45420
|
+
var __setFunctionName;
|
|
45417
45421
|
var __metadata;
|
|
45418
45422
|
var __awaiter;
|
|
45419
45423
|
var __generator;
|
|
@@ -45510,6 +45514,65 @@ var require_tslib = __commonJS({
|
|
|
45510
45514
|
decorator(target, key, paramIndex);
|
|
45511
45515
|
};
|
|
45512
45516
|
};
|
|
45517
|
+
__esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
45518
|
+
function accept(f3) {
|
|
45519
|
+
if (f3 !== void 0 && typeof f3 !== "function")
|
|
45520
|
+
throw new TypeError("Function expected");
|
|
45521
|
+
return f3;
|
|
45522
|
+
}
|
|
45523
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
45524
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
45525
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
45526
|
+
var _, done = false;
|
|
45527
|
+
for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
|
|
45528
|
+
var context = {};
|
|
45529
|
+
for (var p in contextIn)
|
|
45530
|
+
context[p] = p === "access" ? {} : contextIn[p];
|
|
45531
|
+
for (var p in contextIn.access)
|
|
45532
|
+
context.access[p] = contextIn.access[p];
|
|
45533
|
+
context.addInitializer = function(f3) {
|
|
45534
|
+
if (done)
|
|
45535
|
+
throw new TypeError("Cannot add initializers after decoration has completed");
|
|
45536
|
+
extraInitializers.push(accept(f3 || null));
|
|
45537
|
+
};
|
|
45538
|
+
var result = (0, decorators[i2])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
45539
|
+
if (kind === "accessor") {
|
|
45540
|
+
if (result === void 0)
|
|
45541
|
+
continue;
|
|
45542
|
+
if (result === null || typeof result !== "object")
|
|
45543
|
+
throw new TypeError("Object expected");
|
|
45544
|
+
if (_ = accept(result.get))
|
|
45545
|
+
descriptor.get = _;
|
|
45546
|
+
if (_ = accept(result.set))
|
|
45547
|
+
descriptor.set = _;
|
|
45548
|
+
if (_ = accept(result.init))
|
|
45549
|
+
initializers.push(_);
|
|
45550
|
+
} else if (_ = accept(result)) {
|
|
45551
|
+
if (kind === "field")
|
|
45552
|
+
initializers.push(_);
|
|
45553
|
+
else
|
|
45554
|
+
descriptor[key] = _;
|
|
45555
|
+
}
|
|
45556
|
+
}
|
|
45557
|
+
if (target)
|
|
45558
|
+
Object.defineProperty(target, contextIn.name, descriptor);
|
|
45559
|
+
done = true;
|
|
45560
|
+
};
|
|
45561
|
+
__runInitializers = function(thisArg, initializers, value) {
|
|
45562
|
+
var useValue = arguments.length > 2;
|
|
45563
|
+
for (var i2 = 0; i2 < initializers.length; i2++) {
|
|
45564
|
+
value = useValue ? initializers[i2].call(thisArg, value) : initializers[i2].call(thisArg);
|
|
45565
|
+
}
|
|
45566
|
+
return useValue ? value : void 0;
|
|
45567
|
+
};
|
|
45568
|
+
__propKey = function(x2) {
|
|
45569
|
+
return typeof x2 === "symbol" ? x2 : "".concat(x2);
|
|
45570
|
+
};
|
|
45571
|
+
__setFunctionName = function(f3, name, prefix) {
|
|
45572
|
+
if (typeof name === "symbol")
|
|
45573
|
+
name = name.description ? "[".concat(name.description, "]") : "";
|
|
45574
|
+
return Object.defineProperty(f3, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
45575
|
+
};
|
|
45513
45576
|
__metadata = function(metadataKey, metadataValue) {
|
|
45514
45577
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
45515
45578
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -45744,7 +45807,7 @@ var require_tslib = __commonJS({
|
|
|
45744
45807
|
}, i2;
|
|
45745
45808
|
function verb(n, f3) {
|
|
45746
45809
|
i2[n] = o[n] ? function(v) {
|
|
45747
|
-
return (p = !p) ? { value: __await(o[n](v)), done:
|
|
45810
|
+
return (p = !p) ? { value: __await(o[n](v)), done: false } : f3 ? f3(v) : v;
|
|
45748
45811
|
} : f3;
|
|
45749
45812
|
}
|
|
45750
45813
|
};
|
|
@@ -45822,6 +45885,10 @@ var require_tslib = __commonJS({
|
|
|
45822
45885
|
exporter("__rest", __rest);
|
|
45823
45886
|
exporter("__decorate", __decorate);
|
|
45824
45887
|
exporter("__param", __param);
|
|
45888
|
+
exporter("__esDecorate", __esDecorate);
|
|
45889
|
+
exporter("__runInitializers", __runInitializers);
|
|
45890
|
+
exporter("__propKey", __propKey);
|
|
45891
|
+
exporter("__setFunctionName", __setFunctionName);
|
|
45825
45892
|
exporter("__metadata", __metadata);
|
|
45826
45893
|
exporter("__awaiter", __awaiter);
|
|
45827
45894
|
exporter("__generator", __generator);
|
|
@@ -65329,6 +65396,10 @@ var CachePolicy = {
|
|
|
65329
65396
|
NetworkOnly: "NetworkOnly",
|
|
65330
65397
|
CacheAndNetwork: "CacheAndNetwork"
|
|
65331
65398
|
};
|
|
65399
|
+
var PaginateMode = {
|
|
65400
|
+
Infinite: "Infinite",
|
|
65401
|
+
SinglePage: "SinglePage"
|
|
65402
|
+
};
|
|
65332
65403
|
var ArtifactKind = {
|
|
65333
65404
|
Query: "HoudiniQuery",
|
|
65334
65405
|
Subscription: "HoudiniSubscription",
|
|
@@ -68938,6 +69009,7 @@ var Config = class {
|
|
|
68938
69009
|
defaultPartial;
|
|
68939
69010
|
internalListPosition;
|
|
68940
69011
|
defaultListTarget = null;
|
|
69012
|
+
defaultPaginateMode;
|
|
68941
69013
|
definitionsFolder;
|
|
68942
69014
|
newDocuments = "";
|
|
68943
69015
|
defaultKeys = ["id"];
|
|
@@ -68974,6 +69046,7 @@ var Config = class {
|
|
|
68974
69046
|
defaultPartial = false,
|
|
68975
69047
|
defaultListPosition = "append",
|
|
68976
69048
|
defaultListTarget = null,
|
|
69049
|
+
defaultPaginateMode = PaginateMode.Infinite,
|
|
68977
69050
|
defaultKeys,
|
|
68978
69051
|
types: types17 = {},
|
|
68979
69052
|
logLevel,
|
|
@@ -69007,6 +69080,7 @@ var Config = class {
|
|
|
69007
69080
|
this.defaultPartial = defaultPartial;
|
|
69008
69081
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
69009
69082
|
this.defaultListTarget = defaultListTarget;
|
|
69083
|
+
this.defaultPaginateMode = defaultPaginateMode;
|
|
69010
69084
|
this.definitionsFolder = definitionsPath;
|
|
69011
69085
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
69012
69086
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
@@ -69270,7 +69344,7 @@ var Config = class {
|
|
|
69270
69344
|
get listAllListsDirective() {
|
|
69271
69345
|
return "allLists";
|
|
69272
69346
|
}
|
|
69273
|
-
get
|
|
69347
|
+
get listOrPaginateNameArg() {
|
|
69274
69348
|
return "name";
|
|
69275
69349
|
}
|
|
69276
69350
|
get insertFragmentSuffix() {
|
|
@@ -69303,8 +69377,8 @@ var Config = class {
|
|
|
69303
69377
|
get paginateDirective() {
|
|
69304
69378
|
return "paginate";
|
|
69305
69379
|
}
|
|
69306
|
-
get
|
|
69307
|
-
return "
|
|
69380
|
+
get paginateModeArg() {
|
|
69381
|
+
return "mode";
|
|
69308
69382
|
}
|
|
69309
69383
|
get cacheDirective() {
|
|
69310
69384
|
return "cache";
|
|
@@ -69346,7 +69420,7 @@ var Config = class {
|
|
|
69346
69420
|
return name + this.removeFragmentSuffix;
|
|
69347
69421
|
}
|
|
69348
69422
|
isInternalEnum(node) {
|
|
69349
|
-
return node.name.value === "CachePolicy";
|
|
69423
|
+
return node.name.value === "CachePolicy" || node.name.value === "PaginateMode";
|
|
69350
69424
|
}
|
|
69351
69425
|
isInternalDirective(name) {
|
|
69352
69426
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
@@ -71113,6 +71187,7 @@ async function paginate(config4, documents) {
|
|
|
71113
71187
|
let refetchQueryName = "";
|
|
71114
71188
|
let nodeQuery = false;
|
|
71115
71189
|
let fragment = "";
|
|
71190
|
+
let paginateMode = config4.defaultPaginateMode;
|
|
71116
71191
|
doc.document = graphql10.visit(doc.document, {
|
|
71117
71192
|
OperationDefinition(node) {
|
|
71118
71193
|
if (node.operation !== "query") {
|
|
@@ -71178,6 +71253,14 @@ async function paginate(config4, documents) {
|
|
|
71178
71253
|
}
|
|
71179
71254
|
},
|
|
71180
71255
|
Directive(node) {
|
|
71256
|
+
if (node.name.value === config4.paginateDirective) {
|
|
71257
|
+
const paginateModeArg = node?.arguments?.find(
|
|
71258
|
+
(arg) => arg.name.value === config4.paginateModeArg
|
|
71259
|
+
);
|
|
71260
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
71261
|
+
paginateMode = paginateModeArg.value.value;
|
|
71262
|
+
}
|
|
71263
|
+
}
|
|
71181
71264
|
if (node.name.value !== config4.argumentsDirective) {
|
|
71182
71265
|
return;
|
|
71183
71266
|
}
|
|
@@ -71222,7 +71305,8 @@ async function paginate(config4, documents) {
|
|
|
71222
71305
|
targetType,
|
|
71223
71306
|
paginated: true,
|
|
71224
71307
|
direction,
|
|
71225
|
-
start
|
|
71308
|
+
start,
|
|
71309
|
+
mode: paginateMode
|
|
71226
71310
|
};
|
|
71227
71311
|
if (!fragment) {
|
|
71228
71312
|
continue;
|
|
@@ -71571,7 +71655,9 @@ async function addListFragments(config4, documents) {
|
|
|
71571
71655
|
doc.document = graphql11.visit(doc.document, {
|
|
71572
71656
|
Directive(node, key, parent, path2, ancestors) {
|
|
71573
71657
|
if ([config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
|
|
71574
|
-
const nameArg = node.arguments?.find(
|
|
71658
|
+
const nameArg = node.arguments?.find(
|
|
71659
|
+
(arg) => arg.name.value === config4.listOrPaginateNameArg
|
|
71660
|
+
);
|
|
71575
71661
|
let error = {
|
|
71576
71662
|
...new graphql11.GraphQLError(
|
|
71577
71663
|
"",
|
|
@@ -71871,14 +71957,23 @@ function fieldKey(config4, field) {
|
|
|
71871
71957
|
const attributeName = field.alias?.value || field.name.value;
|
|
71872
71958
|
const printed = graphql12.print(field);
|
|
71873
71959
|
const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
71874
|
-
|
|
71960
|
+
let paginateMode = config4.defaultPaginateMode;
|
|
71961
|
+
const paginatedDirective = field.directives?.find(
|
|
71875
71962
|
(directive) => directive.name.value === config4.paginateDirective
|
|
71876
71963
|
);
|
|
71877
|
-
|
|
71964
|
+
if (paginatedDirective) {
|
|
71965
|
+
const paginateModeArg = paginatedDirective?.arguments?.find(
|
|
71966
|
+
(arg) => arg.name.value === config4.paginateModeArg
|
|
71967
|
+
);
|
|
71968
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
71969
|
+
paginateMode = paginateModeArg.value.value;
|
|
71970
|
+
}
|
|
71971
|
+
}
|
|
71972
|
+
const paginationArgs = paginateMode === "SinglePage" ? [] : ["first", "after", "last", "before", "limit", "offset"];
|
|
71878
71973
|
const argObj = (secondParse.arguments || []).reduce((acc, arg) => {
|
|
71879
71974
|
const start = arg.value.loc?.start;
|
|
71880
71975
|
const end = arg.value.loc?.end;
|
|
71881
|
-
if (
|
|
71976
|
+
if (paginatedDirective && paginationArgs.includes(arg.name.value)) {
|
|
71882
71977
|
return acc;
|
|
71883
71978
|
}
|
|
71884
71979
|
if (!start || !end) {
|
|
@@ -71892,7 +71987,7 @@ function fieldKey(config4, field) {
|
|
|
71892
71987
|
const args = Object.keys(argObj);
|
|
71893
71988
|
args.sort();
|
|
71894
71989
|
let key = Object.values(argObj).length > 0 ? `${attributeName}(${args.map((key2) => `${key2}: ${argObj[key2]}`).join(", ")})` : attributeName;
|
|
71895
|
-
if (
|
|
71990
|
+
if (paginatedDirective) {
|
|
71896
71991
|
key = key + "::paginated";
|
|
71897
71992
|
}
|
|
71898
71993
|
return key;
|
|
@@ -72032,7 +72127,9 @@ function selection({
|
|
|
72032
72127
|
const listDirective = field.directives?.find(
|
|
72033
72128
|
(directive) => [config4.listDirective, config4.paginateDirective].includes(directive.name.value)
|
|
72034
72129
|
);
|
|
72035
|
-
const nameArg = listDirective?.arguments?.find(
|
|
72130
|
+
const nameArg = listDirective?.arguments?.find(
|
|
72131
|
+
(arg) => arg.name.value === config4.listOrPaginateNameArg
|
|
72132
|
+
);
|
|
72036
72133
|
if (nameArg && nameArg.value.kind === "StringValue") {
|
|
72037
72134
|
const { connection, type: connectionType } = connectionSelection(
|
|
72038
72135
|
config4,
|
|
@@ -72151,7 +72248,7 @@ function artifactGenerator(stats) {
|
|
|
72151
72248
|
return;
|
|
72152
72249
|
}
|
|
72153
72250
|
const nameArg = node.arguments?.find(
|
|
72154
|
-
(arg) => arg.name.value === config4.
|
|
72251
|
+
(arg) => arg.name.value === config4.listOrPaginateNameArg
|
|
72155
72252
|
);
|
|
72156
72253
|
if (!nameArg || nameArg.value.kind !== "StringValue") {
|
|
72157
72254
|
throw new HoudiniError({
|
|
@@ -73521,7 +73618,9 @@ function listDefinitions(config4, body, docs) {
|
|
|
73521
73618
|
if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
|
|
73522
73619
|
return;
|
|
73523
73620
|
}
|
|
73524
|
-
const nameArg = node.arguments?.find(
|
|
73621
|
+
const nameArg = node.arguments?.find(
|
|
73622
|
+
(arg) => arg.name.value === config4.listOrPaginateNameArg
|
|
73623
|
+
);
|
|
73525
73624
|
const nameValue = nameArg?.value?.value || "";
|
|
73526
73625
|
if (!nameValue || visitedLists.has(nameValue)) {
|
|
73527
73626
|
return;
|
|
@@ -73846,17 +73945,22 @@ enum CachePolicy {
|
|
|
73846
73945
|
${CachePolicy.NetworkOnly}
|
|
73847
73946
|
}
|
|
73848
73947
|
|
|
73948
|
+
enum PaginateMode {
|
|
73949
|
+
${PaginateMode.Infinite}
|
|
73950
|
+
${PaginateMode.SinglePage}
|
|
73951
|
+
}
|
|
73952
|
+
|
|
73849
73953
|
"""
|
|
73850
73954
|
@${config4.listDirective} is used to mark a field for the runtime as a place to add or remove
|
|
73851
73955
|
entities in mutations
|
|
73852
73956
|
"""
|
|
73853
|
-
directive @${config4.listDirective}(${config4.
|
|
73957
|
+
directive @${config4.listDirective}(${config4.listOrPaginateNameArg}: String!, connection: Boolean) on FIELD
|
|
73854
73958
|
|
|
73855
73959
|
"""
|
|
73856
73960
|
@${config4.paginateDirective} is used to to mark a field for pagination.
|
|
73857
73961
|
More info in the [doc](${siteURL}/guides/pagination).
|
|
73858
73962
|
"""
|
|
73859
|
-
directive @${config4.paginateDirective}(${config4.
|
|
73963
|
+
directive @${config4.paginateDirective}(${config4.listOrPaginateNameArg}: String, ${config4.paginateModeArg}: PaginateMode) on FIELD
|
|
73860
73964
|
|
|
73861
73965
|
"""
|
|
73862
73966
|
@${config4.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
@@ -74122,7 +74226,7 @@ async function typeCheck(config4, docs) {
|
|
|
74122
74226
|
}
|
|
74123
74227
|
needsParent = needsParent || definition.kind === "FragmentDefinition";
|
|
74124
74228
|
const nameArg = directive.arguments?.find(
|
|
74125
|
-
({ name }) => name.value === config4.
|
|
74229
|
+
({ name }) => name.value === config4.listOrPaginateNameArg
|
|
74126
74230
|
);
|
|
74127
74231
|
if (!nameArg) {
|
|
74128
74232
|
if (directive.name.value === config4.listDirective) {
|
|
@@ -74602,7 +74706,14 @@ function paginateArgs(config4, filepath) {
|
|
|
74602
74706
|
)
|
|
74603
74707
|
);
|
|
74604
74708
|
}
|
|
74605
|
-
|
|
74709
|
+
const paginateModeArg = node?.arguments?.find(
|
|
74710
|
+
(arg) => arg.name.value === config4.paginateModeArg
|
|
74711
|
+
);
|
|
74712
|
+
let paginateMode = config4.defaultPaginateMode;
|
|
74713
|
+
if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
|
|
74714
|
+
paginateMode = paginateModeArg.value.value;
|
|
74715
|
+
}
|
|
74716
|
+
if (forward && backwards && paginateMode === "Infinite") {
|
|
74606
74717
|
ctx.reportError(
|
|
74607
74718
|
new graphql25.GraphQLError(
|
|
74608
74719
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "The disappearing GraphQL clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"@types/node": "^18.7.23",
|
|
23
23
|
"prettier": "^2.8.3",
|
|
24
24
|
"rollup": "^3.7.4",
|
|
25
|
-
"turbo": "^1.5.4",
|
|
26
25
|
"vite": "^4.1.1",
|
|
27
26
|
"vitest": "^0.28.3",
|
|
28
27
|
"scripts": "^1.0.0"
|