houdini 1.2.44 → 1.2.45
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 +651 -844
- package/build/cmd-esm/index.js +501 -694
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen-cjs/index.js +649 -842
- package/build/codegen-esm/index.js +499 -692
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/typescript.d.ts +19 -0
- package/build/lib-cjs/index.js +667 -464
- package/build/lib-esm/index.js +661 -464
- package/build/runtime/client/index.d.ts +7 -1
- package/build/runtime/client/plugins/fragment.d.ts +2 -2
- package/build/runtime/client/plugins/mutation.d.ts +2 -1
- package/build/runtime/client/plugins/query.d.ts +2 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +13 -2
- package/build/runtime/router/types.d.ts +3 -1
- package/build/runtime-cjs/client/index.d.ts +7 -1
- package/build/runtime-cjs/client/index.js +26 -11
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/fragment.js +4 -11
- package/build/runtime-cjs/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-cjs/client/plugins/mutation.js +8 -15
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/query.js +4 -11
- package/build/runtime-cjs/lib/scalars.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.js +4 -0
- package/build/runtime-cjs/lib/types.d.ts +13 -2
- package/build/runtime-cjs/router/types.d.ts +3 -1
- package/build/runtime-esm/client/index.d.ts +7 -1
- package/build/runtime-esm/client/index.js +26 -11
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-esm/client/plugins/fragment.js +1 -2
- package/build/runtime-esm/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-esm/client/plugins/mutation.js +1 -2
- package/build/runtime-esm/client/plugins/query.d.ts +2 -2
- package/build/runtime-esm/client/plugins/query.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.js +6 -0
- package/build/runtime-esm/lib/types.d.ts +13 -2
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +664 -840
- package/build/test-esm/index.js +514 -690
- package/build/vite-cjs/index.js +761 -852
- package/build/vite-esm/index.js +611 -702
- package/package.json +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +0 -8
- package/build/codegen/generators/typescript/types.d.ts +0 -10
package/build/vite-esm/index.js
CHANGED
|
@@ -61315,7 +61315,7 @@ function watchAndRun(params) {
|
|
|
61315
61315
|
}
|
|
61316
61316
|
|
|
61317
61317
|
// src/codegen/index.ts
|
|
61318
|
-
import * as
|
|
61318
|
+
import * as graphql32 from "graphql";
|
|
61319
61319
|
|
|
61320
61320
|
// src/lib/pipeline.ts
|
|
61321
61321
|
async function runPipeline(config2, pipeline2, target) {
|
|
@@ -64576,47 +64576,6 @@ function deepMerge(...objects) {
|
|
|
64576
64576
|
return mergedObj;
|
|
64577
64577
|
}
|
|
64578
64578
|
|
|
64579
|
-
// src/runtime/lib/scalars.ts
|
|
64580
|
-
async function marshalSelection({
|
|
64581
|
-
selection,
|
|
64582
|
-
data
|
|
64583
|
-
}) {
|
|
64584
|
-
const config2 = getCurrentConfig();
|
|
64585
|
-
if (data === null || typeof data === "undefined") {
|
|
64586
|
-
return data;
|
|
64587
|
-
}
|
|
64588
|
-
if (Array.isArray(data)) {
|
|
64589
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
64590
|
-
}
|
|
64591
|
-
const targetSelection = getFieldsForType(selection, data["__typename"], false);
|
|
64592
|
-
return Object.fromEntries(
|
|
64593
|
-
await Promise.all(
|
|
64594
|
-
Object.entries(data).map(async ([fieldName, value]) => {
|
|
64595
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
64596
|
-
if (!type) {
|
|
64597
|
-
return [fieldName, value];
|
|
64598
|
-
}
|
|
64599
|
-
if (selection2) {
|
|
64600
|
-
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
64601
|
-
}
|
|
64602
|
-
if (config2.scalars?.[type]) {
|
|
64603
|
-
const marshalFn = config2.scalars[type].marshal;
|
|
64604
|
-
if (!marshalFn) {
|
|
64605
|
-
throw new Error(
|
|
64606
|
-
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
64607
|
-
);
|
|
64608
|
-
}
|
|
64609
|
-
if (Array.isArray(value)) {
|
|
64610
|
-
return [fieldName, value.map(marshalFn)];
|
|
64611
|
-
}
|
|
64612
|
-
return [fieldName, marshalFn(value)];
|
|
64613
|
-
}
|
|
64614
|
-
return [fieldName, value];
|
|
64615
|
-
})
|
|
64616
|
-
)
|
|
64617
|
-
);
|
|
64618
|
-
}
|
|
64619
|
-
|
|
64620
64579
|
// src/runtime/lib/types.ts
|
|
64621
64580
|
var CachePolicy = {
|
|
64622
64581
|
CacheOrNetwork: "CacheOrNetwork",
|
|
@@ -64644,11 +64603,6 @@ var RefetchUpdateMode = {
|
|
|
64644
64603
|
prepend: "prepend",
|
|
64645
64604
|
replace: "replace"
|
|
64646
64605
|
};
|
|
64647
|
-
var DataSource = {
|
|
64648
|
-
Cache: "cache",
|
|
64649
|
-
Network: "network",
|
|
64650
|
-
Ssr: "ssr"
|
|
64651
|
-
};
|
|
64652
64606
|
var fragmentKey = " $fragments";
|
|
64653
64607
|
var PendingValue = Symbol("houdini_loading");
|
|
64654
64608
|
|
|
@@ -68419,202 +68373,6 @@ var cache_default = new Cache();
|
|
|
68419
68373
|
// src/runtime/client/plugins/cache.ts
|
|
68420
68374
|
var serverSide = typeof globalThis.window === "undefined";
|
|
68421
68375
|
|
|
68422
|
-
// src/runtime/client/utils/documentPlugins.ts
|
|
68423
|
-
var documentPlugin = (kind, source) => {
|
|
68424
|
-
return () => {
|
|
68425
|
-
const sourceHandlers = source();
|
|
68426
|
-
const enterWrapper = (handler) => {
|
|
68427
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
68428
|
-
if (ctx.artifact.kind !== kind) {
|
|
68429
|
-
return handlers.next(ctx);
|
|
68430
|
-
}
|
|
68431
|
-
return handler(ctx, handlers);
|
|
68432
|
-
};
|
|
68433
|
-
};
|
|
68434
|
-
const exitWrapper = (handler) => {
|
|
68435
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
68436
|
-
if (ctx.artifact.kind !== kind) {
|
|
68437
|
-
return handlers.resolve(ctx);
|
|
68438
|
-
}
|
|
68439
|
-
return handler(ctx, handlers);
|
|
68440
|
-
};
|
|
68441
|
-
};
|
|
68442
|
-
return {
|
|
68443
|
-
start: enterWrapper(sourceHandlers.start),
|
|
68444
|
-
network: enterWrapper(sourceHandlers.network),
|
|
68445
|
-
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
68446
|
-
end: exitWrapper(sourceHandlers.end),
|
|
68447
|
-
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
68448
|
-
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
68449
|
-
};
|
|
68450
|
-
};
|
|
68451
|
-
};
|
|
68452
|
-
|
|
68453
|
-
// src/runtime/client/plugins/query.ts
|
|
68454
|
-
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
68455
|
-
let subscriptionSpec = null;
|
|
68456
|
-
let lastVariables = null;
|
|
68457
|
-
return {
|
|
68458
|
-
start(ctx, { next }) {
|
|
68459
|
-
const runtimeScalarPayload = {
|
|
68460
|
-
session: ctx.session
|
|
68461
|
-
};
|
|
68462
|
-
ctx.variables = {
|
|
68463
|
-
...lastVariables,
|
|
68464
|
-
...Object.fromEntries(
|
|
68465
|
-
Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
|
|
68466
|
-
([field, type]) => {
|
|
68467
|
-
const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
|
|
68468
|
-
if (!runtimeScalar) {
|
|
68469
|
-
return [field, type];
|
|
68470
|
-
}
|
|
68471
|
-
return [field, runtimeScalar.resolve(runtimeScalarPayload)];
|
|
68472
|
-
}
|
|
68473
|
-
)
|
|
68474
|
-
),
|
|
68475
|
-
...ctx.variables
|
|
68476
|
-
};
|
|
68477
|
-
next(ctx);
|
|
68478
|
-
},
|
|
68479
|
-
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
68480
|
-
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
68481
|
-
if (subscriptionSpec) {
|
|
68482
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
68483
|
-
}
|
|
68484
|
-
lastVariables = { ...marshalVariables(ctx) };
|
|
68485
|
-
const variables = lastVariables;
|
|
68486
|
-
subscriptionSpec = {
|
|
68487
|
-
rootType: ctx.artifact.rootType,
|
|
68488
|
-
selection: ctx.artifact.selection,
|
|
68489
|
-
variables: () => variables,
|
|
68490
|
-
set: (newValue) => {
|
|
68491
|
-
resolve2(ctx, {
|
|
68492
|
-
data: newValue,
|
|
68493
|
-
errors: null,
|
|
68494
|
-
fetching: false,
|
|
68495
|
-
partial: false,
|
|
68496
|
-
stale: false,
|
|
68497
|
-
source: DataSource.Cache,
|
|
68498
|
-
variables: ctx.variables ?? {}
|
|
68499
|
-
});
|
|
68500
|
-
}
|
|
68501
|
-
};
|
|
68502
|
-
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
68503
|
-
}
|
|
68504
|
-
resolve2(ctx);
|
|
68505
|
-
},
|
|
68506
|
-
cleanup() {
|
|
68507
|
-
if (subscriptionSpec) {
|
|
68508
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
68509
|
-
lastVariables = null;
|
|
68510
|
-
}
|
|
68511
|
-
}
|
|
68512
|
-
};
|
|
68513
|
-
});
|
|
68514
|
-
|
|
68515
|
-
// src/runtime/client/plugins/fragment.ts
|
|
68516
|
-
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
68517
|
-
let subscriptionSpec = null;
|
|
68518
|
-
let lastReference = null;
|
|
68519
|
-
return {
|
|
68520
|
-
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
68521
|
-
if (!ctx.stuff.parentID) {
|
|
68522
|
-
return next(ctx);
|
|
68523
|
-
}
|
|
68524
|
-
const currentReference = {
|
|
68525
|
-
parent: ctx.stuff.parentID,
|
|
68526
|
-
variables: marshalVariables(ctx)
|
|
68527
|
-
};
|
|
68528
|
-
if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
68529
|
-
if (subscriptionSpec) {
|
|
68530
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
68531
|
-
}
|
|
68532
|
-
const variables = marshalVariables(ctx);
|
|
68533
|
-
subscriptionSpec = {
|
|
68534
|
-
rootType: ctx.artifact.rootType,
|
|
68535
|
-
selection: ctx.artifact.selection,
|
|
68536
|
-
variables: () => variables,
|
|
68537
|
-
parentID: ctx.stuff.parentID,
|
|
68538
|
-
set: (newValue) => {
|
|
68539
|
-
resolve2(ctx, {
|
|
68540
|
-
data: newValue,
|
|
68541
|
-
errors: null,
|
|
68542
|
-
fetching: false,
|
|
68543
|
-
partial: false,
|
|
68544
|
-
stale: false,
|
|
68545
|
-
source: DataSource.Cache,
|
|
68546
|
-
variables
|
|
68547
|
-
});
|
|
68548
|
-
}
|
|
68549
|
-
};
|
|
68550
|
-
cache_default.subscribe(subscriptionSpec, variables);
|
|
68551
|
-
lastReference = currentReference;
|
|
68552
|
-
}
|
|
68553
|
-
next(ctx);
|
|
68554
|
-
},
|
|
68555
|
-
cleanup() {
|
|
68556
|
-
if (subscriptionSpec) {
|
|
68557
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
68558
|
-
}
|
|
68559
|
-
}
|
|
68560
|
-
};
|
|
68561
|
-
});
|
|
68562
|
-
|
|
68563
|
-
// src/runtime/client/plugins/mutation.ts
|
|
68564
|
-
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
68565
|
-
return {
|
|
68566
|
-
async start(ctx, { next, marshalVariables }) {
|
|
68567
|
-
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
68568
|
-
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
68569
|
-
let toNotify = [];
|
|
68570
|
-
if (optimisticResponse) {
|
|
68571
|
-
toNotify = cache_default.write({
|
|
68572
|
-
selection: ctx.artifact.selection,
|
|
68573
|
-
data: await marshalSelection({
|
|
68574
|
-
selection: ctx.artifact.selection,
|
|
68575
|
-
data: optimisticResponse
|
|
68576
|
-
}),
|
|
68577
|
-
variables: marshalVariables(ctx),
|
|
68578
|
-
layer: layerOptimistic.id
|
|
68579
|
-
});
|
|
68580
|
-
}
|
|
68581
|
-
ctx.cacheParams = {
|
|
68582
|
-
...ctx.cacheParams,
|
|
68583
|
-
layer: layerOptimistic,
|
|
68584
|
-
notifySubscribers: toNotify,
|
|
68585
|
-
forceNotify: true
|
|
68586
|
-
};
|
|
68587
|
-
next(ctx);
|
|
68588
|
-
},
|
|
68589
|
-
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
68590
|
-
if (ctx.cacheParams?.layer) {
|
|
68591
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
68592
|
-
}
|
|
68593
|
-
resolve2(ctx);
|
|
68594
|
-
},
|
|
68595
|
-
end(ctx, { resolve: resolve2, value }) {
|
|
68596
|
-
const hasErrors = value.errors && value.errors.length > 0;
|
|
68597
|
-
if (hasErrors) {
|
|
68598
|
-
if (ctx.cacheParams?.layer) {
|
|
68599
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
68600
|
-
}
|
|
68601
|
-
}
|
|
68602
|
-
if (ctx.cacheParams?.layer) {
|
|
68603
|
-
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
68604
|
-
}
|
|
68605
|
-
resolve2(ctx);
|
|
68606
|
-
},
|
|
68607
|
-
catch(ctx, { error }) {
|
|
68608
|
-
if (ctx.cacheParams?.layer) {
|
|
68609
|
-
const { layer } = ctx.cacheParams;
|
|
68610
|
-
cache_default.clearLayer(layer.id);
|
|
68611
|
-
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
68612
|
-
}
|
|
68613
|
-
throw error;
|
|
68614
|
-
}
|
|
68615
|
-
};
|
|
68616
|
-
});
|
|
68617
|
-
|
|
68618
68376
|
// src/lib/types.ts
|
|
68619
68377
|
var LogLevel = {
|
|
68620
68378
|
Full: "full",
|
|
@@ -69627,7 +69385,7 @@ function formatErrors(e2, afterError) {
|
|
|
69627
69385
|
afterError?.(e2);
|
|
69628
69386
|
}
|
|
69629
69387
|
}
|
|
69630
|
-
function unwrapType(config2, type, wrappers = []) {
|
|
69388
|
+
function unwrapType(config2, type, wrappers = [], convertRuntimeScalars) {
|
|
69631
69389
|
if (type.kind === "NonNullType") {
|
|
69632
69390
|
return unwrapType(config2, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
69633
69391
|
}
|
|
@@ -69643,6 +69401,11 @@ function unwrapType(config2, type, wrappers = []) {
|
|
|
69643
69401
|
if (type instanceof graphql3.GraphQLList) {
|
|
69644
69402
|
return unwrapType(config2, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
69645
69403
|
}
|
|
69404
|
+
if (convertRuntimeScalars && config2.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
69405
|
+
type = config2.schema.getType(
|
|
69406
|
+
config2.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
69407
|
+
);
|
|
69408
|
+
}
|
|
69646
69409
|
const namedType = config2.schema.getType(type.name.value || type.name);
|
|
69647
69410
|
if (!namedType) {
|
|
69648
69411
|
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
@@ -69782,6 +69545,231 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
69782
69545
|
return allFilesNotInList;
|
|
69783
69546
|
}
|
|
69784
69547
|
|
|
69548
|
+
// src/runtime/router/match.ts
|
|
69549
|
+
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
69550
|
+
function parse_page_pattern(id) {
|
|
69551
|
+
const params = [];
|
|
69552
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
69553
|
+
`^${get_route_segments(id).map((segment) => {
|
|
69554
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
69555
|
+
if (rest_match) {
|
|
69556
|
+
params.push({
|
|
69557
|
+
name: rest_match[1],
|
|
69558
|
+
matcher: rest_match[2],
|
|
69559
|
+
optional: false,
|
|
69560
|
+
rest: true,
|
|
69561
|
+
chained: true
|
|
69562
|
+
});
|
|
69563
|
+
return "(?:/(.*))?";
|
|
69564
|
+
}
|
|
69565
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
69566
|
+
if (optional_match) {
|
|
69567
|
+
params.push({
|
|
69568
|
+
name: optional_match[1],
|
|
69569
|
+
matcher: optional_match[2],
|
|
69570
|
+
optional: true,
|
|
69571
|
+
rest: false,
|
|
69572
|
+
chained: true
|
|
69573
|
+
});
|
|
69574
|
+
return "(?:/([^/]+))?";
|
|
69575
|
+
}
|
|
69576
|
+
if (!segment) {
|
|
69577
|
+
return;
|
|
69578
|
+
}
|
|
69579
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
69580
|
+
const result = parts.map((content, i2) => {
|
|
69581
|
+
if (i2 % 2) {
|
|
69582
|
+
if (content.startsWith("x+")) {
|
|
69583
|
+
return escape2(
|
|
69584
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
69585
|
+
);
|
|
69586
|
+
}
|
|
69587
|
+
if (content.startsWith("u+")) {
|
|
69588
|
+
return escape2(
|
|
69589
|
+
String.fromCharCode(
|
|
69590
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
69591
|
+
)
|
|
69592
|
+
);
|
|
69593
|
+
}
|
|
69594
|
+
const match = param_pattern.exec(content);
|
|
69595
|
+
if (!match) {
|
|
69596
|
+
throw new Error(
|
|
69597
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
69598
|
+
);
|
|
69599
|
+
}
|
|
69600
|
+
const [, is_optional, is_rest, name, matcher] = match;
|
|
69601
|
+
params.push({
|
|
69602
|
+
name,
|
|
69603
|
+
matcher,
|
|
69604
|
+
optional: !!is_optional,
|
|
69605
|
+
rest: !!is_rest,
|
|
69606
|
+
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
69607
|
+
});
|
|
69608
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
69609
|
+
}
|
|
69610
|
+
return escape2(content);
|
|
69611
|
+
}).join("");
|
|
69612
|
+
return "/" + result;
|
|
69613
|
+
}).join("")}/?$`
|
|
69614
|
+
);
|
|
69615
|
+
return { pattern, params, page_id: id };
|
|
69616
|
+
}
|
|
69617
|
+
function affects_path(segment) {
|
|
69618
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
69619
|
+
}
|
|
69620
|
+
function get_route_segments(route) {
|
|
69621
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
69622
|
+
}
|
|
69623
|
+
function escape2(str) {
|
|
69624
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
69625
|
+
}
|
|
69626
|
+
|
|
69627
|
+
// src/lib/typescript.ts
|
|
69628
|
+
var recast2 = __toESM(require_main2(), 1);
|
|
69629
|
+
import * as graphql4 from "graphql";
|
|
69630
|
+
var AST2 = recast2.types.builders;
|
|
69631
|
+
function unwrappedTsTypeReference(config2, filepath, missingScalars, {
|
|
69632
|
+
type,
|
|
69633
|
+
wrappers
|
|
69634
|
+
}, body) {
|
|
69635
|
+
let result;
|
|
69636
|
+
if (graphql4.isScalarType(type)) {
|
|
69637
|
+
result = scalarPropertyValue(config2, filepath, missingScalars, type, body, null);
|
|
69638
|
+
} else if (graphql4.isEnumType(type)) {
|
|
69639
|
+
result = enumReference(config2, body, type.name);
|
|
69640
|
+
} else {
|
|
69641
|
+
result = AST2.tsTypeReference(AST2.identifier(type.name));
|
|
69642
|
+
}
|
|
69643
|
+
for (const toWrap of wrappers) {
|
|
69644
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
69645
|
+
continue;
|
|
69646
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
69647
|
+
result = nullableField(result, true);
|
|
69648
|
+
} else if (toWrap === "List" /* List */) {
|
|
69649
|
+
result = AST2.tsArrayType(AST2.tsParenthesizedType(result));
|
|
69650
|
+
}
|
|
69651
|
+
}
|
|
69652
|
+
return result;
|
|
69653
|
+
}
|
|
69654
|
+
function tsTypeReference(config2, filepath, missingScalars, definition, body) {
|
|
69655
|
+
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
69656
|
+
return unwrappedTsTypeReference(
|
|
69657
|
+
config2,
|
|
69658
|
+
filepath,
|
|
69659
|
+
missingScalars,
|
|
69660
|
+
{ type, wrappers },
|
|
69661
|
+
body
|
|
69662
|
+
);
|
|
69663
|
+
}
|
|
69664
|
+
function enumReference(config2, body, name) {
|
|
69665
|
+
ensureImports({
|
|
69666
|
+
config: config2,
|
|
69667
|
+
body,
|
|
69668
|
+
import: ["ValueOf"],
|
|
69669
|
+
importKind: "type",
|
|
69670
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
69671
|
+
});
|
|
69672
|
+
return AST2.tsTypeReference(
|
|
69673
|
+
AST2.identifier("ValueOf"),
|
|
69674
|
+
AST2.tsTypeParameterInstantiation([AST2.tsTypeQuery(AST2.identifier(name))])
|
|
69675
|
+
);
|
|
69676
|
+
}
|
|
69677
|
+
function readonlyProperty(prop, enable = true) {
|
|
69678
|
+
if (enable) {
|
|
69679
|
+
prop.readonly = true;
|
|
69680
|
+
}
|
|
69681
|
+
return prop;
|
|
69682
|
+
}
|
|
69683
|
+
function nullableField(inner, input = false) {
|
|
69684
|
+
const members = [inner, AST2.tsNullKeyword()];
|
|
69685
|
+
if (input) {
|
|
69686
|
+
members.push(AST2.tsUndefinedKeyword());
|
|
69687
|
+
}
|
|
69688
|
+
return AST2.tsUnionType(members);
|
|
69689
|
+
}
|
|
69690
|
+
function scalarPropertyValue(config2, filepath, missingScalars, target, body, field) {
|
|
69691
|
+
if (config2.configFile.features?.componentFields && target.name === config2.componentScalar) {
|
|
69692
|
+
if (!field) {
|
|
69693
|
+
return AST2.tsNeverKeyword();
|
|
69694
|
+
}
|
|
69695
|
+
const component = config2.componentFields[field.parent][field.field];
|
|
69696
|
+
const sourcePathRelative = path_exports.relative(
|
|
69697
|
+
path_exports.join(config2.projectRoot, "src"),
|
|
69698
|
+
component.filepath
|
|
69699
|
+
);
|
|
69700
|
+
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
69701
|
+
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
69702
|
+
const localImport = ensureImports({
|
|
69703
|
+
config: config2,
|
|
69704
|
+
body,
|
|
69705
|
+
import: "__component__" + component.fragment,
|
|
69706
|
+
sourceModule: path_exports.join(
|
|
69707
|
+
path_exports.relative(path_exports.dirname(filepath), config2.projectRoot),
|
|
69708
|
+
"src",
|
|
69709
|
+
sourcePath
|
|
69710
|
+
)
|
|
69711
|
+
}) ?? "__component__" + component.fragment;
|
|
69712
|
+
const parameters = AST2.tsTypeReference(AST2.identifier("Parameters"));
|
|
69713
|
+
parameters.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69714
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
69715
|
+
]);
|
|
69716
|
+
const indexed = AST2.tsIndexedAccessType(
|
|
69717
|
+
parameters,
|
|
69718
|
+
AST2.tsLiteralType(AST2.numericLiteral(0))
|
|
69719
|
+
);
|
|
69720
|
+
const omit = AST2.tsTypeReference(AST2.identifier("Omit"));
|
|
69721
|
+
omit.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69722
|
+
indexed,
|
|
69723
|
+
AST2.tsLiteralType(AST2.stringLiteral(component.prop))
|
|
69724
|
+
]);
|
|
69725
|
+
const arg = AST2.identifier("props");
|
|
69726
|
+
arg.typeAnnotation = AST2.tsTypeAnnotation(omit);
|
|
69727
|
+
const returnType = AST2.tsTypeReference(AST2.identifier("ReturnType"));
|
|
69728
|
+
returnType.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69729
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
69730
|
+
]);
|
|
69731
|
+
const fnType = AST2.tsFunctionType([arg]);
|
|
69732
|
+
fnType.typeAnnotation = AST2.tsTypeAnnotation(returnType);
|
|
69733
|
+
return fnType;
|
|
69734
|
+
}
|
|
69735
|
+
switch (target.name) {
|
|
69736
|
+
case "String": {
|
|
69737
|
+
return AST2.tsStringKeyword();
|
|
69738
|
+
}
|
|
69739
|
+
case "Int": {
|
|
69740
|
+
return AST2.tsNumberKeyword();
|
|
69741
|
+
}
|
|
69742
|
+
case "Float": {
|
|
69743
|
+
return AST2.tsNumberKeyword();
|
|
69744
|
+
}
|
|
69745
|
+
case "Boolean": {
|
|
69746
|
+
return AST2.tsBooleanKeyword();
|
|
69747
|
+
}
|
|
69748
|
+
case "ID": {
|
|
69749
|
+
return AST2.tsStringKeyword();
|
|
69750
|
+
}
|
|
69751
|
+
default: {
|
|
69752
|
+
if (graphql4.isNonNullType(target) && "ofType" in target) {
|
|
69753
|
+
return scalarPropertyValue(
|
|
69754
|
+
config2,
|
|
69755
|
+
filepath,
|
|
69756
|
+
missingScalars,
|
|
69757
|
+
target.ofType,
|
|
69758
|
+
body,
|
|
69759
|
+
field
|
|
69760
|
+
);
|
|
69761
|
+
}
|
|
69762
|
+
if (config2.scalars?.[target.name]) {
|
|
69763
|
+
return AST2.tsTypeReference(AST2.identifier(config2.scalars?.[target.name].type));
|
|
69764
|
+
}
|
|
69765
|
+
if (target.name !== config2.componentScalar) {
|
|
69766
|
+
missingScalars.add(target.name);
|
|
69767
|
+
}
|
|
69768
|
+
return AST2.tsAnyKeyword();
|
|
69769
|
+
}
|
|
69770
|
+
}
|
|
69771
|
+
}
|
|
69772
|
+
|
|
69785
69773
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
69786
69774
|
var WalkerBase = class {
|
|
69787
69775
|
constructor() {
|
|
@@ -69895,7 +69883,7 @@ async function asyncWalk(ast, { enter, leave }) {
|
|
|
69895
69883
|
}
|
|
69896
69884
|
|
|
69897
69885
|
// src/lib/walk.ts
|
|
69898
|
-
import * as
|
|
69886
|
+
import * as graphql5 from "graphql";
|
|
69899
69887
|
async function find_graphql(config2, parsedScript, walker) {
|
|
69900
69888
|
await asyncWalk(parsedScript, {
|
|
69901
69889
|
async enter(node, parent2) {
|
|
@@ -69950,7 +69938,7 @@ async function find_graphql(config2, parsedScript, walker) {
|
|
|
69950
69938
|
} else if (!documentString) {
|
|
69951
69939
|
return;
|
|
69952
69940
|
}
|
|
69953
|
-
const parsedTag =
|
|
69941
|
+
const parsedTag = graphql5.parse(documentString);
|
|
69954
69942
|
if (walker.where && !walker.where(parsedTag, { node, parent: parent2 })) {
|
|
69955
69943
|
return;
|
|
69956
69944
|
}
|
|
@@ -70082,7 +70070,7 @@ function extractAnonymousQuery(config2, raw, expr, propName) {
|
|
|
70082
70070
|
};
|
|
70083
70071
|
return defs.concat([
|
|
70084
70072
|
{
|
|
70085
|
-
raw:
|
|
70073
|
+
raw: graphql5.print(parsed),
|
|
70086
70074
|
parsed
|
|
70087
70075
|
}
|
|
70088
70076
|
]);
|
|
@@ -70223,7 +70211,7 @@ function serialized_manifest_path(config2, base = base_dir(config2)) {
|
|
|
70223
70211
|
|
|
70224
70212
|
// src/lib/router/manifest.ts
|
|
70225
70213
|
var t2 = __toESM(require_lib6(), 1);
|
|
70226
|
-
import * as
|
|
70214
|
+
import * as graphql6 from "graphql";
|
|
70227
70215
|
async function load_manifest(args) {
|
|
70228
70216
|
const manifest = await walk_routes({
|
|
70229
70217
|
config: args.config,
|
|
@@ -70240,7 +70228,8 @@ async function load_manifest(args) {
|
|
|
70240
70228
|
local_yoga: false
|
|
70241
70229
|
},
|
|
70242
70230
|
queries: [],
|
|
70243
|
-
layouts: []
|
|
70231
|
+
layouts: [],
|
|
70232
|
+
variables: {}
|
|
70244
70233
|
});
|
|
70245
70234
|
if (args.includeArtifacts) {
|
|
70246
70235
|
try {
|
|
@@ -70271,6 +70260,7 @@ async function walk_routes(args) {
|
|
|
70271
70260
|
const directory_contents = await fs_exports.readdir(args.filepath, {
|
|
70272
70261
|
withFileTypes: true
|
|
70273
70262
|
});
|
|
70263
|
+
const variables = { ...args.variables };
|
|
70274
70264
|
let newLayouts = args.layouts;
|
|
70275
70265
|
let newLayoutQueries = args.queries;
|
|
70276
70266
|
let layout = null;
|
|
@@ -70294,7 +70284,8 @@ async function walk_routes(args) {
|
|
|
70294
70284
|
url: args.url,
|
|
70295
70285
|
project: args.project,
|
|
70296
70286
|
type: "layout",
|
|
70297
|
-
contents: layoutQueryContents
|
|
70287
|
+
contents: layoutQueryContents,
|
|
70288
|
+
variables
|
|
70298
70289
|
});
|
|
70299
70290
|
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
70300
70291
|
}
|
|
@@ -70307,7 +70298,8 @@ async function walk_routes(args) {
|
|
|
70307
70298
|
contents: layoutViewContents,
|
|
70308
70299
|
layouts: args.layouts,
|
|
70309
70300
|
queries: newLayoutQueries,
|
|
70310
|
-
config: args.config
|
|
70301
|
+
config: args.config,
|
|
70302
|
+
variables
|
|
70311
70303
|
});
|
|
70312
70304
|
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
70313
70305
|
}
|
|
@@ -70318,7 +70310,8 @@ async function walk_routes(args) {
|
|
|
70318
70310
|
url: args.url,
|
|
70319
70311
|
project: args.project,
|
|
70320
70312
|
type: "page",
|
|
70321
|
-
contents: pageQueryContents
|
|
70313
|
+
contents: pageQueryContents,
|
|
70314
|
+
variables
|
|
70322
70315
|
});
|
|
70323
70316
|
}
|
|
70324
70317
|
if (pageViewContents) {
|
|
@@ -70330,7 +70323,8 @@ async function walk_routes(args) {
|
|
|
70330
70323
|
contents: pageViewContents,
|
|
70331
70324
|
layouts: newLayouts,
|
|
70332
70325
|
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
70333
|
-
config: args.config
|
|
70326
|
+
config: args.config,
|
|
70327
|
+
variables
|
|
70334
70328
|
});
|
|
70335
70329
|
}
|
|
70336
70330
|
await Promise.all(
|
|
@@ -70343,7 +70337,8 @@ async function walk_routes(args) {
|
|
|
70343
70337
|
filepath: path_exports.join(args.filepath, dir.name),
|
|
70344
70338
|
url: `${args.url}${dir.name}/`,
|
|
70345
70339
|
queries: newLayoutQueries,
|
|
70346
|
-
layouts: newLayouts
|
|
70340
|
+
layouts: newLayouts,
|
|
70341
|
+
variables
|
|
70347
70342
|
});
|
|
70348
70343
|
})
|
|
70349
70344
|
);
|
|
@@ -70365,12 +70360,18 @@ async function add_view(args) {
|
|
|
70365
70360
|
url: args.url,
|
|
70366
70361
|
layouts: args.layouts,
|
|
70367
70362
|
path: path_exports.relative(args.config.projectRoot, args.path),
|
|
70368
|
-
query_options: args.queries
|
|
70363
|
+
query_options: args.queries,
|
|
70364
|
+
params: Object.fromEntries(
|
|
70365
|
+
parse_page_pattern(args.url).params.map((param) => [
|
|
70366
|
+
param.name,
|
|
70367
|
+
args.variables[param.name] ?? null
|
|
70368
|
+
])
|
|
70369
|
+
)
|
|
70369
70370
|
};
|
|
70370
70371
|
return target[id];
|
|
70371
70372
|
}
|
|
70372
70373
|
async function add_query(args) {
|
|
70373
|
-
const parsed =
|
|
70374
|
+
const parsed = graphql6.parse(args.contents);
|
|
70374
70375
|
const query2 = parsed.definitions.find(
|
|
70375
70376
|
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
70376
70377
|
);
|
|
@@ -70378,20 +70379,30 @@ async function add_query(args) {
|
|
|
70378
70379
|
throw new Error("No query found");
|
|
70379
70380
|
}
|
|
70380
70381
|
let loading = false;
|
|
70381
|
-
await
|
|
70382
|
+
await graphql6.visit(parsed, {
|
|
70382
70383
|
Directive(node) {
|
|
70383
70384
|
if (node.name.value === args.config.loadingDirective) {
|
|
70384
70385
|
loading = true;
|
|
70385
70386
|
}
|
|
70386
70387
|
}
|
|
70387
70388
|
});
|
|
70389
|
+
const queryVariables = Object.fromEntries(
|
|
70390
|
+
query2.variableDefinitions?.map((variable) => {
|
|
70391
|
+
const { type, wrappers } = unwrapType(args.config, variable.type, [], true);
|
|
70392
|
+
return [
|
|
70393
|
+
variable.variable.name.value,
|
|
70394
|
+
{ wrappers, type: type.name }
|
|
70395
|
+
];
|
|
70396
|
+
}) ?? []
|
|
70397
|
+
);
|
|
70398
|
+
Object.assign(args.variables, queryVariables);
|
|
70388
70399
|
const target = args.type === "page" ? args.project.page_queries : args.project.layout_queries;
|
|
70389
70400
|
target[page_id(args.url)] = {
|
|
70390
70401
|
path: path_exports.relative(args.config.routesDir, args.path),
|
|
70391
70402
|
name: query2.name.value,
|
|
70392
70403
|
url: args.url,
|
|
70393
70404
|
loading,
|
|
70394
|
-
variables:
|
|
70405
|
+
variables: queryVariables
|
|
70395
70406
|
};
|
|
70396
70407
|
return target[page_id(args.url)];
|
|
70397
70408
|
}
|
|
@@ -70487,8 +70498,8 @@ async function loadLocalSchema(config2) {
|
|
|
70487
70498
|
}
|
|
70488
70499
|
|
|
70489
70500
|
// src/codegen/generators/artifacts/index.ts
|
|
70490
|
-
var
|
|
70491
|
-
import * as
|
|
70501
|
+
var recast5 = __toESM(require_main2(), 1);
|
|
70502
|
+
import * as graphql17 from "graphql";
|
|
70492
70503
|
|
|
70493
70504
|
// src/codegen/utils/commonjs.ts
|
|
70494
70505
|
var cjsIndexFilePreamble = `"use strict";
|
|
@@ -70730,19 +70741,19 @@ var FieldCollection = class {
|
|
|
70730
70741
|
};
|
|
70731
70742
|
|
|
70732
70743
|
// src/codegen/utils/moduleExport.ts
|
|
70733
|
-
var
|
|
70734
|
-
var
|
|
70744
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
70745
|
+
var AST3 = recast3.types.builders;
|
|
70735
70746
|
function moduleExport(config2, key, value) {
|
|
70736
70747
|
if (config2.module === "commonjs") {
|
|
70737
|
-
let target =
|
|
70748
|
+
let target = AST3.memberExpression(AST3.identifier("module"), AST3.identifier("exports"));
|
|
70738
70749
|
if (key !== "default") {
|
|
70739
|
-
target =
|
|
70750
|
+
target = AST3.memberExpression(target, AST3.identifier(key));
|
|
70740
70751
|
}
|
|
70741
|
-
return
|
|
70752
|
+
return AST3.expressionStatement(AST3.assignmentExpression("=", target, value));
|
|
70742
70753
|
}
|
|
70743
|
-
return key === "default" ?
|
|
70744
|
-
|
|
70745
|
-
|
|
70754
|
+
return key === "default" ? AST3.exportDefaultDeclaration(value) : AST3.exportNamedDeclaration(
|
|
70755
|
+
AST3.variableDeclaration("const", [
|
|
70756
|
+
AST3.variableDeclarator(AST3.identifier(key), value)
|
|
70746
70757
|
])
|
|
70747
70758
|
);
|
|
70748
70759
|
}
|
|
@@ -70999,7 +71010,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
70999
71010
|
var esm_default = typeof structuredClone === "function" ? (any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any) : (any, options) => deserialize(serialize(any, options));
|
|
71000
71011
|
|
|
71001
71012
|
// src/codegen/transforms/fragmentVariables.ts
|
|
71002
|
-
import * as
|
|
71013
|
+
import * as graphql8 from "graphql";
|
|
71003
71014
|
|
|
71004
71015
|
// src/codegen/utils/stripLoc.ts
|
|
71005
71016
|
function stripLoc(value) {
|
|
@@ -71020,7 +71031,7 @@ function stripLoc(value) {
|
|
|
71020
71031
|
}
|
|
71021
71032
|
|
|
71022
71033
|
// src/codegen/transforms/collectDefinitions.ts
|
|
71023
|
-
import * as
|
|
71034
|
+
import * as graphql7 from "graphql";
|
|
71024
71035
|
import { Kind as GraphqlKinds } from "graphql";
|
|
71025
71036
|
async function includeFragmentDefinitions(config2, documents) {
|
|
71026
71037
|
const fragments = collectDefinitions(config2, documents);
|
|
@@ -71070,10 +71081,10 @@ function collectDefinitions(config2, docs) {
|
|
|
71070
71081
|
}
|
|
71071
71082
|
function findRequiredFragments(config2, definition) {
|
|
71072
71083
|
const referencedFragments = [];
|
|
71073
|
-
const typeInfo = new
|
|
71074
|
-
definition.selectionSet =
|
|
71084
|
+
const typeInfo = new graphql7.TypeInfo(config2.schema);
|
|
71085
|
+
definition.selectionSet = graphql7.visit(
|
|
71075
71086
|
definition,
|
|
71076
|
-
|
|
71087
|
+
graphql7.visitWithTypeInfo(typeInfo, {
|
|
71077
71088
|
FragmentSpread(node) {
|
|
71078
71089
|
referencedFragments.push(node.name.value);
|
|
71079
71090
|
}
|
|
@@ -71107,7 +71118,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
71107
71118
|
}
|
|
71108
71119
|
|
|
71109
71120
|
// src/codegen/transforms/fragmentVariables.ts
|
|
71110
|
-
var GraphqlKinds2 =
|
|
71121
|
+
var GraphqlKinds2 = graphql8.Kind;
|
|
71111
71122
|
async function fragmentVariables(config2, documents) {
|
|
71112
71123
|
const fragments = collectDefinitions(config2, documents);
|
|
71113
71124
|
const generatedFragments = {};
|
|
@@ -71130,7 +71141,7 @@ async function fragmentVariables(config2, documents) {
|
|
|
71130
71141
|
});
|
|
71131
71142
|
}
|
|
71132
71143
|
const doc = {
|
|
71133
|
-
kind:
|
|
71144
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
71134
71145
|
definitions: Object.values(generatedFragments)
|
|
71135
71146
|
};
|
|
71136
71147
|
documents.push({
|
|
@@ -71201,7 +71212,7 @@ function inlineFragmentArgs({
|
|
|
71201
71212
|
return null;
|
|
71202
71213
|
};
|
|
71203
71214
|
const result = esm_default(
|
|
71204
|
-
|
|
71215
|
+
graphql8.visit(document, {
|
|
71205
71216
|
FragmentSpread(node) {
|
|
71206
71217
|
if (!fragmentDefinitions[node.name.value]) {
|
|
71207
71218
|
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
@@ -71287,7 +71298,7 @@ function inlineFragmentArgs({
|
|
|
71287
71298
|
);
|
|
71288
71299
|
if (newName) {
|
|
71289
71300
|
result.name = {
|
|
71290
|
-
kind:
|
|
71301
|
+
kind: graphql8.Kind.NAME,
|
|
71291
71302
|
value: newName
|
|
71292
71303
|
};
|
|
71293
71304
|
}
|
|
@@ -71454,7 +71465,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
71454
71465
|
}
|
|
71455
71466
|
|
|
71456
71467
|
// src/codegen/generators/artifacts/inputs.ts
|
|
71457
|
-
import * as
|
|
71468
|
+
import * as graphql9 from "graphql";
|
|
71458
71469
|
function inputObject(config2, inputs, runtimeScalars) {
|
|
71459
71470
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
71460
71471
|
const inputObj = {
|
|
@@ -71484,10 +71495,10 @@ function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
|
71484
71495
|
if (visitedTypes.has(type.name)) {
|
|
71485
71496
|
return;
|
|
71486
71497
|
}
|
|
71487
|
-
if (
|
|
71498
|
+
if (graphql9.isEnumType(type) || graphql9.isScalarType(type)) {
|
|
71488
71499
|
return;
|
|
71489
71500
|
}
|
|
71490
|
-
if (
|
|
71501
|
+
if (graphql9.isUnionType(type)) {
|
|
71491
71502
|
return;
|
|
71492
71503
|
}
|
|
71493
71504
|
visitedTypes.add(type.name);
|
|
@@ -71505,50 +71516,50 @@ function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
|
71505
71516
|
}
|
|
71506
71517
|
|
|
71507
71518
|
// src/codegen/generators/artifacts/operations.ts
|
|
71508
|
-
import * as
|
|
71519
|
+
import * as graphql11 from "graphql";
|
|
71509
71520
|
|
|
71510
71521
|
// src/codegen/generators/artifacts/utils.ts
|
|
71511
|
-
var
|
|
71512
|
-
import * as
|
|
71513
|
-
var
|
|
71522
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
71523
|
+
import * as graphql10 from "graphql";
|
|
71524
|
+
var AST4 = recast4.types.builders;
|
|
71514
71525
|
function serializeValue(value) {
|
|
71515
71526
|
if (Array.isArray(value)) {
|
|
71516
|
-
return
|
|
71527
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
71517
71528
|
}
|
|
71518
71529
|
if (typeof value === "object" && value !== null) {
|
|
71519
|
-
return
|
|
71530
|
+
return AST4.objectExpression(
|
|
71520
71531
|
Object.entries(value).filter(([key, value2]) => typeof value2 !== "undefined").map(([key, val]) => {
|
|
71521
|
-
return
|
|
71532
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
71522
71533
|
})
|
|
71523
71534
|
);
|
|
71524
71535
|
}
|
|
71525
71536
|
if (typeof value === "string") {
|
|
71526
71537
|
if (value.indexOf("\n") !== -1) {
|
|
71527
|
-
return
|
|
71528
|
-
[
|
|
71538
|
+
return AST4.templateLiteral(
|
|
71539
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
71529
71540
|
[]
|
|
71530
71541
|
);
|
|
71531
71542
|
}
|
|
71532
|
-
return
|
|
71543
|
+
return AST4.stringLiteral(value);
|
|
71533
71544
|
}
|
|
71534
|
-
return
|
|
71545
|
+
return AST4.literal(value);
|
|
71535
71546
|
}
|
|
71536
71547
|
function convertValue(config2, val) {
|
|
71537
71548
|
let value;
|
|
71538
71549
|
let kind;
|
|
71539
|
-
if (val.kind ===
|
|
71550
|
+
if (val.kind === graphql10.Kind.INT) {
|
|
71540
71551
|
value = parseInt(val.value, 10);
|
|
71541
71552
|
kind = "Int";
|
|
71542
|
-
} else if (val.kind ===
|
|
71553
|
+
} else if (val.kind === graphql10.Kind.FLOAT) {
|
|
71543
71554
|
value = parseFloat(val.value);
|
|
71544
71555
|
kind = "Float";
|
|
71545
|
-
} else if (val.kind ===
|
|
71556
|
+
} else if (val.kind === graphql10.Kind.BOOLEAN) {
|
|
71546
71557
|
value = val.value;
|
|
71547
71558
|
kind = "Boolean";
|
|
71548
|
-
} else if (val.kind ===
|
|
71559
|
+
} else if (val.kind === graphql10.Kind.VARIABLE) {
|
|
71549
71560
|
value = val.name.value;
|
|
71550
71561
|
kind = "Variable";
|
|
71551
|
-
} else if (val.kind ===
|
|
71562
|
+
} else if (val.kind === graphql10.Kind.STRING) {
|
|
71552
71563
|
value = val.value;
|
|
71553
71564
|
kind = "String";
|
|
71554
71565
|
}
|
|
@@ -71561,7 +71572,7 @@ function operationsByPath(config2, filepath, definition, filterTypes) {
|
|
|
71561
71572
|
return {};
|
|
71562
71573
|
}
|
|
71563
71574
|
const pathOperations = {};
|
|
71564
|
-
|
|
71575
|
+
graphql11.visit(definition, {
|
|
71565
71576
|
FragmentSpread(node, _, __, ___, ancestors) {
|
|
71566
71577
|
if (!config2.isListFragment(node.name.value)) {
|
|
71567
71578
|
return;
|
|
@@ -71720,19 +71731,19 @@ function ancestorKey(ancestors) {
|
|
|
71720
71731
|
}
|
|
71721
71732
|
|
|
71722
71733
|
// src/codegen/generators/artifacts/selection.ts
|
|
71723
|
-
import * as
|
|
71734
|
+
import * as graphql16 from "graphql";
|
|
71724
71735
|
|
|
71725
71736
|
// src/codegen/transforms/list.ts
|
|
71726
|
-
import * as
|
|
71737
|
+
import * as graphql14 from "graphql";
|
|
71727
71738
|
|
|
71728
71739
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
71729
|
-
import * as
|
|
71740
|
+
import * as graphql12 from "graphql";
|
|
71730
71741
|
var objectIdentificationSelection = (config2, type) => {
|
|
71731
71742
|
return config2.keyFieldsForType(type.name).map((key) => {
|
|
71732
71743
|
return {
|
|
71733
|
-
kind:
|
|
71744
|
+
kind: graphql12.Kind.FIELD,
|
|
71734
71745
|
name: {
|
|
71735
|
-
kind:
|
|
71746
|
+
kind: graphql12.Kind.NAME,
|
|
71736
71747
|
value: key
|
|
71737
71748
|
}
|
|
71738
71749
|
};
|
|
@@ -71740,7 +71751,7 @@ var objectIdentificationSelection = (config2, type) => {
|
|
|
71740
71751
|
};
|
|
71741
71752
|
|
|
71742
71753
|
// src/codegen/transforms/paginate.ts
|
|
71743
|
-
import * as
|
|
71754
|
+
import * as graphql13 from "graphql";
|
|
71744
71755
|
async function paginate(config2, documents) {
|
|
71745
71756
|
const newDocs = [];
|
|
71746
71757
|
for (const doc of documents) {
|
|
@@ -71773,7 +71784,7 @@ async function paginate(config2, documents) {
|
|
|
71773
71784
|
};
|
|
71774
71785
|
let cursorType = "String";
|
|
71775
71786
|
let paginationPath = [];
|
|
71776
|
-
doc.document =
|
|
71787
|
+
doc.document = graphql13.visit(doc.document, {
|
|
71777
71788
|
Field(node, _, __, ___, ancestors) {
|
|
71778
71789
|
const paginateDirective = node.directives?.find(
|
|
71779
71790
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -71799,7 +71810,7 @@ async function paginate(config2, documents) {
|
|
|
71799
71810
|
flags.offset.enabled = offsetPagination;
|
|
71800
71811
|
flags.limit.enabled = offsetPagination;
|
|
71801
71812
|
paginationPath = ancestors.filter(
|
|
71802
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
71813
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql13.Kind.FIELD
|
|
71803
71814
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
71804
71815
|
return {
|
|
71805
71816
|
...node,
|
|
@@ -71818,7 +71829,7 @@ async function paginate(config2, documents) {
|
|
|
71818
71829
|
let fragment2 = "";
|
|
71819
71830
|
let paginateMode = config2.defaultPaginateMode;
|
|
71820
71831
|
const requiredArgs = [];
|
|
71821
|
-
doc.document =
|
|
71832
|
+
doc.document = graphql13.visit(doc.document, {
|
|
71822
71833
|
OperationDefinition(node) {
|
|
71823
71834
|
if (node.operation !== "query") {
|
|
71824
71835
|
throw new HoudiniError({
|
|
@@ -71877,9 +71888,9 @@ async function paginate(config2, documents) {
|
|
|
71877
71888
|
directives: [
|
|
71878
71889
|
...node.directives || [],
|
|
71879
71890
|
{
|
|
71880
|
-
kind:
|
|
71891
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71881
71892
|
name: {
|
|
71882
|
-
kind:
|
|
71893
|
+
kind: graphql13.Kind.NAME,
|
|
71883
71894
|
value: config2.argumentsDirective
|
|
71884
71895
|
}
|
|
71885
71896
|
}
|
|
@@ -71949,22 +71960,22 @@ async function paginate(config2, documents) {
|
|
|
71949
71960
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
71950
71961
|
const fragmentSpreadSelection = [
|
|
71951
71962
|
{
|
|
71952
|
-
kind:
|
|
71963
|
+
kind: graphql13.Kind.FRAGMENT_SPREAD,
|
|
71953
71964
|
name: {
|
|
71954
|
-
kind:
|
|
71965
|
+
kind: graphql13.Kind.NAME,
|
|
71955
71966
|
value: fragmentName
|
|
71956
71967
|
},
|
|
71957
71968
|
directives: [
|
|
71958
71969
|
{
|
|
71959
|
-
kind:
|
|
71970
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71960
71971
|
name: {
|
|
71961
|
-
kind:
|
|
71972
|
+
kind: graphql13.Kind.NAME,
|
|
71962
71973
|
value: config2.withDirective
|
|
71963
71974
|
},
|
|
71964
71975
|
["arguments"]: requiredArgs.map((arg) => variableAsArgument(arg.name)).concat(paginationArgs.map(({ name }) => variableAsArgument(name)))
|
|
71965
71976
|
},
|
|
71966
71977
|
{
|
|
71967
|
-
kind:
|
|
71978
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71968
71979
|
name: {
|
|
71969
71980
|
kind: "Name",
|
|
71970
71981
|
value: config2.maskDisableDirective
|
|
@@ -71991,23 +72002,23 @@ async function paginate(config2, documents) {
|
|
|
71991
72002
|
});
|
|
71992
72003
|
const typeConfig = config2.typeConfig?.[fragment2];
|
|
71993
72004
|
const queryDoc = {
|
|
71994
|
-
kind:
|
|
72005
|
+
kind: graphql13.Kind.DOCUMENT,
|
|
71995
72006
|
definitions: [
|
|
71996
72007
|
{
|
|
71997
|
-
kind:
|
|
72008
|
+
kind: graphql13.Kind.OPERATION_DEFINITION,
|
|
71998
72009
|
name: {
|
|
71999
|
-
kind:
|
|
72010
|
+
kind: graphql13.Kind.NAME,
|
|
72000
72011
|
value: refetchQueryName
|
|
72001
72012
|
},
|
|
72002
72013
|
operation: "query",
|
|
72003
72014
|
variableDefinitions: requiredArgs.map(
|
|
72004
72015
|
(arg) => ({
|
|
72005
|
-
kind:
|
|
72016
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72006
72017
|
type: arg.type,
|
|
72007
72018
|
variable: {
|
|
72008
|
-
kind:
|
|
72019
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72009
72020
|
name: {
|
|
72010
|
-
kind:
|
|
72021
|
+
kind: graphql13.Kind.NAME,
|
|
72011
72022
|
value: arg.name
|
|
72012
72023
|
}
|
|
72013
72024
|
}
|
|
@@ -72015,18 +72026,18 @@ async function paginate(config2, documents) {
|
|
|
72015
72026
|
).concat(
|
|
72016
72027
|
paginationArgs.map(
|
|
72017
72028
|
(arg) => ({
|
|
72018
|
-
kind:
|
|
72029
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72019
72030
|
type: {
|
|
72020
|
-
kind:
|
|
72031
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
72021
72032
|
name: {
|
|
72022
|
-
kind:
|
|
72033
|
+
kind: graphql13.Kind.NAME,
|
|
72023
72034
|
value: arg.type
|
|
72024
72035
|
}
|
|
72025
72036
|
},
|
|
72026
72037
|
variable: {
|
|
72027
|
-
kind:
|
|
72038
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72028
72039
|
name: {
|
|
72029
|
-
kind:
|
|
72040
|
+
kind: graphql13.Kind.NAME,
|
|
72030
72041
|
value: arg.name
|
|
72031
72042
|
}
|
|
72032
72043
|
},
|
|
@@ -72038,12 +72049,12 @@ async function paginate(config2, documents) {
|
|
|
72038
72049
|
).concat(
|
|
72039
72050
|
!nodeQuery ? [] : keys2.map(
|
|
72040
72051
|
(key) => ({
|
|
72041
|
-
kind:
|
|
72052
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72042
72053
|
type: key.type,
|
|
72043
72054
|
variable: {
|
|
72044
|
-
kind:
|
|
72055
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72045
72056
|
name: {
|
|
72046
|
-
kind:
|
|
72057
|
+
kind: graphql13.Kind.NAME,
|
|
72047
72058
|
value: key.name
|
|
72048
72059
|
}
|
|
72049
72060
|
}
|
|
@@ -72052,42 +72063,42 @@ async function paginate(config2, documents) {
|
|
|
72052
72063
|
)
|
|
72053
72064
|
),
|
|
72054
72065
|
selectionSet: {
|
|
72055
|
-
kind:
|
|
72066
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72056
72067
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
72057
72068
|
{
|
|
72058
|
-
kind:
|
|
72069
|
+
kind: graphql13.Kind.FIELD,
|
|
72059
72070
|
name: {
|
|
72060
|
-
kind:
|
|
72071
|
+
kind: graphql13.Kind.NAME,
|
|
72061
72072
|
value: typeConfig?.resolve?.queryField || "node"
|
|
72062
72073
|
},
|
|
72063
72074
|
["arguments"]: keys2.map((key) => ({
|
|
72064
|
-
kind:
|
|
72075
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72065
72076
|
name: {
|
|
72066
|
-
kind:
|
|
72077
|
+
kind: graphql13.Kind.NAME,
|
|
72067
72078
|
value: key.name
|
|
72068
72079
|
},
|
|
72069
72080
|
value: {
|
|
72070
|
-
kind:
|
|
72081
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72071
72082
|
name: {
|
|
72072
|
-
kind:
|
|
72083
|
+
kind: graphql13.Kind.NAME,
|
|
72073
72084
|
value: key.name
|
|
72074
72085
|
}
|
|
72075
72086
|
}
|
|
72076
72087
|
})),
|
|
72077
72088
|
selectionSet: {
|
|
72078
|
-
kind:
|
|
72089
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72079
72090
|
selections: [
|
|
72080
72091
|
{
|
|
72081
|
-
kind:
|
|
72092
|
+
kind: graphql13.Kind.FIELD,
|
|
72082
72093
|
name: {
|
|
72083
|
-
kind:
|
|
72094
|
+
kind: graphql13.Kind.NAME,
|
|
72084
72095
|
value: "__typename"
|
|
72085
72096
|
}
|
|
72086
72097
|
},
|
|
72087
72098
|
...(typeConfig?.keys || [config2.defaultKeys[0]]).map((key) => ({
|
|
72088
|
-
kind:
|
|
72099
|
+
kind: graphql13.Kind.FIELD,
|
|
72089
72100
|
name: {
|
|
72090
|
-
kind:
|
|
72101
|
+
kind: graphql13.Kind.NAME,
|
|
72091
72102
|
value: key
|
|
72092
72103
|
}
|
|
72093
72104
|
})),
|
|
@@ -72144,15 +72155,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
72144
72155
|
}
|
|
72145
72156
|
function variableAsArgument(name, variable) {
|
|
72146
72157
|
return {
|
|
72147
|
-
kind:
|
|
72158
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72148
72159
|
name: {
|
|
72149
|
-
kind:
|
|
72160
|
+
kind: graphql13.Kind.NAME,
|
|
72150
72161
|
value: name
|
|
72151
72162
|
},
|
|
72152
72163
|
value: {
|
|
72153
|
-
kind:
|
|
72164
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72154
72165
|
name: {
|
|
72155
|
-
kind:
|
|
72166
|
+
kind: graphql13.Kind.NAME,
|
|
72156
72167
|
value: variable ?? name
|
|
72157
72168
|
}
|
|
72158
72169
|
}
|
|
@@ -72160,18 +72171,18 @@ function variableAsArgument(name, variable) {
|
|
|
72160
72171
|
}
|
|
72161
72172
|
function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
72162
72173
|
return {
|
|
72163
|
-
kind:
|
|
72174
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72164
72175
|
type: {
|
|
72165
|
-
kind:
|
|
72176
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
72166
72177
|
name: {
|
|
72167
|
-
kind:
|
|
72178
|
+
kind: graphql13.Kind.NAME,
|
|
72168
72179
|
value: type
|
|
72169
72180
|
}
|
|
72170
72181
|
},
|
|
72171
72182
|
variable: {
|
|
72172
|
-
kind:
|
|
72183
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72173
72184
|
name: {
|
|
72174
|
-
kind:
|
|
72185
|
+
kind: graphql13.Kind.NAME,
|
|
72175
72186
|
value: variableName ?? name
|
|
72176
72187
|
}
|
|
72177
72188
|
},
|
|
@@ -72183,9 +72194,9 @@ function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
|
72183
72194
|
}
|
|
72184
72195
|
function argumentNode(name, value) {
|
|
72185
72196
|
return {
|
|
72186
|
-
kind:
|
|
72197
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72187
72198
|
name: {
|
|
72188
|
-
kind:
|
|
72199
|
+
kind: graphql13.Kind.NAME,
|
|
72189
72200
|
value: name
|
|
72190
72201
|
},
|
|
72191
72202
|
value: objectNode(value)
|
|
@@ -72193,16 +72204,16 @@ function argumentNode(name, value) {
|
|
|
72193
72204
|
}
|
|
72194
72205
|
function objectNode([type, defaultValue]) {
|
|
72195
72206
|
const node = {
|
|
72196
|
-
kind:
|
|
72207
|
+
kind: graphql13.Kind.OBJECT,
|
|
72197
72208
|
fields: [
|
|
72198
72209
|
{
|
|
72199
|
-
kind:
|
|
72210
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
72200
72211
|
name: {
|
|
72201
|
-
kind:
|
|
72212
|
+
kind: graphql13.Kind.NAME,
|
|
72202
72213
|
value: "type"
|
|
72203
72214
|
},
|
|
72204
72215
|
value: {
|
|
72205
|
-
kind:
|
|
72216
|
+
kind: graphql13.Kind.STRING,
|
|
72206
72217
|
value: type
|
|
72207
72218
|
}
|
|
72208
72219
|
}
|
|
@@ -72210,8 +72221,8 @@ function objectNode([type, defaultValue]) {
|
|
|
72210
72221
|
};
|
|
72211
72222
|
if (defaultValue) {
|
|
72212
72223
|
node.fields.push({
|
|
72213
|
-
kind:
|
|
72214
|
-
name: { kind:
|
|
72224
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
72225
|
+
name: { kind: graphql13.Kind.NAME, value: "default" },
|
|
72215
72226
|
value: {
|
|
72216
72227
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
72217
72228
|
value: defaultValue.toString()
|
|
@@ -72222,34 +72233,34 @@ function objectNode([type, defaultValue]) {
|
|
|
72222
72233
|
}
|
|
72223
72234
|
var pageInfoSelection = [
|
|
72224
72235
|
{
|
|
72225
|
-
kind:
|
|
72236
|
+
kind: graphql13.Kind.FIELD,
|
|
72226
72237
|
name: {
|
|
72227
|
-
kind:
|
|
72238
|
+
kind: graphql13.Kind.NAME,
|
|
72228
72239
|
value: "edges"
|
|
72229
72240
|
},
|
|
72230
72241
|
selectionSet: {
|
|
72231
|
-
kind:
|
|
72242
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72232
72243
|
selections: [
|
|
72233
72244
|
{
|
|
72234
|
-
kind:
|
|
72245
|
+
kind: graphql13.Kind.FIELD,
|
|
72235
72246
|
name: {
|
|
72236
|
-
kind:
|
|
72247
|
+
kind: graphql13.Kind.NAME,
|
|
72237
72248
|
value: "cursor"
|
|
72238
72249
|
}
|
|
72239
72250
|
},
|
|
72240
72251
|
{
|
|
72241
|
-
kind:
|
|
72252
|
+
kind: graphql13.Kind.FIELD,
|
|
72242
72253
|
name: {
|
|
72243
|
-
kind:
|
|
72254
|
+
kind: graphql13.Kind.NAME,
|
|
72244
72255
|
value: "node"
|
|
72245
72256
|
},
|
|
72246
72257
|
selectionSet: {
|
|
72247
|
-
kind:
|
|
72258
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72248
72259
|
selections: [
|
|
72249
72260
|
{
|
|
72250
|
-
kind:
|
|
72261
|
+
kind: graphql13.Kind.FIELD,
|
|
72251
72262
|
name: {
|
|
72252
|
-
kind:
|
|
72263
|
+
kind: graphql13.Kind.NAME,
|
|
72253
72264
|
value: "__typename"
|
|
72254
72265
|
}
|
|
72255
72266
|
}
|
|
@@ -72260,39 +72271,39 @@ var pageInfoSelection = [
|
|
|
72260
72271
|
}
|
|
72261
72272
|
},
|
|
72262
72273
|
{
|
|
72263
|
-
kind:
|
|
72274
|
+
kind: graphql13.Kind.FIELD,
|
|
72264
72275
|
name: {
|
|
72265
|
-
kind:
|
|
72276
|
+
kind: graphql13.Kind.NAME,
|
|
72266
72277
|
value: "pageInfo"
|
|
72267
72278
|
},
|
|
72268
72279
|
selectionSet: {
|
|
72269
|
-
kind:
|
|
72280
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72270
72281
|
selections: [
|
|
72271
72282
|
{
|
|
72272
|
-
kind:
|
|
72283
|
+
kind: graphql13.Kind.FIELD,
|
|
72273
72284
|
name: {
|
|
72274
|
-
kind:
|
|
72285
|
+
kind: graphql13.Kind.NAME,
|
|
72275
72286
|
value: "hasPreviousPage"
|
|
72276
72287
|
}
|
|
72277
72288
|
},
|
|
72278
72289
|
{
|
|
72279
|
-
kind:
|
|
72290
|
+
kind: graphql13.Kind.FIELD,
|
|
72280
72291
|
name: {
|
|
72281
|
-
kind:
|
|
72292
|
+
kind: graphql13.Kind.NAME,
|
|
72282
72293
|
value: "hasNextPage"
|
|
72283
72294
|
}
|
|
72284
72295
|
},
|
|
72285
72296
|
{
|
|
72286
|
-
kind:
|
|
72297
|
+
kind: graphql13.Kind.FIELD,
|
|
72287
72298
|
name: {
|
|
72288
|
-
kind:
|
|
72299
|
+
kind: graphql13.Kind.NAME,
|
|
72289
72300
|
value: "startCursor"
|
|
72290
72301
|
}
|
|
72291
72302
|
},
|
|
72292
72303
|
{
|
|
72293
|
-
kind:
|
|
72304
|
+
kind: graphql13.Kind.FIELD,
|
|
72294
72305
|
name: {
|
|
72295
|
-
kind:
|
|
72306
|
+
kind: graphql13.Kind.NAME,
|
|
72296
72307
|
value: "endCursor"
|
|
72297
72308
|
}
|
|
72298
72309
|
}
|
|
@@ -72306,17 +72317,17 @@ async function addListFragments(config2, documents) {
|
|
|
72306
72317
|
const lists = {};
|
|
72307
72318
|
const errors = [];
|
|
72308
72319
|
for (const doc of documents) {
|
|
72309
|
-
doc.document =
|
|
72320
|
+
doc.document = graphql14.visit(doc.document, {
|
|
72310
72321
|
Directive(node, key, parent2, path3, ancestors) {
|
|
72311
72322
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
72312
72323
|
const nameArg = node.arguments?.find(
|
|
72313
72324
|
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
72314
72325
|
);
|
|
72315
72326
|
let error = {
|
|
72316
|
-
...new
|
|
72327
|
+
...new graphql14.GraphQLError(
|
|
72317
72328
|
"",
|
|
72318
72329
|
node,
|
|
72319
|
-
new
|
|
72330
|
+
new graphql14.Source(""),
|
|
72320
72331
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
72321
72332
|
path3
|
|
72322
72333
|
),
|
|
@@ -72368,7 +72379,7 @@ async function addListFragments(config2, documents) {
|
|
|
72368
72379
|
{
|
|
72369
72380
|
kind: "Argument",
|
|
72370
72381
|
name: {
|
|
72371
|
-
kind:
|
|
72382
|
+
kind: graphql14.Kind.NAME,
|
|
72372
72383
|
value: "connection"
|
|
72373
72384
|
},
|
|
72374
72385
|
value: {
|
|
@@ -72418,7 +72429,7 @@ async function addListFragments(config2, documents) {
|
|
|
72418
72429
|
const validDeletes = [
|
|
72419
72430
|
...new Set(
|
|
72420
72431
|
Object.values(lists).map(({ type }) => {
|
|
72421
|
-
if (!(type instanceof
|
|
72432
|
+
if (!(type instanceof graphql14.GraphQLObjectType)) {
|
|
72422
72433
|
return "";
|
|
72423
72434
|
}
|
|
72424
72435
|
if (config2.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -72432,7 +72443,7 @@ async function addListFragments(config2, documents) {
|
|
|
72432
72443
|
return;
|
|
72433
72444
|
}
|
|
72434
72445
|
const generatedDoc = {
|
|
72435
|
-
kind:
|
|
72446
|
+
kind: graphql14.Kind.DOCUMENT,
|
|
72436
72447
|
definitions: Object.entries(lists).flatMap(
|
|
72437
72448
|
([name, { selection, type }]) => {
|
|
72438
72449
|
const schemaType = config2.schema.getType(type.name);
|
|
@@ -72440,7 +72451,7 @@ async function addListFragments(config2, documents) {
|
|
|
72440
72451
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
72441
72452
|
}
|
|
72442
72453
|
const fragmentSelection = {
|
|
72443
|
-
kind:
|
|
72454
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
72444
72455
|
selections: [...selection.selections]
|
|
72445
72456
|
};
|
|
72446
72457
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -72455,14 +72466,14 @@ async function addListFragments(config2, documents) {
|
|
|
72455
72466
|
{
|
|
72456
72467
|
name: {
|
|
72457
72468
|
value: config2.listInsertFragment(name),
|
|
72458
|
-
kind:
|
|
72469
|
+
kind: graphql14.Kind.NAME
|
|
72459
72470
|
},
|
|
72460
|
-
kind:
|
|
72471
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72461
72472
|
selectionSet: fragmentSelection,
|
|
72462
72473
|
typeCondition: {
|
|
72463
|
-
kind:
|
|
72474
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72464
72475
|
name: {
|
|
72465
|
-
kind:
|
|
72476
|
+
kind: graphql14.Kind.NAME,
|
|
72466
72477
|
value: type.name
|
|
72467
72478
|
}
|
|
72468
72479
|
}
|
|
@@ -72470,32 +72481,32 @@ async function addListFragments(config2, documents) {
|
|
|
72470
72481
|
{
|
|
72471
72482
|
name: {
|
|
72472
72483
|
value: config2.listToggleFragment(name),
|
|
72473
|
-
kind:
|
|
72484
|
+
kind: graphql14.Kind.NAME
|
|
72474
72485
|
},
|
|
72475
|
-
kind:
|
|
72486
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72476
72487
|
selectionSet: fragmentSelection,
|
|
72477
72488
|
typeCondition: {
|
|
72478
|
-
kind:
|
|
72489
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72479
72490
|
name: {
|
|
72480
|
-
kind:
|
|
72491
|
+
kind: graphql14.Kind.NAME,
|
|
72481
72492
|
value: type.name
|
|
72482
72493
|
}
|
|
72483
72494
|
}
|
|
72484
72495
|
},
|
|
72485
72496
|
{
|
|
72486
|
-
kind:
|
|
72497
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72487
72498
|
name: {
|
|
72488
72499
|
value: config2.listRemoveFragment(name),
|
|
72489
|
-
kind:
|
|
72500
|
+
kind: graphql14.Kind.NAME
|
|
72490
72501
|
},
|
|
72491
72502
|
selectionSet: {
|
|
72492
|
-
kind:
|
|
72503
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
72493
72504
|
selections: [...objectIdentificationSelection(config2, type)]
|
|
72494
72505
|
},
|
|
72495
72506
|
typeCondition: {
|
|
72496
|
-
kind:
|
|
72507
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72497
72508
|
name: {
|
|
72498
|
-
kind:
|
|
72509
|
+
kind: graphql14.Kind.NAME,
|
|
72499
72510
|
value: type.name
|
|
72500
72511
|
}
|
|
72501
72512
|
}
|
|
@@ -72504,14 +72515,14 @@ async function addListFragments(config2, documents) {
|
|
|
72504
72515
|
}
|
|
72505
72516
|
).concat(
|
|
72506
72517
|
...validDeletes.map((typeName) => ({
|
|
72507
|
-
kind:
|
|
72518
|
+
kind: graphql14.Kind.DIRECTIVE_DEFINITION,
|
|
72508
72519
|
name: {
|
|
72509
|
-
kind:
|
|
72520
|
+
kind: graphql14.Kind.NAME,
|
|
72510
72521
|
value: config2.listDeleteDirective(typeName)
|
|
72511
72522
|
},
|
|
72512
72523
|
locations: [
|
|
72513
72524
|
{
|
|
72514
|
-
kind:
|
|
72525
|
+
kind: graphql14.Kind.NAME,
|
|
72515
72526
|
value: "FIELD"
|
|
72516
72527
|
}
|
|
72517
72528
|
],
|
|
@@ -72519,8 +72530,8 @@ async function addListFragments(config2, documents) {
|
|
|
72519
72530
|
}))
|
|
72520
72531
|
)
|
|
72521
72532
|
};
|
|
72522
|
-
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
72523
|
-
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
72533
|
+
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
72534
|
+
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
72524
72535
|
documents.push({
|
|
72525
72536
|
name: "generated::lists",
|
|
72526
72537
|
kind: ArtifactKind.Fragment,
|
|
@@ -72606,11 +72617,11 @@ var nodeNotDefinedMessage = (config2) => `Looks like you are trying to use the $
|
|
|
72606
72617
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
72607
72618
|
|
|
72608
72619
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
72609
|
-
import * as
|
|
72620
|
+
import * as graphql15 from "graphql";
|
|
72610
72621
|
function fieldKey(config2, field) {
|
|
72611
72622
|
const attributeName = field.alias?.value || field.name.value;
|
|
72612
|
-
const printed =
|
|
72613
|
-
const secondParse =
|
|
72623
|
+
const printed = graphql15.print(field);
|
|
72624
|
+
const secondParse = graphql15.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
72614
72625
|
let paginateMode = config2.defaultPaginateMode;
|
|
72615
72626
|
const paginatedDirective = field.directives?.find(
|
|
72616
72627
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -72733,13 +72744,13 @@ function prepareSelection({
|
|
|
72733
72744
|
} else if ("getFields" in type) {
|
|
72734
72745
|
let typeRef = type.getFields()[field.name.value].type;
|
|
72735
72746
|
fieldType = getRootType(typeRef);
|
|
72736
|
-
nullable = !
|
|
72737
|
-
} else if (
|
|
72747
|
+
nullable = !graphql16.isNonNullType(typeRef);
|
|
72748
|
+
} else if (graphql16.isAbstractType(type)) {
|
|
72738
72749
|
for (const possible of config2.schema.getPossibleTypes(type)) {
|
|
72739
|
-
if (
|
|
72750
|
+
if (graphql16.isObjectType(possible)) {
|
|
72740
72751
|
if (possible.getFields()[field.name.value]) {
|
|
72741
72752
|
fieldType = possible.getFields()[field.name.value].type;
|
|
72742
|
-
nullable = !
|
|
72753
|
+
nullable = !graphql16.isNonNullType(fieldType);
|
|
72743
72754
|
break;
|
|
72744
72755
|
}
|
|
72745
72756
|
}
|
|
@@ -72876,7 +72887,7 @@ function prepareSelection({
|
|
|
72876
72887
|
kind: "value"
|
|
72877
72888
|
} : { kind: "continue" };
|
|
72878
72889
|
const parentType = config2.schema.getType(rootType);
|
|
72879
|
-
if (
|
|
72890
|
+
if (graphql16.isObjectType(parentType) || graphql16.isInterfaceType(parentType)) {
|
|
72880
72891
|
const fieldType2 = parentType.getFields()[field.name.value]?.type;
|
|
72881
72892
|
if (fieldType2) {
|
|
72882
72893
|
const listCount = unwrapType(config2, fieldType2).wrappers.filter(
|
|
@@ -72899,7 +72910,7 @@ function prepareSelection({
|
|
|
72899
72910
|
}
|
|
72900
72911
|
fieldObj.loading = loadingValue;
|
|
72901
72912
|
}
|
|
72902
|
-
if (
|
|
72913
|
+
if (graphql16.isInterfaceType(fieldType) || graphql16.isUnionType(fieldType)) {
|
|
72903
72914
|
fieldObj.abstract = true;
|
|
72904
72915
|
if (Object.values(fieldObj.selection?.abstractFields?.fields ?? {}).some(
|
|
72905
72916
|
(fields) => Object.values(fields ?? {}).some((field2) => field2.required)
|
|
@@ -72981,7 +72992,7 @@ function mergeSelection({
|
|
|
72981
72992
|
typeSelection,
|
|
72982
72993
|
abstractSelection.fields[typeName] ?? {}
|
|
72983
72994
|
);
|
|
72984
|
-
if (
|
|
72995
|
+
if (graphql16.isAbstractType(gqlType)) {
|
|
72985
72996
|
for (const possible of config2.schema.getPossibleTypes(gqlType)) {
|
|
72986
72997
|
if (!possibleSelectionTypes[typeName]) {
|
|
72987
72998
|
possibleSelectionTypes[typeName] = [];
|
|
@@ -73016,7 +73027,7 @@ function mergeSelection({
|
|
|
73016
73027
|
}
|
|
73017
73028
|
}
|
|
73018
73029
|
const parentType = config2.schema.getType(rootType);
|
|
73019
|
-
const possibleParents =
|
|
73030
|
+
const possibleParents = graphql16.isAbstractType(parentType) ? config2.schema.getPossibleTypes(parentType)?.map((t3) => t3.name) : [parentType.name];
|
|
73020
73031
|
for (const key of Object.keys(abstractSelection.typeMap)) {
|
|
73021
73032
|
if (!possibleParents.includes(key) && rootType !== key || abstractSelection.fields[key]) {
|
|
73022
73033
|
delete abstractSelection.typeMap[key];
|
|
@@ -73073,12 +73084,12 @@ function mergeSelection({
|
|
|
73073
73084
|
}
|
|
73074
73085
|
|
|
73075
73086
|
// src/codegen/generators/artifacts/index.ts
|
|
73076
|
-
var
|
|
73087
|
+
var AST5 = recast5.types.builders;
|
|
73077
73088
|
function artifactGenerator(stats) {
|
|
73078
73089
|
return async function(config2, docs) {
|
|
73079
73090
|
const filterTypes = {};
|
|
73080
73091
|
for (const doc of docs) {
|
|
73081
|
-
|
|
73092
|
+
graphql17.visit(doc.document, {
|
|
73082
73093
|
Directive(node, _, __, ___, ancestors) {
|
|
73083
73094
|
if (node.name.value !== config2.listDirective) {
|
|
73084
73095
|
return;
|
|
@@ -73138,7 +73149,7 @@ function artifactGenerator(stats) {
|
|
|
73138
73149
|
return;
|
|
73139
73150
|
}
|
|
73140
73151
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
73141
|
-
let documentWithoutInternalDirectives =
|
|
73152
|
+
let documentWithoutInternalDirectives = graphql17.visit(document, {
|
|
73142
73153
|
Directive(node) {
|
|
73143
73154
|
if (config2.isInternalDirective(node.name.value)) {
|
|
73144
73155
|
return null;
|
|
@@ -73151,7 +73162,7 @@ function artifactGenerator(stats) {
|
|
|
73151
73162
|
}
|
|
73152
73163
|
}
|
|
73153
73164
|
});
|
|
73154
|
-
let documentWithoutExtraVariables =
|
|
73165
|
+
let documentWithoutExtraVariables = graphql17.visit(
|
|
73155
73166
|
documentWithoutInternalDirectives,
|
|
73156
73167
|
{
|
|
73157
73168
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -73162,13 +73173,13 @@ function artifactGenerator(stats) {
|
|
|
73162
73173
|
}
|
|
73163
73174
|
}
|
|
73164
73175
|
);
|
|
73165
|
-
let rawString =
|
|
73176
|
+
let rawString = graphql17.print(documentWithoutExtraVariables);
|
|
73166
73177
|
let docKind = doc.kind;
|
|
73167
73178
|
const operations = document.definitions.filter(
|
|
73168
|
-
({ kind }) => kind ===
|
|
73179
|
+
({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
|
|
73169
73180
|
);
|
|
73170
73181
|
const fragments = document.definitions.filter(
|
|
73171
|
-
({ kind }) => kind ===
|
|
73182
|
+
({ kind }) => kind === graphql17.Kind.FRAGMENT_DEFINITION
|
|
73172
73183
|
);
|
|
73173
73184
|
let rootType = "";
|
|
73174
73185
|
let selectionSet;
|
|
@@ -73368,9 +73379,9 @@ function artifactGenerator(stats) {
|
|
|
73368
73379
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
73369
73380
|
}
|
|
73370
73381
|
const _houdiniHash = hashOriginal({ document: doc });
|
|
73371
|
-
const file =
|
|
73382
|
+
const file = AST5.program([
|
|
73372
73383
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
73373
|
-
|
|
73384
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
73374
73385
|
]);
|
|
73375
73386
|
const artifactPath = config2.artifactPath(document);
|
|
73376
73387
|
const countDocument = doc.generateStore;
|
|
@@ -73428,7 +73439,7 @@ function applyMask(config2, target, mask) {
|
|
|
73428
73439
|
if (!targetType) {
|
|
73429
73440
|
continue;
|
|
73430
73441
|
}
|
|
73431
|
-
if (
|
|
73442
|
+
if (graphql17.isAbstractType(targetType)) {
|
|
73432
73443
|
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
73433
73444
|
if (target.abstractFields?.fields[possible.name]) {
|
|
73434
73445
|
applyMask(
|
|
@@ -73451,8 +73462,8 @@ function applyMask(config2, target, mask) {
|
|
|
73451
73462
|
}
|
|
73452
73463
|
|
|
73453
73464
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
73454
|
-
var
|
|
73455
|
-
var
|
|
73465
|
+
var recast6 = __toESM(require_main2(), 1);
|
|
73466
|
+
var AST6 = recast6.types.builders;
|
|
73456
73467
|
async function generateGraphqlReturnTypes(config2, docs) {
|
|
73457
73468
|
const indexPath = path_exports.join(config2.runtimeDirectory, "index.d.ts");
|
|
73458
73469
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
@@ -73487,18 +73498,18 @@ async function generateGraphqlReturnTypes(config2, docs) {
|
|
|
73487
73498
|
continue;
|
|
73488
73499
|
}
|
|
73489
73500
|
for (const [queryString, returnValue] of Object.entries(overloaded_returns)) {
|
|
73490
|
-
const input =
|
|
73491
|
-
input.typeAnnotation =
|
|
73492
|
-
|
|
73501
|
+
const input = AST6.identifier("str");
|
|
73502
|
+
input.typeAnnotation = AST6.tsTypeAnnotation(
|
|
73503
|
+
AST6.tsLiteralType(AST6.stringLiteral(queryString))
|
|
73493
73504
|
);
|
|
73494
73505
|
script.body.splice(
|
|
73495
73506
|
i2,
|
|
73496
73507
|
0,
|
|
73497
|
-
|
|
73498
|
-
|
|
73499
|
-
|
|
73508
|
+
AST6.exportNamedDeclaration(
|
|
73509
|
+
AST6.tsDeclareFunction(
|
|
73510
|
+
AST6.identifier("graphql"),
|
|
73500
73511
|
[input],
|
|
73501
|
-
|
|
73512
|
+
AST6.tsTypeAnnotation(AST6.tsTypeReference(AST6.identifier(returnValue)))
|
|
73502
73513
|
)
|
|
73503
73514
|
)
|
|
73504
73515
|
);
|
|
@@ -73673,165 +73684,22 @@ function moduleStatments(config2) {
|
|
|
73673
73684
|
var recast11 = __toESM(require_main2(), 1);
|
|
73674
73685
|
|
|
73675
73686
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
73676
|
-
var recast8 = __toESM(require_main2(), 1);
|
|
73677
|
-
import * as graphql19 from "graphql";
|
|
73678
|
-
|
|
73679
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
73680
73687
|
var recast7 = __toESM(require_main2(), 1);
|
|
73681
73688
|
import * as graphql18 from "graphql";
|
|
73682
|
-
|
|
73683
|
-
// src/codegen/generators/typescript/types.ts
|
|
73684
|
-
var recast6 = __toESM(require_main2(), 1);
|
|
73685
|
-
import * as graphql17 from "graphql";
|
|
73686
|
-
var AST6 = recast6.types.builders;
|
|
73687
|
-
function readonlyProperty(prop, enable = true) {
|
|
73688
|
-
if (enable) {
|
|
73689
|
-
prop.readonly = true;
|
|
73690
|
-
}
|
|
73691
|
-
return prop;
|
|
73692
|
-
}
|
|
73693
|
-
function nullableField(inner, input = false) {
|
|
73694
|
-
const members = [inner, AST6.tsNullKeyword()];
|
|
73695
|
-
if (input) {
|
|
73696
|
-
members.push(AST6.tsUndefinedKeyword());
|
|
73697
|
-
}
|
|
73698
|
-
return AST6.tsUnionType(members);
|
|
73699
|
-
}
|
|
73700
|
-
function scalarPropertyValue(config2, filepath, missingScalars, target, body, field) {
|
|
73701
|
-
if (config2.configFile.features?.componentFields && target.name === config2.componentScalar) {
|
|
73702
|
-
if (!field) {
|
|
73703
|
-
return AST6.tsNeverKeyword();
|
|
73704
|
-
}
|
|
73705
|
-
const component = config2.componentFields[field.parent][field.field];
|
|
73706
|
-
const sourcePathRelative = path_exports.relative(
|
|
73707
|
-
path_exports.join(config2.projectRoot, "src"),
|
|
73708
|
-
component.filepath
|
|
73709
|
-
);
|
|
73710
|
-
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
73711
|
-
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
73712
|
-
const localImport = ensureImports({
|
|
73713
|
-
config: config2,
|
|
73714
|
-
body,
|
|
73715
|
-
import: "__component__" + component.fragment,
|
|
73716
|
-
sourceModule: path_exports.join(
|
|
73717
|
-
path_exports.relative(path_exports.dirname(filepath), config2.projectRoot),
|
|
73718
|
-
"src",
|
|
73719
|
-
sourcePath
|
|
73720
|
-
)
|
|
73721
|
-
});
|
|
73722
|
-
const parameters = AST6.tsTypeReference(AST6.identifier("Parameters"));
|
|
73723
|
-
parameters.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
73724
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
73725
|
-
]);
|
|
73726
|
-
const indexed = AST6.tsIndexedAccessType(
|
|
73727
|
-
parameters,
|
|
73728
|
-
AST6.tsLiteralType(AST6.numericLiteral(0))
|
|
73729
|
-
);
|
|
73730
|
-
const omit = AST6.tsTypeReference(AST6.identifier("Omit"));
|
|
73731
|
-
omit.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
73732
|
-
indexed,
|
|
73733
|
-
AST6.tsLiteralType(AST6.stringLiteral(component.prop))
|
|
73734
|
-
]);
|
|
73735
|
-
const arg = AST6.identifier("props");
|
|
73736
|
-
arg.typeAnnotation = AST6.tsTypeAnnotation(omit);
|
|
73737
|
-
const returnType = AST6.tsTypeReference(AST6.identifier("ReturnType"));
|
|
73738
|
-
returnType.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
73739
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
73740
|
-
]);
|
|
73741
|
-
const fnType = AST6.tsFunctionType([arg]);
|
|
73742
|
-
fnType.typeAnnotation = AST6.tsTypeAnnotation(returnType);
|
|
73743
|
-
return fnType;
|
|
73744
|
-
}
|
|
73745
|
-
switch (target.name) {
|
|
73746
|
-
case "String": {
|
|
73747
|
-
return AST6.tsStringKeyword();
|
|
73748
|
-
}
|
|
73749
|
-
case "Int": {
|
|
73750
|
-
return AST6.tsNumberKeyword();
|
|
73751
|
-
}
|
|
73752
|
-
case "Float": {
|
|
73753
|
-
return AST6.tsNumberKeyword();
|
|
73754
|
-
}
|
|
73755
|
-
case "Boolean": {
|
|
73756
|
-
return AST6.tsBooleanKeyword();
|
|
73757
|
-
}
|
|
73758
|
-
case "ID": {
|
|
73759
|
-
return AST6.tsStringKeyword();
|
|
73760
|
-
}
|
|
73761
|
-
default: {
|
|
73762
|
-
if (graphql17.isNonNullType(target) && "ofType" in target) {
|
|
73763
|
-
return scalarPropertyValue(
|
|
73764
|
-
config2,
|
|
73765
|
-
filepath,
|
|
73766
|
-
missingScalars,
|
|
73767
|
-
target.ofType,
|
|
73768
|
-
body,
|
|
73769
|
-
field
|
|
73770
|
-
);
|
|
73771
|
-
}
|
|
73772
|
-
if (config2.scalars?.[target.name]) {
|
|
73773
|
-
return AST6.tsTypeReference(AST6.identifier(config2.scalars?.[target.name].type));
|
|
73774
|
-
}
|
|
73775
|
-
if (target.name !== config2.componentScalar) {
|
|
73776
|
-
missingScalars.add(target.name);
|
|
73777
|
-
}
|
|
73778
|
-
return AST6.tsAnyKeyword();
|
|
73779
|
-
}
|
|
73780
|
-
}
|
|
73781
|
-
}
|
|
73782
|
-
|
|
73783
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
73784
73689
|
var AST7 = recast7.types.builders;
|
|
73785
|
-
function tsTypeReference(config2, filepath, missingScalars, definition, body) {
|
|
73786
|
-
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
73787
|
-
let result;
|
|
73788
|
-
if (graphql18.isScalarType(type)) {
|
|
73789
|
-
result = scalarPropertyValue(config2, filepath, missingScalars, type, body, null);
|
|
73790
|
-
} else if (graphql18.isEnumType(type)) {
|
|
73791
|
-
result = enumReference(config2, body, type.name);
|
|
73792
|
-
} else {
|
|
73793
|
-
result = AST7.tsTypeReference(AST7.identifier(type.name));
|
|
73794
|
-
}
|
|
73795
|
-
for (const toWrap of wrappers) {
|
|
73796
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
73797
|
-
continue;
|
|
73798
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
73799
|
-
result = nullableField(result, true);
|
|
73800
|
-
} else if (toWrap === "List" /* List */) {
|
|
73801
|
-
result = AST7.tsArrayType(AST7.tsParenthesizedType(result));
|
|
73802
|
-
}
|
|
73803
|
-
}
|
|
73804
|
-
return result;
|
|
73805
|
-
}
|
|
73806
|
-
function enumReference(config2, body, name) {
|
|
73807
|
-
ensureImports({
|
|
73808
|
-
config: config2,
|
|
73809
|
-
body,
|
|
73810
|
-
import: ["ValueOf"],
|
|
73811
|
-
importKind: "type",
|
|
73812
|
-
sourceModule: "$houdini/runtime/lib/types"
|
|
73813
|
-
});
|
|
73814
|
-
return AST7.tsTypeReference(
|
|
73815
|
-
AST7.identifier("ValueOf"),
|
|
73816
|
-
AST7.tsTypeParameterInstantiation([AST7.tsTypeQuery(AST7.identifier(name))])
|
|
73817
|
-
);
|
|
73818
|
-
}
|
|
73819
|
-
|
|
73820
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
73821
|
-
var AST8 = recast8.types.builders;
|
|
73822
73690
|
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
73823
73691
|
const { type } = unwrapType(config2, rootType);
|
|
73824
|
-
if (
|
|
73692
|
+
if (graphql18.isScalarType(type)) {
|
|
73825
73693
|
return;
|
|
73826
73694
|
}
|
|
73827
73695
|
if (visitedTypes.has(type.name)) {
|
|
73828
73696
|
return;
|
|
73829
73697
|
}
|
|
73830
|
-
if (
|
|
73698
|
+
if (graphql18.isUnionType(type)) {
|
|
73831
73699
|
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
73832
73700
|
}
|
|
73833
73701
|
visitedTypes.add(type.name);
|
|
73834
|
-
if (
|
|
73702
|
+
if (graphql18.isEnumType(type)) {
|
|
73835
73703
|
ensureImports({
|
|
73836
73704
|
config: config2,
|
|
73837
73705
|
body,
|
|
@@ -73845,21 +73713,37 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
73845
73713
|
for (const field of Object.values(type.getFields())) {
|
|
73846
73714
|
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
73847
73715
|
members.push(
|
|
73848
|
-
|
|
73849
|
-
|
|
73850
|
-
|
|
73716
|
+
AST7.tsPropertySignature(
|
|
73717
|
+
AST7.identifier(field.name),
|
|
73718
|
+
AST7.tsTypeAnnotation(
|
|
73851
73719
|
tsTypeReference(config2, filepath, missingScalars, field, body)
|
|
73852
73720
|
),
|
|
73853
|
-
|
|
73721
|
+
graphql18.isNullableType(field.type)
|
|
73854
73722
|
)
|
|
73855
73723
|
);
|
|
73856
73724
|
}
|
|
73857
|
-
body.push(
|
|
73725
|
+
body.push(AST7.tsTypeAliasDeclaration(AST7.identifier(type.name), AST7.tsTypeLiteral(members)));
|
|
73858
73726
|
}
|
|
73859
73727
|
|
|
73860
73728
|
// src/codegen/generators/typescript/inlineType.ts
|
|
73861
73729
|
var recast9 = __toESM(require_main2(), 1);
|
|
73862
|
-
import * as
|
|
73730
|
+
import * as graphql19 from "graphql";
|
|
73731
|
+
|
|
73732
|
+
// src/codegen/generators/comments/jsdoc.ts
|
|
73733
|
+
var recast8 = __toESM(require_main2(), 1);
|
|
73734
|
+
var AST8 = recast8.types.builders;
|
|
73735
|
+
function jsdocComment(text, deprecated) {
|
|
73736
|
+
let commentContent = `*
|
|
73737
|
+
* ${text}
|
|
73738
|
+
`;
|
|
73739
|
+
if (deprecated) {
|
|
73740
|
+
commentContent = `${commentContent} * @deprecated ${deprecated}
|
|
73741
|
+
`;
|
|
73742
|
+
}
|
|
73743
|
+
return AST8.commentBlock(commentContent, true);
|
|
73744
|
+
}
|
|
73745
|
+
|
|
73746
|
+
// src/codegen/generators/typescript/inlineType.ts
|
|
73863
73747
|
var AST9 = recast9.types.builders;
|
|
73864
73748
|
var fragmentKey2 = " $fragments";
|
|
73865
73749
|
function inlineType({
|
|
@@ -73880,7 +73764,7 @@ function inlineType({
|
|
|
73880
73764
|
const { type, wrappers } = unwrapType(config2, rootType);
|
|
73881
73765
|
let result;
|
|
73882
73766
|
let forceNullable = false;
|
|
73883
|
-
if (
|
|
73767
|
+
if (graphql19.isScalarType(type)) {
|
|
73884
73768
|
result = scalarPropertyValue(
|
|
73885
73769
|
config2,
|
|
73886
73770
|
filepath,
|
|
@@ -73889,7 +73773,7 @@ function inlineType({
|
|
|
73889
73773
|
body,
|
|
73890
73774
|
field
|
|
73891
73775
|
);
|
|
73892
|
-
} else if (
|
|
73776
|
+
} else if (graphql19.isEnumType(type)) {
|
|
73893
73777
|
ensureImports({
|
|
73894
73778
|
config: config2,
|
|
73895
73779
|
body,
|
|
@@ -73914,11 +73798,11 @@ function inlineType({
|
|
|
73914
73798
|
for (const selection of selections) {
|
|
73915
73799
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73916
73800
|
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
73917
|
-
if (!
|
|
73801
|
+
if (!graphql19.isInterfaceType(type) && !graphql19.isUnionType(type)) {
|
|
73918
73802
|
selectedFields.push(...selection.selectionSet.selections);
|
|
73919
73803
|
continue;
|
|
73920
73804
|
}
|
|
73921
|
-
if (!
|
|
73805
|
+
if (!graphql19.isInterfaceType(fragmentType) && !graphql19.isUnionType(fragmentType)) {
|
|
73922
73806
|
if (!inlineFragments[fragmentType.name]) {
|
|
73923
73807
|
inlineFragments[fragmentType.name] = [];
|
|
73924
73808
|
}
|
|
@@ -74010,6 +73894,11 @@ function inlineType({
|
|
|
74010
73894
|
if (allOptional) {
|
|
74011
73895
|
prop.optional = true;
|
|
74012
73896
|
}
|
|
73897
|
+
if (field2.description || field2.deprecationReason) {
|
|
73898
|
+
prop.comments = [
|
|
73899
|
+
jsdocComment(field2.description ?? "", field2.deprecationReason ?? void 0)
|
|
73900
|
+
];
|
|
73901
|
+
}
|
|
74013
73902
|
return prop;
|
|
74014
73903
|
})
|
|
74015
73904
|
]);
|
|
@@ -74061,7 +73950,7 @@ function inlineType({
|
|
|
74061
73950
|
}
|
|
74062
73951
|
}
|
|
74063
73952
|
}
|
|
74064
|
-
if (objectType.type === "TSTypeLiteral" && !
|
|
73953
|
+
if (objectType.type === "TSTypeLiteral" && !graphql19.isInterfaceType(fragmentRootType) && !graphql19.isUnionType(fragmentRootType)) {
|
|
74065
73954
|
const existingTypenameIndex = objectType.members.findIndex(
|
|
74066
73955
|
(member) => member.type === "TSPropertySignature" && member.key.type === "Identifier" && member.key.name === "__typename"
|
|
74067
73956
|
);
|
|
@@ -74086,11 +73975,11 @@ function inlineType({
|
|
|
74086
73975
|
];
|
|
74087
73976
|
}
|
|
74088
73977
|
let coveredTypenames;
|
|
74089
|
-
if (
|
|
73978
|
+
if (graphql19.isInterfaceType(fragmentRootType)) {
|
|
74090
73979
|
coveredTypenames = interfaceCoveredTypenames(fragmentRootType);
|
|
74091
|
-
} else if (
|
|
73980
|
+
} else if (graphql19.isUnionType(fragmentRootType)) {
|
|
74092
73981
|
coveredTypenames = fragmentRootType.getTypes().map((type2) => type2.name);
|
|
74093
|
-
} else if (
|
|
73982
|
+
} else if (graphql19.isObjectType(fragmentRootType)) {
|
|
74094
73983
|
coveredTypenames = [fragmentRootType.name];
|
|
74095
73984
|
} else {
|
|
74096
73985
|
throw Error("unreachable code");
|
|
@@ -74126,7 +74015,7 @@ function inlineType({
|
|
|
74126
74015
|
);
|
|
74127
74016
|
}
|
|
74128
74017
|
);
|
|
74129
|
-
const parentIsUnionOrInterface = !
|
|
74018
|
+
const parentIsUnionOrInterface = !graphql19.isInterfaceType(type) && !graphql19.isUnionType(type);
|
|
74130
74019
|
const possibleTypenames = parentIsUnionOrInterface ? [parent.name] : config2.schema.getPossibleTypes(type).map((type2) => type2.name);
|
|
74131
74020
|
const coveredTypenames = new Set(
|
|
74132
74021
|
Object.values(inlineFragmentSelections).flatMap((sel) => sel.coveredTypenames)
|
|
@@ -74193,7 +74082,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
74193
74082
|
},
|
|
74194
74083
|
type: schema.getType("String")
|
|
74195
74084
|
};
|
|
74196
|
-
} else if (
|
|
74085
|
+
} else if (graphql19.isNonNullType(rootType) && "getFields" in rootType.ofType) {
|
|
74197
74086
|
fields = rootType.ofType.getFields();
|
|
74198
74087
|
} else {
|
|
74199
74088
|
fields = rootType.getFields();
|
|
@@ -74205,7 +74094,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
74205
74094
|
message: `Could not find type information for field ${rootType.toString()}.${selectionName} ${field}`
|
|
74206
74095
|
});
|
|
74207
74096
|
}
|
|
74208
|
-
const fieldType =
|
|
74097
|
+
const fieldType = graphql19.getNamedType(field.type);
|
|
74209
74098
|
if (!fieldType) {
|
|
74210
74099
|
throw new HoudiniError({
|
|
74211
74100
|
filepath,
|
|
@@ -74714,7 +74603,7 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
74714
74603
|
|
|
74715
74604
|
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
74716
74605
|
var recast12 = __toESM(require_main2(), 1);
|
|
74717
|
-
import * as
|
|
74606
|
+
import * as graphql20 from "graphql";
|
|
74718
74607
|
var AST12 = recast12.types.builders;
|
|
74719
74608
|
async function imperativeCacheTypef(config2, docs) {
|
|
74720
74609
|
const returnType = (doc) => config2.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
@@ -74765,7 +74654,7 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74765
74654
|
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
74766
74655
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
74767
74656
|
const types17 = Object.values(config2.schema.getTypeMap()).filter(
|
|
74768
|
-
(type) => !
|
|
74657
|
+
(type) => !graphql20.isAbstractType(type) && !graphql20.isScalarType(type) && !graphql20.isEnumType(type) && !graphql20.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
74769
74658
|
);
|
|
74770
74659
|
const fragmentMap = fragmentListMap(
|
|
74771
74660
|
config2,
|
|
@@ -74782,7 +74671,7 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74782
74671
|
}
|
|
74783
74672
|
let idFields = AST12.tsNeverKeyword();
|
|
74784
74673
|
const keys2 = keyFieldsForType(config2.configFile, type.name);
|
|
74785
|
-
if (
|
|
74674
|
+
if (graphql20.isObjectType(type) && keys2.length > 0 && keys2.every((key) => type.getFields()[key])) {
|
|
74786
74675
|
idFields = AST12.tsTypeLiteral(
|
|
74787
74676
|
keys2.map((key) => {
|
|
74788
74677
|
const fieldType = type.getFields()[key];
|
|
@@ -74809,13 +74698,13 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74809
74698
|
idFields = AST12.tsTypeLiteral([]);
|
|
74810
74699
|
}
|
|
74811
74700
|
let fields = AST12.tsTypeLiteral([]);
|
|
74812
|
-
if (
|
|
74701
|
+
if (graphql20.isObjectType(type)) {
|
|
74813
74702
|
fields = AST12.tsTypeLiteral(
|
|
74814
74703
|
Object.entries(type.getFields()).map(
|
|
74815
74704
|
([key, fieldType]) => {
|
|
74816
74705
|
const unwrapped = unwrapType(config2, fieldType.type);
|
|
74817
74706
|
let typeOptions = AST12.tsUnionType([]);
|
|
74818
|
-
if (
|
|
74707
|
+
if (graphql20.isScalarType(unwrapped.type)) {
|
|
74819
74708
|
typeOptions.types.push(
|
|
74820
74709
|
scalarPropertyValue(
|
|
74821
74710
|
config2,
|
|
@@ -74829,11 +74718,11 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74829
74718
|
}
|
|
74830
74719
|
)
|
|
74831
74720
|
);
|
|
74832
|
-
} else if (
|
|
74721
|
+
} else if (graphql20.isEnumType(unwrapped.type)) {
|
|
74833
74722
|
typeOptions.types.push(
|
|
74834
74723
|
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
74835
74724
|
);
|
|
74836
|
-
} else if (!
|
|
74725
|
+
} else if (!graphql20.isAbstractType(unwrapped.type)) {
|
|
74837
74726
|
typeOptions.types.push(record(unwrapped.type.name));
|
|
74838
74727
|
} else {
|
|
74839
74728
|
typeOptions.types.push(
|
|
@@ -74929,7 +74818,7 @@ function listDefinitions(config2, filepath, body, docs) {
|
|
|
74929
74818
|
const lists = [];
|
|
74930
74819
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
74931
74820
|
for (const doc of docs) {
|
|
74932
|
-
|
|
74821
|
+
graphql20.visit(doc.document, {
|
|
74933
74822
|
Directive(node, key, parent2, path3, ancestors) {
|
|
74934
74823
|
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
74935
74824
|
return;
|
|
@@ -74951,7 +74840,7 @@ function listDefinitions(config2, filepath, body, docs) {
|
|
|
74951
74840
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74952
74841
|
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
74953
74842
|
const possibleTypes = [];
|
|
74954
|
-
if (
|
|
74843
|
+
if (graphql20.isAbstractType(listType)) {
|
|
74955
74844
|
possibleTypes.push(
|
|
74956
74845
|
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
74957
74846
|
);
|
|
@@ -75113,7 +75002,7 @@ async function typescriptGenerator(config2, docs) {
|
|
|
75113
75002
|
}
|
|
75114
75003
|
|
|
75115
75004
|
// src/codegen/generators/persistedQueries/index.ts
|
|
75116
|
-
import * as
|
|
75005
|
+
import * as graphql21 from "graphql";
|
|
75117
75006
|
async function persistOutputGenerator(config2, docs) {
|
|
75118
75007
|
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
75119
75008
|
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
@@ -75123,8 +75012,8 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75123
75012
|
if (!generateArtifact) {
|
|
75124
75013
|
return acc;
|
|
75125
75014
|
}
|
|
75126
|
-
let rawString =
|
|
75127
|
-
|
|
75015
|
+
let rawString = graphql21.print(
|
|
75016
|
+
graphql21.visit(document, {
|
|
75128
75017
|
Directive(node) {
|
|
75129
75018
|
if (config2.isInternalDirective(node.name.value)) {
|
|
75130
75019
|
return null;
|
|
@@ -75133,7 +75022,7 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75133
75022
|
})
|
|
75134
75023
|
);
|
|
75135
75024
|
const operations = document.definitions.filter(
|
|
75136
|
-
({ kind }) => kind ===
|
|
75025
|
+
({ kind }) => kind === graphql21.Kind.OPERATION_DEFINITION
|
|
75137
75026
|
);
|
|
75138
75027
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
75139
75028
|
if (artifact) {
|
|
@@ -75148,33 +75037,45 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75148
75037
|
}
|
|
75149
75038
|
|
|
75150
75039
|
// src/codegen/generators/definitions/index.ts
|
|
75151
|
-
import * as
|
|
75040
|
+
import * as graphql23 from "graphql";
|
|
75152
75041
|
|
|
75153
75042
|
// src/codegen/generators/definitions/enums.ts
|
|
75154
75043
|
var recast13 = __toESM(require_main2(), 1);
|
|
75155
|
-
import * as
|
|
75044
|
+
import * as graphql22 from "graphql";
|
|
75156
75045
|
var AST13 = recast13.types.builders;
|
|
75157
75046
|
async function definitionsGenerator(config2) {
|
|
75158
|
-
const enums =
|
|
75047
|
+
const enums = graphql22.parse(graphql22.printSchema(config2.schema)).definitions.filter(
|
|
75159
75048
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
75160
75049
|
).filter((def) => !config2.isInternalEnum(def));
|
|
75161
75050
|
const { code: runtimeDefinitions } = await printJS(
|
|
75162
75051
|
AST13.program(
|
|
75163
75052
|
enums.map((defn) => {
|
|
75164
75053
|
const name = defn.name.value;
|
|
75165
|
-
|
|
75054
|
+
const declaration = moduleExport(
|
|
75166
75055
|
config2,
|
|
75167
75056
|
name,
|
|
75168
75057
|
AST13.objectExpression(
|
|
75169
75058
|
defn.values?.map((value) => {
|
|
75170
75059
|
const str = value.name.value;
|
|
75171
|
-
|
|
75060
|
+
const prop = AST13.objectProperty(
|
|
75172
75061
|
AST13.stringLiteral(str),
|
|
75173
75062
|
AST13.stringLiteral(str)
|
|
75174
75063
|
);
|
|
75064
|
+
const deprecationReason = value.directives?.find((d) => d.name.value === "deprecated")?.arguments?.find((a) => a.name.value === "reason")?.value?.value;
|
|
75065
|
+
if (value.description || deprecationReason)
|
|
75066
|
+
prop.comments = [
|
|
75067
|
+
jsdocComment(value.description?.value ?? "", deprecationReason)
|
|
75068
|
+
];
|
|
75069
|
+
return prop;
|
|
75175
75070
|
}) || []
|
|
75176
75071
|
)
|
|
75177
75072
|
);
|
|
75073
|
+
if (defn.description) {
|
|
75074
|
+
declaration.comments = [
|
|
75075
|
+
AST13.commentBlock(`* ${defn.description.value} `, true, false)
|
|
75076
|
+
];
|
|
75077
|
+
}
|
|
75078
|
+
return declaration;
|
|
75178
75079
|
})
|
|
75179
75080
|
)
|
|
75180
75081
|
);
|
|
@@ -75183,11 +75084,19 @@ type ValuesOf<T> = T[keyof T]
|
|
|
75183
75084
|
` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
|
|
75184
75085
|
const name = definition.name.value;
|
|
75185
75086
|
const values = definition.values;
|
|
75186
|
-
|
|
75087
|
+
let jsdoc = "";
|
|
75088
|
+
if (definition.description) {
|
|
75089
|
+
jsdoc = `
|
|
75090
|
+
/** ${definition.description.value} */`;
|
|
75091
|
+
}
|
|
75092
|
+
return `${jsdoc}
|
|
75187
75093
|
export declare const ${name}: {
|
|
75188
|
-
${values?.map(
|
|
75094
|
+
${values?.map(
|
|
75095
|
+
(value) => (value.description ? ` /** ${value.description.value} */
|
|
75096
|
+
` : "") + ` readonly ${value.name.value}: "${value.name.value}";`
|
|
75097
|
+
).join("\n")}
|
|
75189
75098
|
}
|
|
75190
|
-
|
|
75099
|
+
${jsdoc}
|
|
75191
75100
|
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
75192
75101
|
`;
|
|
75193
75102
|
}).join("");
|
|
@@ -75207,7 +75116,7 @@ async function schemaGenerator(config2) {
|
|
|
75207
75116
|
await Promise.all([
|
|
75208
75117
|
fs_exports.writeFile(
|
|
75209
75118
|
config2.definitionsSchemaPath,
|
|
75210
|
-
config2.localSchema ?
|
|
75119
|
+
config2.localSchema ? graphql23.printSchema(config2.schema) : config2.newSchema
|
|
75211
75120
|
),
|
|
75212
75121
|
fs_exports.writeFile(config2.definitionsDocumentsPath, config2.newDocuments),
|
|
75213
75122
|
definitionsGenerator(config2)
|
|
@@ -76912,7 +76821,7 @@ function mergeGraphQLTypes2(typeSource, config2) {
|
|
|
76912
76821
|
}
|
|
76913
76822
|
|
|
76914
76823
|
// src/codegen/transforms/schema.ts
|
|
76915
|
-
import * as
|
|
76824
|
+
import * as graphql24 from "graphql";
|
|
76916
76825
|
async function graphqlExtensions(config2, documents) {
|
|
76917
76826
|
let internalSchema = `
|
|
76918
76827
|
enum CachePolicy {
|
|
@@ -77035,7 +76944,7 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
|
|
|
77035
76944
|
const args = fragmentArguments(config2, "", field.parent);
|
|
77036
76945
|
if (args.length > 0) {
|
|
77037
76946
|
argString = "(" + args.map((arg) => {
|
|
77038
|
-
const typeName =
|
|
76947
|
+
const typeName = graphql24.print(arg.type);
|
|
77039
76948
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
77040
76949
|
}).join("\n") + ")";
|
|
77041
76950
|
}
|
|
@@ -77045,20 +76954,20 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
|
|
|
77045
76954
|
`;
|
|
77046
76955
|
}).join("\n");
|
|
77047
76956
|
extensions += `${Object.keys(config2.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
77048
|
-
config2.newSchema =
|
|
76957
|
+
config2.newSchema = graphql24.print(mergeTypeDefs2([internalSchema, config2.newSchema]));
|
|
77049
76958
|
config2.schemaString += extensions;
|
|
77050
|
-
config2.schema =
|
|
77051
|
-
|
|
77052
|
-
mergeTypeDefs2([
|
|
76959
|
+
config2.schema = graphql24.buildSchema(
|
|
76960
|
+
graphql24.print(
|
|
76961
|
+
mergeTypeDefs2([graphql24.printSchema(config2.schema), internalSchema, extensions])
|
|
77053
76962
|
)
|
|
77054
76963
|
);
|
|
77055
76964
|
}
|
|
77056
76965
|
|
|
77057
76966
|
// src/codegen/transforms/typename.ts
|
|
77058
|
-
import * as
|
|
76967
|
+
import * as graphql25 from "graphql";
|
|
77059
76968
|
async function addTypename(config2, documents) {
|
|
77060
76969
|
for (const doc of documents) {
|
|
77061
|
-
doc.document =
|
|
76970
|
+
doc.document = graphql25.visit(doc.document, {
|
|
77062
76971
|
Field(node, key, parent2, path3, ancestors) {
|
|
77063
76972
|
if (!node.selectionSet) {
|
|
77064
76973
|
return;
|
|
@@ -77070,7 +76979,7 @@ async function addTypename(config2, documents) {
|
|
|
77070
76979
|
);
|
|
77071
76980
|
const field = type.getFields()[node.name.value];
|
|
77072
76981
|
const fieldType = unwrapType(config2, field.type).type;
|
|
77073
|
-
if (
|
|
76982
|
+
if (graphql25.isInterfaceType(fieldType) || graphql25.isUnionType(fieldType)) {
|
|
77074
76983
|
return {
|
|
77075
76984
|
...node,
|
|
77076
76985
|
selectionSet: {
|
|
@@ -77078,9 +76987,9 @@ async function addTypename(config2, documents) {
|
|
|
77078
76987
|
selections: [
|
|
77079
76988
|
...node.selectionSet.selections,
|
|
77080
76989
|
{
|
|
77081
|
-
kind:
|
|
76990
|
+
kind: graphql25.Kind.FIELD,
|
|
77082
76991
|
name: {
|
|
77083
|
-
kind:
|
|
76992
|
+
kind: graphql25.Kind.NAME,
|
|
77084
76993
|
value: "__typename"
|
|
77085
76994
|
}
|
|
77086
76995
|
}
|
|
@@ -77097,9 +77006,9 @@ async function addTypename(config2, documents) {
|
|
|
77097
77006
|
selections: [
|
|
77098
77007
|
...node.selectionSet.selections,
|
|
77099
77008
|
{
|
|
77100
|
-
kind:
|
|
77009
|
+
kind: graphql25.Kind.FIELD,
|
|
77101
77010
|
name: {
|
|
77102
|
-
kind:
|
|
77011
|
+
kind: graphql25.Kind.NAME,
|
|
77103
77012
|
value: "__typename"
|
|
77104
77013
|
}
|
|
77105
77014
|
}
|
|
@@ -77112,10 +77021,10 @@ async function addTypename(config2, documents) {
|
|
|
77112
77021
|
}
|
|
77113
77022
|
|
|
77114
77023
|
// src/codegen/transforms/addID.ts
|
|
77115
|
-
import * as
|
|
77024
|
+
import * as graphql26 from "graphql";
|
|
77116
77025
|
async function addID(config2, documents) {
|
|
77117
77026
|
for (const doc of documents) {
|
|
77118
|
-
doc.document =
|
|
77027
|
+
doc.document = graphql26.visit(doc.document, {
|
|
77119
77028
|
Field(node, key, parent2, path3, ancestors) {
|
|
77120
77029
|
if (!node.selectionSet) {
|
|
77121
77030
|
return;
|
|
@@ -77153,7 +77062,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77153
77062
|
if (!node.selectionSet || node.selectionSet.selections.length == 0) {
|
|
77154
77063
|
return;
|
|
77155
77064
|
}
|
|
77156
|
-
if (!
|
|
77065
|
+
if (!graphql26.isObjectType(fieldType) && !graphql26.isInterfaceType(fieldType)) {
|
|
77157
77066
|
return;
|
|
77158
77067
|
}
|
|
77159
77068
|
const keyFields = config2.keyFieldsForType(fieldType.name);
|
|
@@ -77168,9 +77077,9 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77168
77077
|
continue;
|
|
77169
77078
|
}
|
|
77170
77079
|
selections.push({
|
|
77171
|
-
kind:
|
|
77080
|
+
kind: graphql26.Kind.FIELD,
|
|
77172
77081
|
name: {
|
|
77173
|
-
kind:
|
|
77082
|
+
kind: graphql26.Kind.NAME,
|
|
77174
77083
|
value: keyField
|
|
77175
77084
|
}
|
|
77176
77085
|
});
|
|
@@ -77185,13 +77094,13 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77185
77094
|
}
|
|
77186
77095
|
|
|
77187
77096
|
// src/codegen/transforms/componentFields.ts
|
|
77188
|
-
import * as
|
|
77097
|
+
import * as graphql27 from "graphql";
|
|
77189
77098
|
async function componentFields(config2, documents) {
|
|
77190
77099
|
for (const document of documents) {
|
|
77191
|
-
const typeInfo = new
|
|
77192
|
-
document.document =
|
|
77100
|
+
const typeInfo = new graphql27.TypeInfo(config2.schema);
|
|
77101
|
+
document.document = graphql27.visit(
|
|
77193
77102
|
document.document,
|
|
77194
|
-
|
|
77103
|
+
graphql27.visitWithTypeInfo(typeInfo, {
|
|
77195
77104
|
Field(node) {
|
|
77196
77105
|
const parentType = typeInfo.getParentType();
|
|
77197
77106
|
if (!parentType) {
|
|
@@ -77240,10 +77149,10 @@ async function componentFields(config2, documents) {
|
|
|
77240
77149
|
}
|
|
77241
77150
|
|
|
77242
77151
|
// src/codegen/transforms/runtimeScalars.ts
|
|
77243
|
-
import * as
|
|
77152
|
+
import * as graphql28 from "graphql";
|
|
77244
77153
|
async function addTypename2(config2, documents) {
|
|
77245
77154
|
for (const doc of documents) {
|
|
77246
|
-
doc.document =
|
|
77155
|
+
doc.document = graphql28.visit(doc.document, {
|
|
77247
77156
|
VariableDefinition(node) {
|
|
77248
77157
|
const { type, wrappers } = unwrapType(config2, node.type);
|
|
77249
77158
|
const runtimeScalar = config2.configFile.features?.runtimeScalars?.[type.name];
|
|
@@ -77282,7 +77191,7 @@ async function addTypename2(config2, documents) {
|
|
|
77282
77191
|
}
|
|
77283
77192
|
|
|
77284
77193
|
// src/codegen/validators/typeCheck.ts
|
|
77285
|
-
import * as
|
|
77194
|
+
import * as graphql29 from "graphql";
|
|
77286
77195
|
async function typeCheck(config2, docs) {
|
|
77287
77196
|
const errors = [];
|
|
77288
77197
|
const freeLists = [];
|
|
@@ -77290,7 +77199,7 @@ async function typeCheck(config2, docs) {
|
|
|
77290
77199
|
const listTypes = [];
|
|
77291
77200
|
const fragments = {};
|
|
77292
77201
|
for (const { document: parsed, originalString, filename } of docs) {
|
|
77293
|
-
|
|
77202
|
+
graphql29.visit(parsed, {
|
|
77294
77203
|
FragmentDefinition(definition) {
|
|
77295
77204
|
fragments[definition.name.value] = definition;
|
|
77296
77205
|
},
|
|
@@ -77335,14 +77244,14 @@ async function typeCheck(config2, docs) {
|
|
|
77335
77244
|
);
|
|
77336
77245
|
return;
|
|
77337
77246
|
}
|
|
77338
|
-
if (
|
|
77247
|
+
if (graphql29.isListType(rootType) || graphql29.isNonNullType(rootType) && graphql29.isListType(rootType.ofType)) {
|
|
77339
77248
|
needsParent = true;
|
|
77340
77249
|
break;
|
|
77341
77250
|
}
|
|
77342
|
-
if (
|
|
77251
|
+
if (graphql29.isNonNullType(rootType) && "ofType" in rootType) {
|
|
77343
77252
|
rootType = rootType.ofType;
|
|
77344
77253
|
}
|
|
77345
|
-
if (
|
|
77254
|
+
if (graphql29.isScalarType(rootType)) {
|
|
77346
77255
|
break;
|
|
77347
77256
|
}
|
|
77348
77257
|
rootType = rootType?.getFields()[parent3.name.value]?.type;
|
|
@@ -77418,9 +77327,9 @@ async function typeCheck(config2, docs) {
|
|
|
77418
77327
|
);
|
|
77419
77328
|
}
|
|
77420
77329
|
let targetTypes = [type];
|
|
77421
|
-
if (
|
|
77330
|
+
if (graphql29.isUnionType(type)) {
|
|
77422
77331
|
targetTypes = config2.schema.getPossibleTypes(type);
|
|
77423
|
-
} else if (
|
|
77332
|
+
} else if (graphql29.isInterfaceType(type)) {
|
|
77424
77333
|
try {
|
|
77425
77334
|
for (const key of config2.keyFieldsForType(type.name)) {
|
|
77426
77335
|
if (!type.getFields()[key]) {
|
|
@@ -77456,13 +77365,13 @@ async function typeCheck(config2, docs) {
|
|
|
77456
77365
|
if (errors.length > 0) {
|
|
77457
77366
|
throw errors;
|
|
77458
77367
|
}
|
|
77459
|
-
const rules = (filepath) => [...
|
|
77368
|
+
const rules = (filepath) => [...graphql29.specifiedRules].filter(
|
|
77460
77369
|
(rule) => ![
|
|
77461
|
-
|
|
77462
|
-
|
|
77463
|
-
|
|
77464
|
-
|
|
77465
|
-
|
|
77370
|
+
graphql29.NoUnusedFragmentsRule,
|
|
77371
|
+
graphql29.KnownFragmentNamesRule,
|
|
77372
|
+
graphql29.ExecutableDefinitionsRule,
|
|
77373
|
+
graphql29.KnownDirectivesRule,
|
|
77374
|
+
graphql29.KnownArgumentNamesRule
|
|
77466
77375
|
].includes(rule)
|
|
77467
77376
|
).concat(
|
|
77468
77377
|
validateLists({
|
|
@@ -77483,7 +77392,7 @@ async function typeCheck(config2, docs) {
|
|
|
77483
77392
|
validateLoadingDirective(config2)
|
|
77484
77393
|
);
|
|
77485
77394
|
for (const { filename, document: parsed, originalString } of docs) {
|
|
77486
|
-
for (const error of
|
|
77395
|
+
for (const error of graphql29.validate(config2.schema, parsed, rules(filename))) {
|
|
77487
77396
|
errors.push(
|
|
77488
77397
|
new HoudiniError({
|
|
77489
77398
|
filepath: filename,
|
|
@@ -77512,20 +77421,20 @@ function validateRequiredDirective(config2, filepath) {
|
|
|
77512
77421
|
if (!node.directives?.some(({ name }) => name.value === config2.requiredDirective))
|
|
77513
77422
|
return;
|
|
77514
77423
|
const parentType = parentTypeFromAncestors(config2.schema, filepath, ancestors);
|
|
77515
|
-
if (!
|
|
77424
|
+
if (!graphql29.isObjectType(parentType)) {
|
|
77516
77425
|
ctx.reportError(
|
|
77517
|
-
new
|
|
77426
|
+
new graphql29.GraphQLError(
|
|
77518
77427
|
`@${config2.requiredDirective} may only be used on objects, not arguments`
|
|
77519
77428
|
)
|
|
77520
77429
|
);
|
|
77521
77430
|
return;
|
|
77522
77431
|
}
|
|
77523
77432
|
const type = parentType.getFields()[node.name.value].type;
|
|
77524
|
-
const isServerNullable = !
|
|
77433
|
+
const isServerNullable = !graphql29.isNonNullType(type);
|
|
77525
77434
|
const isAlreadyClientNullable = isClientNullable(node, true);
|
|
77526
77435
|
if (!isServerNullable && !isAlreadyClientNullable) {
|
|
77527
77436
|
ctx.reportError(
|
|
77528
|
-
new
|
|
77437
|
+
new graphql29.GraphQLError(
|
|
77529
77438
|
`@${config2.requiredDirective} may only be used on nullable fields`
|
|
77530
77439
|
)
|
|
77531
77440
|
);
|
|
@@ -77547,7 +77456,7 @@ var validateLists = ({
|
|
|
77547
77456
|
if (!config2.isListFragment(node.name.value)) {
|
|
77548
77457
|
if (!fragments[node.name.value]) {
|
|
77549
77458
|
ctx.reportError(
|
|
77550
|
-
new
|
|
77459
|
+
new graphql29.GraphQLError(
|
|
77551
77460
|
"Encountered unknown fragment: " + node.name.value
|
|
77552
77461
|
)
|
|
77553
77462
|
);
|
|
@@ -77557,7 +77466,7 @@ var validateLists = ({
|
|
|
77557
77466
|
const listName = config2.listNameFromFragment(node.name.value);
|
|
77558
77467
|
if (!lists.includes(listName)) {
|
|
77559
77468
|
ctx.reportError(
|
|
77560
|
-
new
|
|
77469
|
+
new graphql29.GraphQLError(
|
|
77561
77470
|
"Encountered fragment referencing unknown list: " + listName
|
|
77562
77471
|
)
|
|
77563
77472
|
);
|
|
@@ -77582,7 +77491,7 @@ var validateLists = ({
|
|
|
77582
77491
|
);
|
|
77583
77492
|
if (parentArg) {
|
|
77584
77493
|
ctx.reportError(
|
|
77585
|
-
new
|
|
77494
|
+
new graphql29.GraphQLError(
|
|
77586
77495
|
`@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
77587
77496
|
)
|
|
77588
77497
|
);
|
|
@@ -77598,7 +77507,7 @@ var validateLists = ({
|
|
|
77598
77507
|
return;
|
|
77599
77508
|
}
|
|
77600
77509
|
ctx.reportError(
|
|
77601
|
-
new
|
|
77510
|
+
new graphql29.GraphQLError(
|
|
77602
77511
|
`For this list fragment, you need to add or @${config2.listParentDirective} or @${config2.listAllListsDirective} directive to specify the behavior`
|
|
77603
77512
|
)
|
|
77604
77513
|
);
|
|
@@ -77608,7 +77517,7 @@ var validateLists = ({
|
|
|
77608
77517
|
const directiveName = node.name.value;
|
|
77609
77518
|
if (directiveName === "connection") {
|
|
77610
77519
|
ctx.reportError(
|
|
77611
|
-
new
|
|
77520
|
+
new graphql29.GraphQLError(
|
|
77612
77521
|
"@connection was renamed to @list. Please change your components. If you were using `cache.connection` in your components, you will need to update that to `cache.list` too."
|
|
77613
77522
|
)
|
|
77614
77523
|
);
|
|
@@ -77617,7 +77526,7 @@ var validateLists = ({
|
|
|
77617
77526
|
if (!config2.isInternalDirective(node.name.value)) {
|
|
77618
77527
|
if (!config2.schema.getDirective(directiveName)) {
|
|
77619
77528
|
ctx.reportError(
|
|
77620
|
-
new
|
|
77529
|
+
new graphql29.GraphQLError(
|
|
77621
77530
|
"Encountered unknown directive: " + directiveName
|
|
77622
77531
|
)
|
|
77623
77532
|
);
|
|
@@ -77626,7 +77535,7 @@ var validateLists = ({
|
|
|
77626
77535
|
}
|
|
77627
77536
|
if (config2.isListOperationDirective(directiveName) && !listTypes.includes(config2.listNameFromDirective(directiveName))) {
|
|
77628
77537
|
ctx.reportError(
|
|
77629
|
-
new
|
|
77538
|
+
new graphql29.GraphQLError(
|
|
77630
77539
|
"Encountered directive referencing unknown list: " + directiveName
|
|
77631
77540
|
)
|
|
77632
77541
|
);
|
|
@@ -77637,7 +77546,7 @@ var validateLists = ({
|
|
|
77637
77546
|
};
|
|
77638
77547
|
function knownArguments(config2) {
|
|
77639
77548
|
return function(ctx) {
|
|
77640
|
-
const nativeValidator =
|
|
77549
|
+
const nativeValidator = graphql29.KnownArgumentNamesRule(ctx);
|
|
77641
77550
|
return {
|
|
77642
77551
|
...nativeValidator,
|
|
77643
77552
|
Directive(directiveNode) {
|
|
@@ -77672,7 +77581,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77672
77581
|
for (const arg of node.arguments || []) {
|
|
77673
77582
|
if (arg.value.kind !== "ObjectValue") {
|
|
77674
77583
|
ctx.reportError(
|
|
77675
|
-
new
|
|
77584
|
+
new graphql29.GraphQLError("values in @arguments must be an object")
|
|
77676
77585
|
);
|
|
77677
77586
|
return;
|
|
77678
77587
|
}
|
|
@@ -77682,13 +77591,13 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77682
77591
|
);
|
|
77683
77592
|
if (!typeArg) {
|
|
77684
77593
|
ctx.reportError(
|
|
77685
|
-
new
|
|
77594
|
+
new graphql29.GraphQLError("missing type field for @arguments directive")
|
|
77686
77595
|
);
|
|
77687
77596
|
return;
|
|
77688
77597
|
}
|
|
77689
|
-
if (typeArg.value.kind !==
|
|
77598
|
+
if (typeArg.value.kind !== graphql29.Kind.STRING) {
|
|
77690
77599
|
ctx.reportError(
|
|
77691
|
-
new
|
|
77600
|
+
new graphql29.GraphQLError("type field to @arguments must be a string")
|
|
77692
77601
|
);
|
|
77693
77602
|
return;
|
|
77694
77603
|
}
|
|
@@ -77701,7 +77610,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77701
77610
|
);
|
|
77702
77611
|
if (typeArg.value.value !== defaultValueType) {
|
|
77703
77612
|
ctx.reportError(
|
|
77704
|
-
new
|
|
77613
|
+
new graphql29.GraphQLError(
|
|
77705
77614
|
`Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
|
|
77706
77615
|
)
|
|
77707
77616
|
);
|
|
@@ -77719,7 +77628,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77719
77628
|
try {
|
|
77720
77629
|
args = fragmentArguments(config2, filepath, fragments[fragmentName]);
|
|
77721
77630
|
} catch (e2) {
|
|
77722
|
-
ctx.reportError(new
|
|
77631
|
+
ctx.reportError(new graphql29.GraphQLError(e2.message));
|
|
77723
77632
|
return;
|
|
77724
77633
|
}
|
|
77725
77634
|
fragmentArguments2[fragmentName] = args;
|
|
@@ -77742,7 +77651,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77742
77651
|
);
|
|
77743
77652
|
if (missing.length > 0) {
|
|
77744
77653
|
ctx.reportError(
|
|
77745
|
-
new
|
|
77654
|
+
new graphql29.GraphQLError(
|
|
77746
77655
|
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
77747
77656
|
)
|
|
77748
77657
|
);
|
|
@@ -77753,7 +77662,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77753
77662
|
);
|
|
77754
77663
|
if (unknown.length > 0) {
|
|
77755
77664
|
ctx.reportError(
|
|
77756
|
-
new
|
|
77665
|
+
new graphql29.GraphQLError(
|
|
77757
77666
|
"Encountered unknown arguments: " + JSON.stringify(unknown)
|
|
77758
77667
|
)
|
|
77759
77668
|
);
|
|
@@ -77765,7 +77674,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77765
77674
|
for (const [applied, target] of zipped) {
|
|
77766
77675
|
if (!valueIsType(config2, applied.value, target)) {
|
|
77767
77676
|
ctx.reportError(
|
|
77768
|
-
new
|
|
77677
|
+
new graphql29.GraphQLError(
|
|
77769
77678
|
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
77770
77679
|
)
|
|
77771
77680
|
);
|
|
@@ -77807,7 +77716,7 @@ function valueIsType(config2, value, targetType) {
|
|
|
77807
77716
|
}
|
|
77808
77717
|
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
77809
77718
|
const enumType = config2.schema.getType(targetType.name.value);
|
|
77810
|
-
if (!
|
|
77719
|
+
if (!graphql29.isEnumType(enumType)) {
|
|
77811
77720
|
return false;
|
|
77812
77721
|
}
|
|
77813
77722
|
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
@@ -77827,7 +77736,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77827
77736
|
}
|
|
77828
77737
|
if (alreadyPaginated) {
|
|
77829
77738
|
ctx.reportError(
|
|
77830
|
-
new
|
|
77739
|
+
new graphql29.GraphQLError(
|
|
77831
77740
|
`@${config2.paginateDirective} can only appear in a document once.`
|
|
77832
77741
|
)
|
|
77833
77742
|
);
|
|
@@ -77859,7 +77768,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77859
77768
|
const backwards = appliedArgs.has("last");
|
|
77860
77769
|
if (!forward && !backwards) {
|
|
77861
77770
|
ctx.reportError(
|
|
77862
|
-
new
|
|
77771
|
+
new graphql29.GraphQLError(
|
|
77863
77772
|
"A field with cursor-based pagination must have a first or last argument"
|
|
77864
77773
|
)
|
|
77865
77774
|
);
|
|
@@ -77873,7 +77782,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77873
77782
|
}
|
|
77874
77783
|
if (forward && backwards && paginateMode === "Infinite") {
|
|
77875
77784
|
ctx.reportError(
|
|
77876
|
-
new
|
|
77785
|
+
new graphql29.GraphQLError(
|
|
77877
77786
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
77878
77787
|
)
|
|
77879
77788
|
);
|
|
@@ -77887,7 +77796,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77887
77796
|
);
|
|
77888
77797
|
if (!appliedLimitArg) {
|
|
77889
77798
|
ctx.reportError(
|
|
77890
|
-
new
|
|
77799
|
+
new graphql29.GraphQLError(
|
|
77891
77800
|
"A field with offset-based pagination must have a limit argument"
|
|
77892
77801
|
)
|
|
77893
77802
|
);
|
|
@@ -77903,20 +77812,20 @@ function noUnusedFragmentArguments(config2) {
|
|
|
77903
77812
|
const args = /* @__PURE__ */ new Set();
|
|
77904
77813
|
return {
|
|
77905
77814
|
enter(node) {
|
|
77906
|
-
if (node.kind ===
|
|
77815
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
77907
77816
|
const definitionArguments = node.directives?.filter((directive) => directive.name.value === config2.argumentsDirective).flatMap((directive) => directive.arguments);
|
|
77908
77817
|
for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
|
|
77909
77818
|
args.add(arg);
|
|
77910
77819
|
}
|
|
77911
|
-
} else if (node.kind ===
|
|
77820
|
+
} else if (node.kind === graphql29.Kind.VARIABLE) {
|
|
77912
77821
|
args.delete(node.name.value);
|
|
77913
77822
|
}
|
|
77914
77823
|
},
|
|
77915
77824
|
leave(node) {
|
|
77916
|
-
if (node.kind ===
|
|
77825
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
77917
77826
|
if (args.size > 0) {
|
|
77918
77827
|
ctx.reportError(
|
|
77919
|
-
new
|
|
77828
|
+
new graphql29.GraphQLError(
|
|
77920
77829
|
"Encountered unused fragment arguments: " + [...args].join(",")
|
|
77921
77830
|
)
|
|
77922
77831
|
);
|
|
@@ -77952,7 +77861,7 @@ function nodeDirectives(config2, directives) {
|
|
|
77952
77861
|
if (definition.kind === "OperationDefinition") {
|
|
77953
77862
|
if (definition.operation !== "query") {
|
|
77954
77863
|
ctx.reportError(
|
|
77955
|
-
new
|
|
77864
|
+
new graphql29.GraphQLError(
|
|
77956
77865
|
`@${node.name.value} must fall on a fragment or query document`
|
|
77957
77866
|
)
|
|
77958
77867
|
);
|
|
@@ -77964,7 +77873,7 @@ function nodeDirectives(config2, directives) {
|
|
|
77964
77873
|
}
|
|
77965
77874
|
if (!possibleNodes.includes(definitionType)) {
|
|
77966
77875
|
ctx.reportError(
|
|
77967
|
-
new
|
|
77876
|
+
new graphql29.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
77968
77877
|
);
|
|
77969
77878
|
}
|
|
77970
77879
|
}
|
|
@@ -77983,7 +77892,7 @@ function checkMutationOperation(config2) {
|
|
|
77983
77892
|
);
|
|
77984
77893
|
if (append && prepend) {
|
|
77985
77894
|
ctx.reportError(
|
|
77986
|
-
new
|
|
77895
|
+
new graphql29.GraphQLError(
|
|
77987
77896
|
`You can't apply both @${config2.listPrependDirective} and @${config2.listAppendDirective} at the same time`
|
|
77988
77897
|
)
|
|
77989
77898
|
);
|
|
@@ -77997,7 +77906,7 @@ function checkMutationOperation(config2) {
|
|
|
77997
77906
|
);
|
|
77998
77907
|
if (parentId && allLists) {
|
|
77999
77908
|
ctx.reportError(
|
|
78000
|
-
new
|
|
77909
|
+
new graphql29.GraphQLError(
|
|
78001
77910
|
`You can't apply both @${config2.listParentDirective} and @${config2.listAllListsDirective} at the same time`
|
|
78002
77911
|
)
|
|
78003
77912
|
);
|
|
@@ -78019,7 +77928,7 @@ function checkMaskDirectives(config2) {
|
|
|
78019
77928
|
);
|
|
78020
77929
|
if (maskEnableDirective && maskDisableDirective) {
|
|
78021
77930
|
ctx.reportError(
|
|
78022
|
-
new
|
|
77931
|
+
new graphql29.GraphQLError(
|
|
78023
77932
|
`You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
|
|
78024
77933
|
)
|
|
78025
77934
|
);
|
|
@@ -78061,7 +77970,7 @@ function validateLoadingDirective(config2) {
|
|
|
78061
77970
|
);
|
|
78062
77971
|
if (!parentLoading && !global2) {
|
|
78063
77972
|
ctx.reportError(
|
|
78064
|
-
new
|
|
77973
|
+
new graphql29.GraphQLError(
|
|
78065
77974
|
`@${config2.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config2.loadingDirective}`
|
|
78066
77975
|
)
|
|
78067
77976
|
);
|
|
@@ -78083,7 +77992,7 @@ function validateLoadingDirective(config2) {
|
|
|
78083
77992
|
);
|
|
78084
77993
|
if (!parentLoading && !global2) {
|
|
78085
77994
|
ctx.reportError(
|
|
78086
|
-
new
|
|
77995
|
+
new graphql29.GraphQLError(
|
|
78087
77996
|
`@${config2.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config2.loadingDirective}`
|
|
78088
77997
|
)
|
|
78089
77998
|
);
|
|
@@ -78098,7 +78007,7 @@ function getAndVerifyNodeInterface(config2) {
|
|
|
78098
78007
|
if (!nodeInterface) {
|
|
78099
78008
|
return null;
|
|
78100
78009
|
}
|
|
78101
|
-
if (!
|
|
78010
|
+
if (!graphql29.isInterfaceType(nodeInterface)) {
|
|
78102
78011
|
displayInvalidNodeFieldMessage(config2);
|
|
78103
78012
|
return null;
|
|
78104
78013
|
}
|
|
@@ -78193,11 +78102,11 @@ async function uniqueDocumentNames(config2, docs) {
|
|
|
78193
78102
|
}
|
|
78194
78103
|
|
|
78195
78104
|
// src/codegen/validators/noIDAlias.ts
|
|
78196
|
-
import * as
|
|
78105
|
+
import * as graphql30 from "graphql";
|
|
78197
78106
|
async function noIDAlias(config2, docs) {
|
|
78198
78107
|
const errors = [];
|
|
78199
78108
|
for (const { filename, document } of docs) {
|
|
78200
|
-
|
|
78109
|
+
graphql30.visit(document, {
|
|
78201
78110
|
Field(node, _, __, ___, ancestors) {
|
|
78202
78111
|
const fieldType = parentTypeFromAncestors(config2.schema, filename, ancestors).name;
|
|
78203
78112
|
if (config2.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
|
|
@@ -78236,11 +78145,11 @@ async function validatePlugins(config2, documents) {
|
|
|
78236
78145
|
}
|
|
78237
78146
|
|
|
78238
78147
|
// src/codegen/validators/componentFields.ts
|
|
78239
|
-
import * as
|
|
78148
|
+
import * as graphql31 from "graphql";
|
|
78240
78149
|
async function componentFields2(config2, docs) {
|
|
78241
78150
|
const errors = [];
|
|
78242
78151
|
for (const { filename: filepath, document } of docs) {
|
|
78243
|
-
|
|
78152
|
+
graphql31.visit(document, {
|
|
78244
78153
|
FragmentDefinition(node, _, __, ___, ancestors) {
|
|
78245
78154
|
const componentFieldDirective = node.directives?.find(
|
|
78246
78155
|
(dir) => dir.name.value === config2.componentFieldDirective
|
|
@@ -78288,7 +78197,7 @@ async function componentFields2(config2, docs) {
|
|
|
78288
78197
|
if (existingField && existingField.filepath !== filepath) {
|
|
78289
78198
|
conflict = true;
|
|
78290
78199
|
} else if (parentType && fieldValue) {
|
|
78291
|
-
const fieldDef =
|
|
78200
|
+
const fieldDef = graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
78292
78201
|
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
78293
78202
|
(dir) => dir.name.value === config2.componentFieldDirective
|
|
78294
78203
|
)) {
|
|
@@ -78301,7 +78210,7 @@ async function componentFields2(config2, docs) {
|
|
|
78301
78210
|
filepath
|
|
78302
78211
|
});
|
|
78303
78212
|
}
|
|
78304
|
-
if (parentType &&
|
|
78213
|
+
if (parentType && graphql31.isAbstractType(parentType)) {
|
|
78305
78214
|
errors.push({
|
|
78306
78215
|
message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
|
|
78307
78216
|
filepath
|
|
@@ -78522,12 +78431,12 @@ async function processJSFile(config2, contents) {
|
|
|
78522
78431
|
return documents;
|
|
78523
78432
|
}
|
|
78524
78433
|
async function processGraphQLDocument(config2, filepath, document) {
|
|
78525
|
-
const parsedDoc =
|
|
78434
|
+
const parsedDoc = graphql32.parse(document);
|
|
78526
78435
|
const operations = parsedDoc.definitions.filter(
|
|
78527
|
-
({ kind: kind2 }) => kind2 ===
|
|
78436
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.OPERATION_DEFINITION
|
|
78528
78437
|
);
|
|
78529
78438
|
const fragments = parsedDoc.definitions.filter(
|
|
78530
|
-
({ kind: kind2 }) => kind2 ===
|
|
78439
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.FRAGMENT_DEFINITION
|
|
78531
78440
|
);
|
|
78532
78441
|
if (operations.length > 1) {
|
|
78533
78442
|
throw new HoudiniError({
|