houdini 1.2.44 → 1.2.46
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 +664 -848
- package/build/cmd-esm/index.js +514 -698
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen-cjs/index.js +662 -846
- package/build/codegen-esm/index.js +512 -696
- 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 +726 -467
- package/build/lib-esm/index.js +720 -467
- 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/match.d.ts +3 -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/match.d.ts +3 -2
- package/build/runtime-cjs/router/match.js +11 -2
- package/build/runtime-cjs/router/server.js +1 -1
- 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/match.d.ts +3 -2
- package/build/runtime-esm/router/match.js +11 -2
- package/build/runtime-esm/router/server.js +1 -1
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +677 -844
- package/build/test-esm/index.js +527 -694
- package/build/vite-cjs/index.js +786 -857
- package/build/vite-esm/index.js +636 -707
- 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);
|
|
@@ -69710,7 +69473,12 @@ function deepMerge2(filepath, ...targets) {
|
|
|
69710
69473
|
// src/lib/parse.ts
|
|
69711
69474
|
function parseJS(str, config2) {
|
|
69712
69475
|
const defaultConfig = {
|
|
69713
|
-
plugins: [
|
|
69476
|
+
plugins: [
|
|
69477
|
+
"typescript",
|
|
69478
|
+
"importAssertions",
|
|
69479
|
+
"decorators-legacy",
|
|
69480
|
+
"explicitResourceManagement"
|
|
69481
|
+
],
|
|
69714
69482
|
sourceType: "module"
|
|
69715
69483
|
};
|
|
69716
69484
|
return (0, import_parser.parse)(str || "", config2 ? deepMerge2("", defaultConfig, config2) : defaultConfig).program;
|
|
@@ -69782,6 +69550,231 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
69782
69550
|
return allFilesNotInList;
|
|
69783
69551
|
}
|
|
69784
69552
|
|
|
69553
|
+
// src/runtime/router/match.ts
|
|
69554
|
+
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
69555
|
+
function parse_page_pattern(id) {
|
|
69556
|
+
const params = [];
|
|
69557
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
69558
|
+
`^${get_route_segments(id).map((segment) => {
|
|
69559
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
69560
|
+
if (rest_match) {
|
|
69561
|
+
params.push({
|
|
69562
|
+
name: rest_match[1],
|
|
69563
|
+
matcher: rest_match[2],
|
|
69564
|
+
optional: false,
|
|
69565
|
+
rest: true,
|
|
69566
|
+
chained: true
|
|
69567
|
+
});
|
|
69568
|
+
return "(?:/(.*))?";
|
|
69569
|
+
}
|
|
69570
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
69571
|
+
if (optional_match) {
|
|
69572
|
+
params.push({
|
|
69573
|
+
name: optional_match[1],
|
|
69574
|
+
matcher: optional_match[2],
|
|
69575
|
+
optional: true,
|
|
69576
|
+
rest: false,
|
|
69577
|
+
chained: true
|
|
69578
|
+
});
|
|
69579
|
+
return "(?:/([^/]+))?";
|
|
69580
|
+
}
|
|
69581
|
+
if (!segment) {
|
|
69582
|
+
return;
|
|
69583
|
+
}
|
|
69584
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
69585
|
+
const result = parts.map((content, i2) => {
|
|
69586
|
+
if (i2 % 2) {
|
|
69587
|
+
if (content.startsWith("x+")) {
|
|
69588
|
+
return escape2(
|
|
69589
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
69590
|
+
);
|
|
69591
|
+
}
|
|
69592
|
+
if (content.startsWith("u+")) {
|
|
69593
|
+
return escape2(
|
|
69594
|
+
String.fromCharCode(
|
|
69595
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
69596
|
+
)
|
|
69597
|
+
);
|
|
69598
|
+
}
|
|
69599
|
+
const match = param_pattern.exec(content);
|
|
69600
|
+
if (!match) {
|
|
69601
|
+
throw new Error(
|
|
69602
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
69603
|
+
);
|
|
69604
|
+
}
|
|
69605
|
+
const [, is_optional, is_rest, name, matcher] = match;
|
|
69606
|
+
params.push({
|
|
69607
|
+
name,
|
|
69608
|
+
matcher,
|
|
69609
|
+
optional: !!is_optional,
|
|
69610
|
+
rest: !!is_rest,
|
|
69611
|
+
chained: is_rest ? i2 === 1 && parts[0] === "" : false
|
|
69612
|
+
});
|
|
69613
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
69614
|
+
}
|
|
69615
|
+
return escape2(content);
|
|
69616
|
+
}).join("");
|
|
69617
|
+
return "/" + result;
|
|
69618
|
+
}).join("")}/?$`
|
|
69619
|
+
);
|
|
69620
|
+
return { pattern, params, page_id: id };
|
|
69621
|
+
}
|
|
69622
|
+
function affects_path(segment) {
|
|
69623
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
69624
|
+
}
|
|
69625
|
+
function get_route_segments(route) {
|
|
69626
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
69627
|
+
}
|
|
69628
|
+
function escape2(str) {
|
|
69629
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
69630
|
+
}
|
|
69631
|
+
|
|
69632
|
+
// src/lib/typescript.ts
|
|
69633
|
+
var recast2 = __toESM(require_main2(), 1);
|
|
69634
|
+
import * as graphql4 from "graphql";
|
|
69635
|
+
var AST2 = recast2.types.builders;
|
|
69636
|
+
function unwrappedTsTypeReference(config2, filepath, missingScalars, {
|
|
69637
|
+
type,
|
|
69638
|
+
wrappers
|
|
69639
|
+
}, body) {
|
|
69640
|
+
let result;
|
|
69641
|
+
if (graphql4.isScalarType(type)) {
|
|
69642
|
+
result = scalarPropertyValue(config2, filepath, missingScalars, type, body, null);
|
|
69643
|
+
} else if (graphql4.isEnumType(type)) {
|
|
69644
|
+
result = enumReference(config2, body, type.name);
|
|
69645
|
+
} else {
|
|
69646
|
+
result = AST2.tsTypeReference(AST2.identifier(type.name));
|
|
69647
|
+
}
|
|
69648
|
+
for (const toWrap of wrappers) {
|
|
69649
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
69650
|
+
continue;
|
|
69651
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
69652
|
+
result = nullableField(result, true);
|
|
69653
|
+
} else if (toWrap === "List" /* List */) {
|
|
69654
|
+
result = AST2.tsArrayType(AST2.tsParenthesizedType(result));
|
|
69655
|
+
}
|
|
69656
|
+
}
|
|
69657
|
+
return result;
|
|
69658
|
+
}
|
|
69659
|
+
function tsTypeReference(config2, filepath, missingScalars, definition, body) {
|
|
69660
|
+
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
69661
|
+
return unwrappedTsTypeReference(
|
|
69662
|
+
config2,
|
|
69663
|
+
filepath,
|
|
69664
|
+
missingScalars,
|
|
69665
|
+
{ type, wrappers },
|
|
69666
|
+
body
|
|
69667
|
+
);
|
|
69668
|
+
}
|
|
69669
|
+
function enumReference(config2, body, name) {
|
|
69670
|
+
ensureImports({
|
|
69671
|
+
config: config2,
|
|
69672
|
+
body,
|
|
69673
|
+
import: ["ValueOf"],
|
|
69674
|
+
importKind: "type",
|
|
69675
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
69676
|
+
});
|
|
69677
|
+
return AST2.tsTypeReference(
|
|
69678
|
+
AST2.identifier("ValueOf"),
|
|
69679
|
+
AST2.tsTypeParameterInstantiation([AST2.tsTypeQuery(AST2.identifier(name))])
|
|
69680
|
+
);
|
|
69681
|
+
}
|
|
69682
|
+
function readonlyProperty(prop, enable = true) {
|
|
69683
|
+
if (enable) {
|
|
69684
|
+
prop.readonly = true;
|
|
69685
|
+
}
|
|
69686
|
+
return prop;
|
|
69687
|
+
}
|
|
69688
|
+
function nullableField(inner, input = false) {
|
|
69689
|
+
const members = [inner, AST2.tsNullKeyword()];
|
|
69690
|
+
if (input) {
|
|
69691
|
+
members.push(AST2.tsUndefinedKeyword());
|
|
69692
|
+
}
|
|
69693
|
+
return AST2.tsUnionType(members);
|
|
69694
|
+
}
|
|
69695
|
+
function scalarPropertyValue(config2, filepath, missingScalars, target, body, field) {
|
|
69696
|
+
if (config2.configFile.features?.componentFields && target.name === config2.componentScalar) {
|
|
69697
|
+
if (!field) {
|
|
69698
|
+
return AST2.tsNeverKeyword();
|
|
69699
|
+
}
|
|
69700
|
+
const component = config2.componentFields[field.parent][field.field];
|
|
69701
|
+
const sourcePathRelative = path_exports.relative(
|
|
69702
|
+
path_exports.join(config2.projectRoot, "src"),
|
|
69703
|
+
component.filepath
|
|
69704
|
+
);
|
|
69705
|
+
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
69706
|
+
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
69707
|
+
const localImport = ensureImports({
|
|
69708
|
+
config: config2,
|
|
69709
|
+
body,
|
|
69710
|
+
import: "__component__" + component.fragment,
|
|
69711
|
+
sourceModule: path_exports.join(
|
|
69712
|
+
path_exports.relative(path_exports.dirname(filepath), config2.projectRoot),
|
|
69713
|
+
"src",
|
|
69714
|
+
sourcePath
|
|
69715
|
+
)
|
|
69716
|
+
}) ?? "__component__" + component.fragment;
|
|
69717
|
+
const parameters = AST2.tsTypeReference(AST2.identifier("Parameters"));
|
|
69718
|
+
parameters.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69719
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
69720
|
+
]);
|
|
69721
|
+
const indexed = AST2.tsIndexedAccessType(
|
|
69722
|
+
parameters,
|
|
69723
|
+
AST2.tsLiteralType(AST2.numericLiteral(0))
|
|
69724
|
+
);
|
|
69725
|
+
const omit = AST2.tsTypeReference(AST2.identifier("Omit"));
|
|
69726
|
+
omit.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69727
|
+
indexed,
|
|
69728
|
+
AST2.tsLiteralType(AST2.stringLiteral(component.prop))
|
|
69729
|
+
]);
|
|
69730
|
+
const arg = AST2.identifier("props");
|
|
69731
|
+
arg.typeAnnotation = AST2.tsTypeAnnotation(omit);
|
|
69732
|
+
const returnType = AST2.tsTypeReference(AST2.identifier("ReturnType"));
|
|
69733
|
+
returnType.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
69734
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
69735
|
+
]);
|
|
69736
|
+
const fnType = AST2.tsFunctionType([arg]);
|
|
69737
|
+
fnType.typeAnnotation = AST2.tsTypeAnnotation(returnType);
|
|
69738
|
+
return fnType;
|
|
69739
|
+
}
|
|
69740
|
+
switch (target.name) {
|
|
69741
|
+
case "String": {
|
|
69742
|
+
return AST2.tsStringKeyword();
|
|
69743
|
+
}
|
|
69744
|
+
case "Int": {
|
|
69745
|
+
return AST2.tsNumberKeyword();
|
|
69746
|
+
}
|
|
69747
|
+
case "Float": {
|
|
69748
|
+
return AST2.tsNumberKeyword();
|
|
69749
|
+
}
|
|
69750
|
+
case "Boolean": {
|
|
69751
|
+
return AST2.tsBooleanKeyword();
|
|
69752
|
+
}
|
|
69753
|
+
case "ID": {
|
|
69754
|
+
return AST2.tsStringKeyword();
|
|
69755
|
+
}
|
|
69756
|
+
default: {
|
|
69757
|
+
if (graphql4.isNonNullType(target) && "ofType" in target) {
|
|
69758
|
+
return scalarPropertyValue(
|
|
69759
|
+
config2,
|
|
69760
|
+
filepath,
|
|
69761
|
+
missingScalars,
|
|
69762
|
+
target.ofType,
|
|
69763
|
+
body,
|
|
69764
|
+
field
|
|
69765
|
+
);
|
|
69766
|
+
}
|
|
69767
|
+
if (config2.scalars?.[target.name]) {
|
|
69768
|
+
return AST2.tsTypeReference(AST2.identifier(config2.scalars?.[target.name].type));
|
|
69769
|
+
}
|
|
69770
|
+
if (target.name !== config2.componentScalar) {
|
|
69771
|
+
missingScalars.add(target.name);
|
|
69772
|
+
}
|
|
69773
|
+
return AST2.tsAnyKeyword();
|
|
69774
|
+
}
|
|
69775
|
+
}
|
|
69776
|
+
}
|
|
69777
|
+
|
|
69785
69778
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
69786
69779
|
var WalkerBase = class {
|
|
69787
69780
|
constructor() {
|
|
@@ -69895,7 +69888,7 @@ async function asyncWalk(ast, { enter, leave }) {
|
|
|
69895
69888
|
}
|
|
69896
69889
|
|
|
69897
69890
|
// src/lib/walk.ts
|
|
69898
|
-
import * as
|
|
69891
|
+
import * as graphql5 from "graphql";
|
|
69899
69892
|
async function find_graphql(config2, parsedScript, walker) {
|
|
69900
69893
|
await asyncWalk(parsedScript, {
|
|
69901
69894
|
async enter(node, parent2) {
|
|
@@ -69950,7 +69943,7 @@ async function find_graphql(config2, parsedScript, walker) {
|
|
|
69950
69943
|
} else if (!documentString) {
|
|
69951
69944
|
return;
|
|
69952
69945
|
}
|
|
69953
|
-
const parsedTag =
|
|
69946
|
+
const parsedTag = graphql5.parse(documentString);
|
|
69954
69947
|
if (walker.where && !walker.where(parsedTag, { node, parent: parent2 })) {
|
|
69955
69948
|
return;
|
|
69956
69949
|
}
|
|
@@ -70082,7 +70075,7 @@ function extractAnonymousQuery(config2, raw, expr, propName) {
|
|
|
70082
70075
|
};
|
|
70083
70076
|
return defs.concat([
|
|
70084
70077
|
{
|
|
70085
|
-
raw:
|
|
70078
|
+
raw: graphql5.print(parsed),
|
|
70086
70079
|
parsed
|
|
70087
70080
|
}
|
|
70088
70081
|
]);
|
|
@@ -70223,7 +70216,7 @@ function serialized_manifest_path(config2, base = base_dir(config2)) {
|
|
|
70223
70216
|
|
|
70224
70217
|
// src/lib/router/manifest.ts
|
|
70225
70218
|
var t2 = __toESM(require_lib6(), 1);
|
|
70226
|
-
import * as
|
|
70219
|
+
import * as graphql6 from "graphql";
|
|
70227
70220
|
async function load_manifest(args) {
|
|
70228
70221
|
const manifest = await walk_routes({
|
|
70229
70222
|
config: args.config,
|
|
@@ -70240,7 +70233,8 @@ async function load_manifest(args) {
|
|
|
70240
70233
|
local_yoga: false
|
|
70241
70234
|
},
|
|
70242
70235
|
queries: [],
|
|
70243
|
-
layouts: []
|
|
70236
|
+
layouts: [],
|
|
70237
|
+
variables: {}
|
|
70244
70238
|
});
|
|
70245
70239
|
if (args.includeArtifacts) {
|
|
70246
70240
|
try {
|
|
@@ -70271,6 +70265,7 @@ async function walk_routes(args) {
|
|
|
70271
70265
|
const directory_contents = await fs_exports.readdir(args.filepath, {
|
|
70272
70266
|
withFileTypes: true
|
|
70273
70267
|
});
|
|
70268
|
+
const variables = { ...args.variables };
|
|
70274
70269
|
let newLayouts = args.layouts;
|
|
70275
70270
|
let newLayoutQueries = args.queries;
|
|
70276
70271
|
let layout = null;
|
|
@@ -70294,7 +70289,8 @@ async function walk_routes(args) {
|
|
|
70294
70289
|
url: args.url,
|
|
70295
70290
|
project: args.project,
|
|
70296
70291
|
type: "layout",
|
|
70297
|
-
contents: layoutQueryContents
|
|
70292
|
+
contents: layoutQueryContents,
|
|
70293
|
+
variables
|
|
70298
70294
|
});
|
|
70299
70295
|
newLayoutQueries = [...args.queries, layoutQuery.name];
|
|
70300
70296
|
}
|
|
@@ -70307,7 +70303,8 @@ async function walk_routes(args) {
|
|
|
70307
70303
|
contents: layoutViewContents,
|
|
70308
70304
|
layouts: args.layouts,
|
|
70309
70305
|
queries: newLayoutQueries,
|
|
70310
|
-
config: args.config
|
|
70306
|
+
config: args.config,
|
|
70307
|
+
variables
|
|
70311
70308
|
});
|
|
70312
70309
|
newLayouts = [...args.layouts, page_id(layout.url)];
|
|
70313
70310
|
}
|
|
@@ -70318,7 +70315,8 @@ async function walk_routes(args) {
|
|
|
70318
70315
|
url: args.url,
|
|
70319
70316
|
project: args.project,
|
|
70320
70317
|
type: "page",
|
|
70321
|
-
contents: pageQueryContents
|
|
70318
|
+
contents: pageQueryContents,
|
|
70319
|
+
variables
|
|
70322
70320
|
});
|
|
70323
70321
|
}
|
|
70324
70322
|
if (pageViewContents) {
|
|
@@ -70330,7 +70328,8 @@ async function walk_routes(args) {
|
|
|
70330
70328
|
contents: pageViewContents,
|
|
70331
70329
|
layouts: newLayouts,
|
|
70332
70330
|
queries: pageQuery ? [...newLayoutQueries, pageQuery.name] : newLayoutQueries,
|
|
70333
|
-
config: args.config
|
|
70331
|
+
config: args.config,
|
|
70332
|
+
variables
|
|
70334
70333
|
});
|
|
70335
70334
|
}
|
|
70336
70335
|
await Promise.all(
|
|
@@ -70343,7 +70342,8 @@ async function walk_routes(args) {
|
|
|
70343
70342
|
filepath: path_exports.join(args.filepath, dir.name),
|
|
70344
70343
|
url: `${args.url}${dir.name}/`,
|
|
70345
70344
|
queries: newLayoutQueries,
|
|
70346
|
-
layouts: newLayouts
|
|
70345
|
+
layouts: newLayouts,
|
|
70346
|
+
variables
|
|
70347
70347
|
});
|
|
70348
70348
|
})
|
|
70349
70349
|
);
|
|
@@ -70365,12 +70365,18 @@ async function add_view(args) {
|
|
|
70365
70365
|
url: args.url,
|
|
70366
70366
|
layouts: args.layouts,
|
|
70367
70367
|
path: path_exports.relative(args.config.projectRoot, args.path),
|
|
70368
|
-
query_options: args.queries
|
|
70368
|
+
query_options: args.queries,
|
|
70369
|
+
params: Object.fromEntries(
|
|
70370
|
+
parse_page_pattern(args.url).params.map((param) => [
|
|
70371
|
+
param.name,
|
|
70372
|
+
args.variables[param.name] ?? null
|
|
70373
|
+
])
|
|
70374
|
+
)
|
|
70369
70375
|
};
|
|
70370
70376
|
return target[id];
|
|
70371
70377
|
}
|
|
70372
70378
|
async function add_query(args) {
|
|
70373
|
-
const parsed =
|
|
70379
|
+
const parsed = graphql6.parse(args.contents);
|
|
70374
70380
|
const query2 = parsed.definitions.find(
|
|
70375
70381
|
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
70376
70382
|
);
|
|
@@ -70378,20 +70384,30 @@ async function add_query(args) {
|
|
|
70378
70384
|
throw new Error("No query found");
|
|
70379
70385
|
}
|
|
70380
70386
|
let loading = false;
|
|
70381
|
-
await
|
|
70387
|
+
await graphql6.visit(parsed, {
|
|
70382
70388
|
Directive(node) {
|
|
70383
70389
|
if (node.name.value === args.config.loadingDirective) {
|
|
70384
70390
|
loading = true;
|
|
70385
70391
|
}
|
|
70386
70392
|
}
|
|
70387
70393
|
});
|
|
70394
|
+
const queryVariables = Object.fromEntries(
|
|
70395
|
+
query2.variableDefinitions?.map((variable) => {
|
|
70396
|
+
const { type, wrappers } = unwrapType(args.config, variable.type, [], true);
|
|
70397
|
+
return [
|
|
70398
|
+
variable.variable.name.value,
|
|
70399
|
+
{ wrappers, type: type.name }
|
|
70400
|
+
];
|
|
70401
|
+
}) ?? []
|
|
70402
|
+
);
|
|
70403
|
+
Object.assign(args.variables, queryVariables);
|
|
70388
70404
|
const target = args.type === "page" ? args.project.page_queries : args.project.layout_queries;
|
|
70389
70405
|
target[page_id(args.url)] = {
|
|
70390
70406
|
path: path_exports.relative(args.config.routesDir, args.path),
|
|
70391
70407
|
name: query2.name.value,
|
|
70392
70408
|
url: args.url,
|
|
70393
70409
|
loading,
|
|
70394
|
-
variables:
|
|
70410
|
+
variables: queryVariables
|
|
70395
70411
|
};
|
|
70396
70412
|
return target[page_id(args.url)];
|
|
70397
70413
|
}
|
|
@@ -70445,7 +70461,18 @@ async function extractQueries(source) {
|
|
|
70445
70461
|
} else {
|
|
70446
70462
|
return [];
|
|
70447
70463
|
}
|
|
70448
|
-
return props.
|
|
70464
|
+
return props.reduce((queries, query2) => {
|
|
70465
|
+
if (query2 === "children") {
|
|
70466
|
+
return queries;
|
|
70467
|
+
}
|
|
70468
|
+
if (query2.endsWith("$handle")) {
|
|
70469
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
70470
|
+
}
|
|
70471
|
+
if (queries.includes(query2)) {
|
|
70472
|
+
return queries;
|
|
70473
|
+
}
|
|
70474
|
+
return queries.concat([query2]);
|
|
70475
|
+
}, []);
|
|
70449
70476
|
}
|
|
70450
70477
|
|
|
70451
70478
|
// src/lib/router/server.ts
|
|
@@ -70487,8 +70514,8 @@ async function loadLocalSchema(config2) {
|
|
|
70487
70514
|
}
|
|
70488
70515
|
|
|
70489
70516
|
// src/codegen/generators/artifacts/index.ts
|
|
70490
|
-
var
|
|
70491
|
-
import * as
|
|
70517
|
+
var recast5 = __toESM(require_main2(), 1);
|
|
70518
|
+
import * as graphql17 from "graphql";
|
|
70492
70519
|
|
|
70493
70520
|
// src/codegen/utils/commonjs.ts
|
|
70494
70521
|
var cjsIndexFilePreamble = `"use strict";
|
|
@@ -70730,19 +70757,19 @@ var FieldCollection = class {
|
|
|
70730
70757
|
};
|
|
70731
70758
|
|
|
70732
70759
|
// src/codegen/utils/moduleExport.ts
|
|
70733
|
-
var
|
|
70734
|
-
var
|
|
70760
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
70761
|
+
var AST3 = recast3.types.builders;
|
|
70735
70762
|
function moduleExport(config2, key, value) {
|
|
70736
70763
|
if (config2.module === "commonjs") {
|
|
70737
|
-
let target =
|
|
70764
|
+
let target = AST3.memberExpression(AST3.identifier("module"), AST3.identifier("exports"));
|
|
70738
70765
|
if (key !== "default") {
|
|
70739
|
-
target =
|
|
70766
|
+
target = AST3.memberExpression(target, AST3.identifier(key));
|
|
70740
70767
|
}
|
|
70741
|
-
return
|
|
70768
|
+
return AST3.expressionStatement(AST3.assignmentExpression("=", target, value));
|
|
70742
70769
|
}
|
|
70743
|
-
return key === "default" ?
|
|
70744
|
-
|
|
70745
|
-
|
|
70770
|
+
return key === "default" ? AST3.exportDefaultDeclaration(value) : AST3.exportNamedDeclaration(
|
|
70771
|
+
AST3.variableDeclaration("const", [
|
|
70772
|
+
AST3.variableDeclarator(AST3.identifier(key), value)
|
|
70746
70773
|
])
|
|
70747
70774
|
);
|
|
70748
70775
|
}
|
|
@@ -70999,7 +71026,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
70999
71026
|
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
71027
|
|
|
71001
71028
|
// src/codegen/transforms/fragmentVariables.ts
|
|
71002
|
-
import * as
|
|
71029
|
+
import * as graphql8 from "graphql";
|
|
71003
71030
|
|
|
71004
71031
|
// src/codegen/utils/stripLoc.ts
|
|
71005
71032
|
function stripLoc(value) {
|
|
@@ -71020,7 +71047,7 @@ function stripLoc(value) {
|
|
|
71020
71047
|
}
|
|
71021
71048
|
|
|
71022
71049
|
// src/codegen/transforms/collectDefinitions.ts
|
|
71023
|
-
import * as
|
|
71050
|
+
import * as graphql7 from "graphql";
|
|
71024
71051
|
import { Kind as GraphqlKinds } from "graphql";
|
|
71025
71052
|
async function includeFragmentDefinitions(config2, documents) {
|
|
71026
71053
|
const fragments = collectDefinitions(config2, documents);
|
|
@@ -71070,10 +71097,10 @@ function collectDefinitions(config2, docs) {
|
|
|
71070
71097
|
}
|
|
71071
71098
|
function findRequiredFragments(config2, definition) {
|
|
71072
71099
|
const referencedFragments = [];
|
|
71073
|
-
const typeInfo = new
|
|
71074
|
-
definition.selectionSet =
|
|
71100
|
+
const typeInfo = new graphql7.TypeInfo(config2.schema);
|
|
71101
|
+
definition.selectionSet = graphql7.visit(
|
|
71075
71102
|
definition,
|
|
71076
|
-
|
|
71103
|
+
graphql7.visitWithTypeInfo(typeInfo, {
|
|
71077
71104
|
FragmentSpread(node) {
|
|
71078
71105
|
referencedFragments.push(node.name.value);
|
|
71079
71106
|
}
|
|
@@ -71107,7 +71134,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
71107
71134
|
}
|
|
71108
71135
|
|
|
71109
71136
|
// src/codegen/transforms/fragmentVariables.ts
|
|
71110
|
-
var GraphqlKinds2 =
|
|
71137
|
+
var GraphqlKinds2 = graphql8.Kind;
|
|
71111
71138
|
async function fragmentVariables(config2, documents) {
|
|
71112
71139
|
const fragments = collectDefinitions(config2, documents);
|
|
71113
71140
|
const generatedFragments = {};
|
|
@@ -71130,7 +71157,7 @@ async function fragmentVariables(config2, documents) {
|
|
|
71130
71157
|
});
|
|
71131
71158
|
}
|
|
71132
71159
|
const doc = {
|
|
71133
|
-
kind:
|
|
71160
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
71134
71161
|
definitions: Object.values(generatedFragments)
|
|
71135
71162
|
};
|
|
71136
71163
|
documents.push({
|
|
@@ -71201,7 +71228,7 @@ function inlineFragmentArgs({
|
|
|
71201
71228
|
return null;
|
|
71202
71229
|
};
|
|
71203
71230
|
const result = esm_default(
|
|
71204
|
-
|
|
71231
|
+
graphql8.visit(document, {
|
|
71205
71232
|
FragmentSpread(node) {
|
|
71206
71233
|
if (!fragmentDefinitions[node.name.value]) {
|
|
71207
71234
|
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
@@ -71287,7 +71314,7 @@ function inlineFragmentArgs({
|
|
|
71287
71314
|
);
|
|
71288
71315
|
if (newName) {
|
|
71289
71316
|
result.name = {
|
|
71290
|
-
kind:
|
|
71317
|
+
kind: graphql8.Kind.NAME,
|
|
71291
71318
|
value: newName
|
|
71292
71319
|
};
|
|
71293
71320
|
}
|
|
@@ -71454,7 +71481,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
71454
71481
|
}
|
|
71455
71482
|
|
|
71456
71483
|
// src/codegen/generators/artifacts/inputs.ts
|
|
71457
|
-
import * as
|
|
71484
|
+
import * as graphql9 from "graphql";
|
|
71458
71485
|
function inputObject(config2, inputs, runtimeScalars) {
|
|
71459
71486
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
71460
71487
|
const inputObj = {
|
|
@@ -71484,10 +71511,10 @@ function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
|
71484
71511
|
if (visitedTypes.has(type.name)) {
|
|
71485
71512
|
return;
|
|
71486
71513
|
}
|
|
71487
|
-
if (
|
|
71514
|
+
if (graphql9.isEnumType(type) || graphql9.isScalarType(type)) {
|
|
71488
71515
|
return;
|
|
71489
71516
|
}
|
|
71490
|
-
if (
|
|
71517
|
+
if (graphql9.isUnionType(type)) {
|
|
71491
71518
|
return;
|
|
71492
71519
|
}
|
|
71493
71520
|
visitedTypes.add(type.name);
|
|
@@ -71505,50 +71532,50 @@ function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
|
71505
71532
|
}
|
|
71506
71533
|
|
|
71507
71534
|
// src/codegen/generators/artifacts/operations.ts
|
|
71508
|
-
import * as
|
|
71535
|
+
import * as graphql11 from "graphql";
|
|
71509
71536
|
|
|
71510
71537
|
// src/codegen/generators/artifacts/utils.ts
|
|
71511
|
-
var
|
|
71512
|
-
import * as
|
|
71513
|
-
var
|
|
71538
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
71539
|
+
import * as graphql10 from "graphql";
|
|
71540
|
+
var AST4 = recast4.types.builders;
|
|
71514
71541
|
function serializeValue(value) {
|
|
71515
71542
|
if (Array.isArray(value)) {
|
|
71516
|
-
return
|
|
71543
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
71517
71544
|
}
|
|
71518
71545
|
if (typeof value === "object" && value !== null) {
|
|
71519
|
-
return
|
|
71546
|
+
return AST4.objectExpression(
|
|
71520
71547
|
Object.entries(value).filter(([key, value2]) => typeof value2 !== "undefined").map(([key, val]) => {
|
|
71521
|
-
return
|
|
71548
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
71522
71549
|
})
|
|
71523
71550
|
);
|
|
71524
71551
|
}
|
|
71525
71552
|
if (typeof value === "string") {
|
|
71526
71553
|
if (value.indexOf("\n") !== -1) {
|
|
71527
|
-
return
|
|
71528
|
-
[
|
|
71554
|
+
return AST4.templateLiteral(
|
|
71555
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
71529
71556
|
[]
|
|
71530
71557
|
);
|
|
71531
71558
|
}
|
|
71532
|
-
return
|
|
71559
|
+
return AST4.stringLiteral(value);
|
|
71533
71560
|
}
|
|
71534
|
-
return
|
|
71561
|
+
return AST4.literal(value);
|
|
71535
71562
|
}
|
|
71536
71563
|
function convertValue(config2, val) {
|
|
71537
71564
|
let value;
|
|
71538
71565
|
let kind;
|
|
71539
|
-
if (val.kind ===
|
|
71566
|
+
if (val.kind === graphql10.Kind.INT) {
|
|
71540
71567
|
value = parseInt(val.value, 10);
|
|
71541
71568
|
kind = "Int";
|
|
71542
|
-
} else if (val.kind ===
|
|
71569
|
+
} else if (val.kind === graphql10.Kind.FLOAT) {
|
|
71543
71570
|
value = parseFloat(val.value);
|
|
71544
71571
|
kind = "Float";
|
|
71545
|
-
} else if (val.kind ===
|
|
71572
|
+
} else if (val.kind === graphql10.Kind.BOOLEAN) {
|
|
71546
71573
|
value = val.value;
|
|
71547
71574
|
kind = "Boolean";
|
|
71548
|
-
} else if (val.kind ===
|
|
71575
|
+
} else if (val.kind === graphql10.Kind.VARIABLE) {
|
|
71549
71576
|
value = val.name.value;
|
|
71550
71577
|
kind = "Variable";
|
|
71551
|
-
} else if (val.kind ===
|
|
71578
|
+
} else if (val.kind === graphql10.Kind.STRING) {
|
|
71552
71579
|
value = val.value;
|
|
71553
71580
|
kind = "String";
|
|
71554
71581
|
}
|
|
@@ -71561,9 +71588,13 @@ function operationsByPath(config2, filepath, definition, filterTypes) {
|
|
|
71561
71588
|
return {};
|
|
71562
71589
|
}
|
|
71563
71590
|
const pathOperations = {};
|
|
71564
|
-
|
|
71591
|
+
graphql11.visit(definition, {
|
|
71565
71592
|
FragmentSpread(node, _, __, ___, ancestors) {
|
|
71566
|
-
|
|
71593
|
+
let nameWithoutHash = node.name.value;
|
|
71594
|
+
if (node.directives && node.directives.find((directive) => directive.name.value === "with")) {
|
|
71595
|
+
nameWithoutHash = nameWithoutHash.substring(0, nameWithoutHash.lastIndexOf("_"));
|
|
71596
|
+
}
|
|
71597
|
+
if (!config2.isListFragment(nameWithoutHash)) {
|
|
71567
71598
|
return;
|
|
71568
71599
|
}
|
|
71569
71600
|
const path3 = ancestorKey(ancestors);
|
|
@@ -71574,8 +71605,8 @@ function operationsByPath(config2, filepath, definition, filterTypes) {
|
|
|
71574
71605
|
operationObject({
|
|
71575
71606
|
config: config2,
|
|
71576
71607
|
filepath,
|
|
71577
|
-
listName: config2.listNameFromFragment(
|
|
71578
|
-
operationKind: config2.listOperationFromFragment(
|
|
71608
|
+
listName: config2.listNameFromFragment(nameWithoutHash),
|
|
71609
|
+
operationKind: config2.listOperationFromFragment(nameWithoutHash),
|
|
71579
71610
|
type: parentTypeFromAncestors(config2.schema, filepath, ancestors).name,
|
|
71580
71611
|
selection: node
|
|
71581
71612
|
})
|
|
@@ -71720,19 +71751,19 @@ function ancestorKey(ancestors) {
|
|
|
71720
71751
|
}
|
|
71721
71752
|
|
|
71722
71753
|
// src/codegen/generators/artifacts/selection.ts
|
|
71723
|
-
import * as
|
|
71754
|
+
import * as graphql16 from "graphql";
|
|
71724
71755
|
|
|
71725
71756
|
// src/codegen/transforms/list.ts
|
|
71726
|
-
import * as
|
|
71757
|
+
import * as graphql14 from "graphql";
|
|
71727
71758
|
|
|
71728
71759
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
71729
|
-
import * as
|
|
71760
|
+
import * as graphql12 from "graphql";
|
|
71730
71761
|
var objectIdentificationSelection = (config2, type) => {
|
|
71731
71762
|
return config2.keyFieldsForType(type.name).map((key) => {
|
|
71732
71763
|
return {
|
|
71733
|
-
kind:
|
|
71764
|
+
kind: graphql12.Kind.FIELD,
|
|
71734
71765
|
name: {
|
|
71735
|
-
kind:
|
|
71766
|
+
kind: graphql12.Kind.NAME,
|
|
71736
71767
|
value: key
|
|
71737
71768
|
}
|
|
71738
71769
|
};
|
|
@@ -71740,7 +71771,7 @@ var objectIdentificationSelection = (config2, type) => {
|
|
|
71740
71771
|
};
|
|
71741
71772
|
|
|
71742
71773
|
// src/codegen/transforms/paginate.ts
|
|
71743
|
-
import * as
|
|
71774
|
+
import * as graphql13 from "graphql";
|
|
71744
71775
|
async function paginate(config2, documents) {
|
|
71745
71776
|
const newDocs = [];
|
|
71746
71777
|
for (const doc of documents) {
|
|
@@ -71773,7 +71804,7 @@ async function paginate(config2, documents) {
|
|
|
71773
71804
|
};
|
|
71774
71805
|
let cursorType = "String";
|
|
71775
71806
|
let paginationPath = [];
|
|
71776
|
-
doc.document =
|
|
71807
|
+
doc.document = graphql13.visit(doc.document, {
|
|
71777
71808
|
Field(node, _, __, ___, ancestors) {
|
|
71778
71809
|
const paginateDirective = node.directives?.find(
|
|
71779
71810
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -71799,7 +71830,7 @@ async function paginate(config2, documents) {
|
|
|
71799
71830
|
flags.offset.enabled = offsetPagination;
|
|
71800
71831
|
flags.limit.enabled = offsetPagination;
|
|
71801
71832
|
paginationPath = ancestors.filter(
|
|
71802
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
71833
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql13.Kind.FIELD
|
|
71803
71834
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
71804
71835
|
return {
|
|
71805
71836
|
...node,
|
|
@@ -71818,7 +71849,7 @@ async function paginate(config2, documents) {
|
|
|
71818
71849
|
let fragment2 = "";
|
|
71819
71850
|
let paginateMode = config2.defaultPaginateMode;
|
|
71820
71851
|
const requiredArgs = [];
|
|
71821
|
-
doc.document =
|
|
71852
|
+
doc.document = graphql13.visit(doc.document, {
|
|
71822
71853
|
OperationDefinition(node) {
|
|
71823
71854
|
if (node.operation !== "query") {
|
|
71824
71855
|
throw new HoudiniError({
|
|
@@ -71877,9 +71908,9 @@ async function paginate(config2, documents) {
|
|
|
71877
71908
|
directives: [
|
|
71878
71909
|
...node.directives || [],
|
|
71879
71910
|
{
|
|
71880
|
-
kind:
|
|
71911
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71881
71912
|
name: {
|
|
71882
|
-
kind:
|
|
71913
|
+
kind: graphql13.Kind.NAME,
|
|
71883
71914
|
value: config2.argumentsDirective
|
|
71884
71915
|
}
|
|
71885
71916
|
}
|
|
@@ -71949,22 +71980,22 @@ async function paginate(config2, documents) {
|
|
|
71949
71980
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
71950
71981
|
const fragmentSpreadSelection = [
|
|
71951
71982
|
{
|
|
71952
|
-
kind:
|
|
71983
|
+
kind: graphql13.Kind.FRAGMENT_SPREAD,
|
|
71953
71984
|
name: {
|
|
71954
|
-
kind:
|
|
71985
|
+
kind: graphql13.Kind.NAME,
|
|
71955
71986
|
value: fragmentName
|
|
71956
71987
|
},
|
|
71957
71988
|
directives: [
|
|
71958
71989
|
{
|
|
71959
|
-
kind:
|
|
71990
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71960
71991
|
name: {
|
|
71961
|
-
kind:
|
|
71992
|
+
kind: graphql13.Kind.NAME,
|
|
71962
71993
|
value: config2.withDirective
|
|
71963
71994
|
},
|
|
71964
71995
|
["arguments"]: requiredArgs.map((arg) => variableAsArgument(arg.name)).concat(paginationArgs.map(({ name }) => variableAsArgument(name)))
|
|
71965
71996
|
},
|
|
71966
71997
|
{
|
|
71967
|
-
kind:
|
|
71998
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
71968
71999
|
name: {
|
|
71969
72000
|
kind: "Name",
|
|
71970
72001
|
value: config2.maskDisableDirective
|
|
@@ -71991,23 +72022,23 @@ async function paginate(config2, documents) {
|
|
|
71991
72022
|
});
|
|
71992
72023
|
const typeConfig = config2.typeConfig?.[fragment2];
|
|
71993
72024
|
const queryDoc = {
|
|
71994
|
-
kind:
|
|
72025
|
+
kind: graphql13.Kind.DOCUMENT,
|
|
71995
72026
|
definitions: [
|
|
71996
72027
|
{
|
|
71997
|
-
kind:
|
|
72028
|
+
kind: graphql13.Kind.OPERATION_DEFINITION,
|
|
71998
72029
|
name: {
|
|
71999
|
-
kind:
|
|
72030
|
+
kind: graphql13.Kind.NAME,
|
|
72000
72031
|
value: refetchQueryName
|
|
72001
72032
|
},
|
|
72002
72033
|
operation: "query",
|
|
72003
72034
|
variableDefinitions: requiredArgs.map(
|
|
72004
72035
|
(arg) => ({
|
|
72005
|
-
kind:
|
|
72036
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72006
72037
|
type: arg.type,
|
|
72007
72038
|
variable: {
|
|
72008
|
-
kind:
|
|
72039
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72009
72040
|
name: {
|
|
72010
|
-
kind:
|
|
72041
|
+
kind: graphql13.Kind.NAME,
|
|
72011
72042
|
value: arg.name
|
|
72012
72043
|
}
|
|
72013
72044
|
}
|
|
@@ -72015,18 +72046,18 @@ async function paginate(config2, documents) {
|
|
|
72015
72046
|
).concat(
|
|
72016
72047
|
paginationArgs.map(
|
|
72017
72048
|
(arg) => ({
|
|
72018
|
-
kind:
|
|
72049
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72019
72050
|
type: {
|
|
72020
|
-
kind:
|
|
72051
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
72021
72052
|
name: {
|
|
72022
|
-
kind:
|
|
72053
|
+
kind: graphql13.Kind.NAME,
|
|
72023
72054
|
value: arg.type
|
|
72024
72055
|
}
|
|
72025
72056
|
},
|
|
72026
72057
|
variable: {
|
|
72027
|
-
kind:
|
|
72058
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72028
72059
|
name: {
|
|
72029
|
-
kind:
|
|
72060
|
+
kind: graphql13.Kind.NAME,
|
|
72030
72061
|
value: arg.name
|
|
72031
72062
|
}
|
|
72032
72063
|
},
|
|
@@ -72038,12 +72069,12 @@ async function paginate(config2, documents) {
|
|
|
72038
72069
|
).concat(
|
|
72039
72070
|
!nodeQuery ? [] : keys2.map(
|
|
72040
72071
|
(key) => ({
|
|
72041
|
-
kind:
|
|
72072
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72042
72073
|
type: key.type,
|
|
72043
72074
|
variable: {
|
|
72044
|
-
kind:
|
|
72075
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72045
72076
|
name: {
|
|
72046
|
-
kind:
|
|
72077
|
+
kind: graphql13.Kind.NAME,
|
|
72047
72078
|
value: key.name
|
|
72048
72079
|
}
|
|
72049
72080
|
}
|
|
@@ -72052,42 +72083,42 @@ async function paginate(config2, documents) {
|
|
|
72052
72083
|
)
|
|
72053
72084
|
),
|
|
72054
72085
|
selectionSet: {
|
|
72055
|
-
kind:
|
|
72086
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72056
72087
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
72057
72088
|
{
|
|
72058
|
-
kind:
|
|
72089
|
+
kind: graphql13.Kind.FIELD,
|
|
72059
72090
|
name: {
|
|
72060
|
-
kind:
|
|
72091
|
+
kind: graphql13.Kind.NAME,
|
|
72061
72092
|
value: typeConfig?.resolve?.queryField || "node"
|
|
72062
72093
|
},
|
|
72063
72094
|
["arguments"]: keys2.map((key) => ({
|
|
72064
|
-
kind:
|
|
72095
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72065
72096
|
name: {
|
|
72066
|
-
kind:
|
|
72097
|
+
kind: graphql13.Kind.NAME,
|
|
72067
72098
|
value: key.name
|
|
72068
72099
|
},
|
|
72069
72100
|
value: {
|
|
72070
|
-
kind:
|
|
72101
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72071
72102
|
name: {
|
|
72072
|
-
kind:
|
|
72103
|
+
kind: graphql13.Kind.NAME,
|
|
72073
72104
|
value: key.name
|
|
72074
72105
|
}
|
|
72075
72106
|
}
|
|
72076
72107
|
})),
|
|
72077
72108
|
selectionSet: {
|
|
72078
|
-
kind:
|
|
72109
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72079
72110
|
selections: [
|
|
72080
72111
|
{
|
|
72081
|
-
kind:
|
|
72112
|
+
kind: graphql13.Kind.FIELD,
|
|
72082
72113
|
name: {
|
|
72083
|
-
kind:
|
|
72114
|
+
kind: graphql13.Kind.NAME,
|
|
72084
72115
|
value: "__typename"
|
|
72085
72116
|
}
|
|
72086
72117
|
},
|
|
72087
72118
|
...(typeConfig?.keys || [config2.defaultKeys[0]]).map((key) => ({
|
|
72088
|
-
kind:
|
|
72119
|
+
kind: graphql13.Kind.FIELD,
|
|
72089
72120
|
name: {
|
|
72090
|
-
kind:
|
|
72121
|
+
kind: graphql13.Kind.NAME,
|
|
72091
72122
|
value: key
|
|
72092
72123
|
}
|
|
72093
72124
|
})),
|
|
@@ -72144,15 +72175,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
72144
72175
|
}
|
|
72145
72176
|
function variableAsArgument(name, variable) {
|
|
72146
72177
|
return {
|
|
72147
|
-
kind:
|
|
72178
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72148
72179
|
name: {
|
|
72149
|
-
kind:
|
|
72180
|
+
kind: graphql13.Kind.NAME,
|
|
72150
72181
|
value: name
|
|
72151
72182
|
},
|
|
72152
72183
|
value: {
|
|
72153
|
-
kind:
|
|
72184
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72154
72185
|
name: {
|
|
72155
|
-
kind:
|
|
72186
|
+
kind: graphql13.Kind.NAME,
|
|
72156
72187
|
value: variable ?? name
|
|
72157
72188
|
}
|
|
72158
72189
|
}
|
|
@@ -72160,18 +72191,18 @@ function variableAsArgument(name, variable) {
|
|
|
72160
72191
|
}
|
|
72161
72192
|
function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
72162
72193
|
return {
|
|
72163
|
-
kind:
|
|
72194
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
72164
72195
|
type: {
|
|
72165
|
-
kind:
|
|
72196
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
72166
72197
|
name: {
|
|
72167
|
-
kind:
|
|
72198
|
+
kind: graphql13.Kind.NAME,
|
|
72168
72199
|
value: type
|
|
72169
72200
|
}
|
|
72170
72201
|
},
|
|
72171
72202
|
variable: {
|
|
72172
|
-
kind:
|
|
72203
|
+
kind: graphql13.Kind.VARIABLE,
|
|
72173
72204
|
name: {
|
|
72174
|
-
kind:
|
|
72205
|
+
kind: graphql13.Kind.NAME,
|
|
72175
72206
|
value: variableName ?? name
|
|
72176
72207
|
}
|
|
72177
72208
|
},
|
|
@@ -72183,9 +72214,9 @@ function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
|
72183
72214
|
}
|
|
72184
72215
|
function argumentNode(name, value) {
|
|
72185
72216
|
return {
|
|
72186
|
-
kind:
|
|
72217
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
72187
72218
|
name: {
|
|
72188
|
-
kind:
|
|
72219
|
+
kind: graphql13.Kind.NAME,
|
|
72189
72220
|
value: name
|
|
72190
72221
|
},
|
|
72191
72222
|
value: objectNode(value)
|
|
@@ -72193,16 +72224,16 @@ function argumentNode(name, value) {
|
|
|
72193
72224
|
}
|
|
72194
72225
|
function objectNode([type, defaultValue]) {
|
|
72195
72226
|
const node = {
|
|
72196
|
-
kind:
|
|
72227
|
+
kind: graphql13.Kind.OBJECT,
|
|
72197
72228
|
fields: [
|
|
72198
72229
|
{
|
|
72199
|
-
kind:
|
|
72230
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
72200
72231
|
name: {
|
|
72201
|
-
kind:
|
|
72232
|
+
kind: graphql13.Kind.NAME,
|
|
72202
72233
|
value: "type"
|
|
72203
72234
|
},
|
|
72204
72235
|
value: {
|
|
72205
|
-
kind:
|
|
72236
|
+
kind: graphql13.Kind.STRING,
|
|
72206
72237
|
value: type
|
|
72207
72238
|
}
|
|
72208
72239
|
}
|
|
@@ -72210,8 +72241,8 @@ function objectNode([type, defaultValue]) {
|
|
|
72210
72241
|
};
|
|
72211
72242
|
if (defaultValue) {
|
|
72212
72243
|
node.fields.push({
|
|
72213
|
-
kind:
|
|
72214
|
-
name: { kind:
|
|
72244
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
72245
|
+
name: { kind: graphql13.Kind.NAME, value: "default" },
|
|
72215
72246
|
value: {
|
|
72216
72247
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
72217
72248
|
value: defaultValue.toString()
|
|
@@ -72222,34 +72253,34 @@ function objectNode([type, defaultValue]) {
|
|
|
72222
72253
|
}
|
|
72223
72254
|
var pageInfoSelection = [
|
|
72224
72255
|
{
|
|
72225
|
-
kind:
|
|
72256
|
+
kind: graphql13.Kind.FIELD,
|
|
72226
72257
|
name: {
|
|
72227
|
-
kind:
|
|
72258
|
+
kind: graphql13.Kind.NAME,
|
|
72228
72259
|
value: "edges"
|
|
72229
72260
|
},
|
|
72230
72261
|
selectionSet: {
|
|
72231
|
-
kind:
|
|
72262
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72232
72263
|
selections: [
|
|
72233
72264
|
{
|
|
72234
|
-
kind:
|
|
72265
|
+
kind: graphql13.Kind.FIELD,
|
|
72235
72266
|
name: {
|
|
72236
|
-
kind:
|
|
72267
|
+
kind: graphql13.Kind.NAME,
|
|
72237
72268
|
value: "cursor"
|
|
72238
72269
|
}
|
|
72239
72270
|
},
|
|
72240
72271
|
{
|
|
72241
|
-
kind:
|
|
72272
|
+
kind: graphql13.Kind.FIELD,
|
|
72242
72273
|
name: {
|
|
72243
|
-
kind:
|
|
72274
|
+
kind: graphql13.Kind.NAME,
|
|
72244
72275
|
value: "node"
|
|
72245
72276
|
},
|
|
72246
72277
|
selectionSet: {
|
|
72247
|
-
kind:
|
|
72278
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72248
72279
|
selections: [
|
|
72249
72280
|
{
|
|
72250
|
-
kind:
|
|
72281
|
+
kind: graphql13.Kind.FIELD,
|
|
72251
72282
|
name: {
|
|
72252
|
-
kind:
|
|
72283
|
+
kind: graphql13.Kind.NAME,
|
|
72253
72284
|
value: "__typename"
|
|
72254
72285
|
}
|
|
72255
72286
|
}
|
|
@@ -72260,39 +72291,39 @@ var pageInfoSelection = [
|
|
|
72260
72291
|
}
|
|
72261
72292
|
},
|
|
72262
72293
|
{
|
|
72263
|
-
kind:
|
|
72294
|
+
kind: graphql13.Kind.FIELD,
|
|
72264
72295
|
name: {
|
|
72265
|
-
kind:
|
|
72296
|
+
kind: graphql13.Kind.NAME,
|
|
72266
72297
|
value: "pageInfo"
|
|
72267
72298
|
},
|
|
72268
72299
|
selectionSet: {
|
|
72269
|
-
kind:
|
|
72300
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
72270
72301
|
selections: [
|
|
72271
72302
|
{
|
|
72272
|
-
kind:
|
|
72303
|
+
kind: graphql13.Kind.FIELD,
|
|
72273
72304
|
name: {
|
|
72274
|
-
kind:
|
|
72305
|
+
kind: graphql13.Kind.NAME,
|
|
72275
72306
|
value: "hasPreviousPage"
|
|
72276
72307
|
}
|
|
72277
72308
|
},
|
|
72278
72309
|
{
|
|
72279
|
-
kind:
|
|
72310
|
+
kind: graphql13.Kind.FIELD,
|
|
72280
72311
|
name: {
|
|
72281
|
-
kind:
|
|
72312
|
+
kind: graphql13.Kind.NAME,
|
|
72282
72313
|
value: "hasNextPage"
|
|
72283
72314
|
}
|
|
72284
72315
|
},
|
|
72285
72316
|
{
|
|
72286
|
-
kind:
|
|
72317
|
+
kind: graphql13.Kind.FIELD,
|
|
72287
72318
|
name: {
|
|
72288
|
-
kind:
|
|
72319
|
+
kind: graphql13.Kind.NAME,
|
|
72289
72320
|
value: "startCursor"
|
|
72290
72321
|
}
|
|
72291
72322
|
},
|
|
72292
72323
|
{
|
|
72293
|
-
kind:
|
|
72324
|
+
kind: graphql13.Kind.FIELD,
|
|
72294
72325
|
name: {
|
|
72295
|
-
kind:
|
|
72326
|
+
kind: graphql13.Kind.NAME,
|
|
72296
72327
|
value: "endCursor"
|
|
72297
72328
|
}
|
|
72298
72329
|
}
|
|
@@ -72306,17 +72337,17 @@ async function addListFragments(config2, documents) {
|
|
|
72306
72337
|
const lists = {};
|
|
72307
72338
|
const errors = [];
|
|
72308
72339
|
for (const doc of documents) {
|
|
72309
|
-
doc.document =
|
|
72340
|
+
doc.document = graphql14.visit(doc.document, {
|
|
72310
72341
|
Directive(node, key, parent2, path3, ancestors) {
|
|
72311
72342
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
72312
72343
|
const nameArg = node.arguments?.find(
|
|
72313
72344
|
(arg) => arg.name.value === config2.listOrPaginateNameArg
|
|
72314
72345
|
);
|
|
72315
72346
|
let error = {
|
|
72316
|
-
...new
|
|
72347
|
+
...new graphql14.GraphQLError(
|
|
72317
72348
|
"",
|
|
72318
72349
|
node,
|
|
72319
|
-
new
|
|
72350
|
+
new graphql14.Source(""),
|
|
72320
72351
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
72321
72352
|
path3
|
|
72322
72353
|
),
|
|
@@ -72368,7 +72399,7 @@ async function addListFragments(config2, documents) {
|
|
|
72368
72399
|
{
|
|
72369
72400
|
kind: "Argument",
|
|
72370
72401
|
name: {
|
|
72371
|
-
kind:
|
|
72402
|
+
kind: graphql14.Kind.NAME,
|
|
72372
72403
|
value: "connection"
|
|
72373
72404
|
},
|
|
72374
72405
|
value: {
|
|
@@ -72418,7 +72449,7 @@ async function addListFragments(config2, documents) {
|
|
|
72418
72449
|
const validDeletes = [
|
|
72419
72450
|
...new Set(
|
|
72420
72451
|
Object.values(lists).map(({ type }) => {
|
|
72421
|
-
if (!(type instanceof
|
|
72452
|
+
if (!(type instanceof graphql14.GraphQLObjectType)) {
|
|
72422
72453
|
return "";
|
|
72423
72454
|
}
|
|
72424
72455
|
if (config2.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -72432,7 +72463,7 @@ async function addListFragments(config2, documents) {
|
|
|
72432
72463
|
return;
|
|
72433
72464
|
}
|
|
72434
72465
|
const generatedDoc = {
|
|
72435
|
-
kind:
|
|
72466
|
+
kind: graphql14.Kind.DOCUMENT,
|
|
72436
72467
|
definitions: Object.entries(lists).flatMap(
|
|
72437
72468
|
([name, { selection, type }]) => {
|
|
72438
72469
|
const schemaType = config2.schema.getType(type.name);
|
|
@@ -72440,7 +72471,7 @@ async function addListFragments(config2, documents) {
|
|
|
72440
72471
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
72441
72472
|
}
|
|
72442
72473
|
const fragmentSelection = {
|
|
72443
|
-
kind:
|
|
72474
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
72444
72475
|
selections: [...selection.selections]
|
|
72445
72476
|
};
|
|
72446
72477
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -72455,14 +72486,14 @@ async function addListFragments(config2, documents) {
|
|
|
72455
72486
|
{
|
|
72456
72487
|
name: {
|
|
72457
72488
|
value: config2.listInsertFragment(name),
|
|
72458
|
-
kind:
|
|
72489
|
+
kind: graphql14.Kind.NAME
|
|
72459
72490
|
},
|
|
72460
|
-
kind:
|
|
72491
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72461
72492
|
selectionSet: fragmentSelection,
|
|
72462
72493
|
typeCondition: {
|
|
72463
|
-
kind:
|
|
72494
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72464
72495
|
name: {
|
|
72465
|
-
kind:
|
|
72496
|
+
kind: graphql14.Kind.NAME,
|
|
72466
72497
|
value: type.name
|
|
72467
72498
|
}
|
|
72468
72499
|
}
|
|
@@ -72470,32 +72501,32 @@ async function addListFragments(config2, documents) {
|
|
|
72470
72501
|
{
|
|
72471
72502
|
name: {
|
|
72472
72503
|
value: config2.listToggleFragment(name),
|
|
72473
|
-
kind:
|
|
72504
|
+
kind: graphql14.Kind.NAME
|
|
72474
72505
|
},
|
|
72475
|
-
kind:
|
|
72506
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72476
72507
|
selectionSet: fragmentSelection,
|
|
72477
72508
|
typeCondition: {
|
|
72478
|
-
kind:
|
|
72509
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72479
72510
|
name: {
|
|
72480
|
-
kind:
|
|
72511
|
+
kind: graphql14.Kind.NAME,
|
|
72481
72512
|
value: type.name
|
|
72482
72513
|
}
|
|
72483
72514
|
}
|
|
72484
72515
|
},
|
|
72485
72516
|
{
|
|
72486
|
-
kind:
|
|
72517
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
72487
72518
|
name: {
|
|
72488
72519
|
value: config2.listRemoveFragment(name),
|
|
72489
|
-
kind:
|
|
72520
|
+
kind: graphql14.Kind.NAME
|
|
72490
72521
|
},
|
|
72491
72522
|
selectionSet: {
|
|
72492
|
-
kind:
|
|
72523
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
72493
72524
|
selections: [...objectIdentificationSelection(config2, type)]
|
|
72494
72525
|
},
|
|
72495
72526
|
typeCondition: {
|
|
72496
|
-
kind:
|
|
72527
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
72497
72528
|
name: {
|
|
72498
|
-
kind:
|
|
72529
|
+
kind: graphql14.Kind.NAME,
|
|
72499
72530
|
value: type.name
|
|
72500
72531
|
}
|
|
72501
72532
|
}
|
|
@@ -72504,14 +72535,14 @@ async function addListFragments(config2, documents) {
|
|
|
72504
72535
|
}
|
|
72505
72536
|
).concat(
|
|
72506
72537
|
...validDeletes.map((typeName) => ({
|
|
72507
|
-
kind:
|
|
72538
|
+
kind: graphql14.Kind.DIRECTIVE_DEFINITION,
|
|
72508
72539
|
name: {
|
|
72509
|
-
kind:
|
|
72540
|
+
kind: graphql14.Kind.NAME,
|
|
72510
72541
|
value: config2.listDeleteDirective(typeName)
|
|
72511
72542
|
},
|
|
72512
72543
|
locations: [
|
|
72513
72544
|
{
|
|
72514
|
-
kind:
|
|
72545
|
+
kind: graphql14.Kind.NAME,
|
|
72515
72546
|
value: "FIELD"
|
|
72516
72547
|
}
|
|
72517
72548
|
],
|
|
@@ -72519,8 +72550,8 @@ async function addListFragments(config2, documents) {
|
|
|
72519
72550
|
}))
|
|
72520
72551
|
)
|
|
72521
72552
|
};
|
|
72522
|
-
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
72523
|
-
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
72553
|
+
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
72554
|
+
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
72524
72555
|
documents.push({
|
|
72525
72556
|
name: "generated::lists",
|
|
72526
72557
|
kind: ArtifactKind.Fragment,
|
|
@@ -72606,11 +72637,11 @@ var nodeNotDefinedMessage = (config2) => `Looks like you are trying to use the $
|
|
|
72606
72637
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
72607
72638
|
|
|
72608
72639
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
72609
|
-
import * as
|
|
72640
|
+
import * as graphql15 from "graphql";
|
|
72610
72641
|
function fieldKey(config2, field) {
|
|
72611
72642
|
const attributeName = field.alias?.value || field.name.value;
|
|
72612
|
-
const printed =
|
|
72613
|
-
const secondParse =
|
|
72643
|
+
const printed = graphql15.print(field);
|
|
72644
|
+
const secondParse = graphql15.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
72614
72645
|
let paginateMode = config2.defaultPaginateMode;
|
|
72615
72646
|
const paginatedDirective = field.directives?.find(
|
|
72616
72647
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -72733,13 +72764,13 @@ function prepareSelection({
|
|
|
72733
72764
|
} else if ("getFields" in type) {
|
|
72734
72765
|
let typeRef = type.getFields()[field.name.value].type;
|
|
72735
72766
|
fieldType = getRootType(typeRef);
|
|
72736
|
-
nullable = !
|
|
72737
|
-
} else if (
|
|
72767
|
+
nullable = !graphql16.isNonNullType(typeRef);
|
|
72768
|
+
} else if (graphql16.isAbstractType(type)) {
|
|
72738
72769
|
for (const possible of config2.schema.getPossibleTypes(type)) {
|
|
72739
|
-
if (
|
|
72770
|
+
if (graphql16.isObjectType(possible)) {
|
|
72740
72771
|
if (possible.getFields()[field.name.value]) {
|
|
72741
72772
|
fieldType = possible.getFields()[field.name.value].type;
|
|
72742
|
-
nullable = !
|
|
72773
|
+
nullable = !graphql16.isNonNullType(fieldType);
|
|
72743
72774
|
break;
|
|
72744
72775
|
}
|
|
72745
72776
|
}
|
|
@@ -72876,7 +72907,7 @@ function prepareSelection({
|
|
|
72876
72907
|
kind: "value"
|
|
72877
72908
|
} : { kind: "continue" };
|
|
72878
72909
|
const parentType = config2.schema.getType(rootType);
|
|
72879
|
-
if (
|
|
72910
|
+
if (graphql16.isObjectType(parentType) || graphql16.isInterfaceType(parentType)) {
|
|
72880
72911
|
const fieldType2 = parentType.getFields()[field.name.value]?.type;
|
|
72881
72912
|
if (fieldType2) {
|
|
72882
72913
|
const listCount = unwrapType(config2, fieldType2).wrappers.filter(
|
|
@@ -72899,7 +72930,7 @@ function prepareSelection({
|
|
|
72899
72930
|
}
|
|
72900
72931
|
fieldObj.loading = loadingValue;
|
|
72901
72932
|
}
|
|
72902
|
-
if (
|
|
72933
|
+
if (graphql16.isInterfaceType(fieldType) || graphql16.isUnionType(fieldType)) {
|
|
72903
72934
|
fieldObj.abstract = true;
|
|
72904
72935
|
if (Object.values(fieldObj.selection?.abstractFields?.fields ?? {}).some(
|
|
72905
72936
|
(fields) => Object.values(fields ?? {}).some((field2) => field2.required)
|
|
@@ -72981,7 +73012,7 @@ function mergeSelection({
|
|
|
72981
73012
|
typeSelection,
|
|
72982
73013
|
abstractSelection.fields[typeName] ?? {}
|
|
72983
73014
|
);
|
|
72984
|
-
if (
|
|
73015
|
+
if (graphql16.isAbstractType(gqlType)) {
|
|
72985
73016
|
for (const possible of config2.schema.getPossibleTypes(gqlType)) {
|
|
72986
73017
|
if (!possibleSelectionTypes[typeName]) {
|
|
72987
73018
|
possibleSelectionTypes[typeName] = [];
|
|
@@ -73016,7 +73047,7 @@ function mergeSelection({
|
|
|
73016
73047
|
}
|
|
73017
73048
|
}
|
|
73018
73049
|
const parentType = config2.schema.getType(rootType);
|
|
73019
|
-
const possibleParents =
|
|
73050
|
+
const possibleParents = graphql16.isAbstractType(parentType) ? config2.schema.getPossibleTypes(parentType)?.map((t3) => t3.name) : [parentType.name];
|
|
73020
73051
|
for (const key of Object.keys(abstractSelection.typeMap)) {
|
|
73021
73052
|
if (!possibleParents.includes(key) && rootType !== key || abstractSelection.fields[key]) {
|
|
73022
73053
|
delete abstractSelection.typeMap[key];
|
|
@@ -73073,12 +73104,12 @@ function mergeSelection({
|
|
|
73073
73104
|
}
|
|
73074
73105
|
|
|
73075
73106
|
// src/codegen/generators/artifacts/index.ts
|
|
73076
|
-
var
|
|
73107
|
+
var AST5 = recast5.types.builders;
|
|
73077
73108
|
function artifactGenerator(stats) {
|
|
73078
73109
|
return async function(config2, docs) {
|
|
73079
73110
|
const filterTypes = {};
|
|
73080
73111
|
for (const doc of docs) {
|
|
73081
|
-
|
|
73112
|
+
graphql17.visit(doc.document, {
|
|
73082
73113
|
Directive(node, _, __, ___, ancestors) {
|
|
73083
73114
|
if (node.name.value !== config2.listDirective) {
|
|
73084
73115
|
return;
|
|
@@ -73138,7 +73169,7 @@ function artifactGenerator(stats) {
|
|
|
73138
73169
|
return;
|
|
73139
73170
|
}
|
|
73140
73171
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
73141
|
-
let documentWithoutInternalDirectives =
|
|
73172
|
+
let documentWithoutInternalDirectives = graphql17.visit(document, {
|
|
73142
73173
|
Directive(node) {
|
|
73143
73174
|
if (config2.isInternalDirective(node.name.value)) {
|
|
73144
73175
|
return null;
|
|
@@ -73151,7 +73182,7 @@ function artifactGenerator(stats) {
|
|
|
73151
73182
|
}
|
|
73152
73183
|
}
|
|
73153
73184
|
});
|
|
73154
|
-
let documentWithoutExtraVariables =
|
|
73185
|
+
let documentWithoutExtraVariables = graphql17.visit(
|
|
73155
73186
|
documentWithoutInternalDirectives,
|
|
73156
73187
|
{
|
|
73157
73188
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -73162,13 +73193,13 @@ function artifactGenerator(stats) {
|
|
|
73162
73193
|
}
|
|
73163
73194
|
}
|
|
73164
73195
|
);
|
|
73165
|
-
let rawString =
|
|
73196
|
+
let rawString = graphql17.print(documentWithoutExtraVariables);
|
|
73166
73197
|
let docKind = doc.kind;
|
|
73167
73198
|
const operations = document.definitions.filter(
|
|
73168
|
-
({ kind }) => kind ===
|
|
73199
|
+
({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
|
|
73169
73200
|
);
|
|
73170
73201
|
const fragments = document.definitions.filter(
|
|
73171
|
-
({ kind }) => kind ===
|
|
73202
|
+
({ kind }) => kind === graphql17.Kind.FRAGMENT_DEFINITION
|
|
73172
73203
|
);
|
|
73173
73204
|
let rootType = "";
|
|
73174
73205
|
let selectionSet;
|
|
@@ -73368,9 +73399,9 @@ function artifactGenerator(stats) {
|
|
|
73368
73399
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
73369
73400
|
}
|
|
73370
73401
|
const _houdiniHash = hashOriginal({ document: doc });
|
|
73371
|
-
const file =
|
|
73402
|
+
const file = AST5.program([
|
|
73372
73403
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
73373
|
-
|
|
73404
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
73374
73405
|
]);
|
|
73375
73406
|
const artifactPath = config2.artifactPath(document);
|
|
73376
73407
|
const countDocument = doc.generateStore;
|
|
@@ -73428,7 +73459,7 @@ function applyMask(config2, target, mask) {
|
|
|
73428
73459
|
if (!targetType) {
|
|
73429
73460
|
continue;
|
|
73430
73461
|
}
|
|
73431
|
-
if (
|
|
73462
|
+
if (graphql17.isAbstractType(targetType)) {
|
|
73432
73463
|
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
73433
73464
|
if (target.abstractFields?.fields[possible.name]) {
|
|
73434
73465
|
applyMask(
|
|
@@ -73451,8 +73482,8 @@ function applyMask(config2, target, mask) {
|
|
|
73451
73482
|
}
|
|
73452
73483
|
|
|
73453
73484
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
73454
|
-
var
|
|
73455
|
-
var
|
|
73485
|
+
var recast6 = __toESM(require_main2(), 1);
|
|
73486
|
+
var AST6 = recast6.types.builders;
|
|
73456
73487
|
async function generateGraphqlReturnTypes(config2, docs) {
|
|
73457
73488
|
const indexPath = path_exports.join(config2.runtimeDirectory, "index.d.ts");
|
|
73458
73489
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
@@ -73487,18 +73518,18 @@ async function generateGraphqlReturnTypes(config2, docs) {
|
|
|
73487
73518
|
continue;
|
|
73488
73519
|
}
|
|
73489
73520
|
for (const [queryString, returnValue] of Object.entries(overloaded_returns)) {
|
|
73490
|
-
const input =
|
|
73491
|
-
input.typeAnnotation =
|
|
73492
|
-
|
|
73521
|
+
const input = AST6.identifier("str");
|
|
73522
|
+
input.typeAnnotation = AST6.tsTypeAnnotation(
|
|
73523
|
+
AST6.tsLiteralType(AST6.stringLiteral(queryString))
|
|
73493
73524
|
);
|
|
73494
73525
|
script.body.splice(
|
|
73495
73526
|
i2,
|
|
73496
73527
|
0,
|
|
73497
|
-
|
|
73498
|
-
|
|
73499
|
-
|
|
73528
|
+
AST6.exportNamedDeclaration(
|
|
73529
|
+
AST6.tsDeclareFunction(
|
|
73530
|
+
AST6.identifier("graphql"),
|
|
73500
73531
|
[input],
|
|
73501
|
-
|
|
73532
|
+
AST6.tsTypeAnnotation(AST6.tsTypeReference(AST6.identifier(returnValue)))
|
|
73502
73533
|
)
|
|
73503
73534
|
)
|
|
73504
73535
|
);
|
|
@@ -73673,165 +73704,22 @@ function moduleStatments(config2) {
|
|
|
73673
73704
|
var recast11 = __toESM(require_main2(), 1);
|
|
73674
73705
|
|
|
73675
73706
|
// 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
73707
|
var recast7 = __toESM(require_main2(), 1);
|
|
73681
73708
|
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
73709
|
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
73710
|
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
73823
73711
|
const { type } = unwrapType(config2, rootType);
|
|
73824
|
-
if (
|
|
73712
|
+
if (graphql18.isScalarType(type)) {
|
|
73825
73713
|
return;
|
|
73826
73714
|
}
|
|
73827
73715
|
if (visitedTypes.has(type.name)) {
|
|
73828
73716
|
return;
|
|
73829
73717
|
}
|
|
73830
|
-
if (
|
|
73718
|
+
if (graphql18.isUnionType(type)) {
|
|
73831
73719
|
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
73832
73720
|
}
|
|
73833
73721
|
visitedTypes.add(type.name);
|
|
73834
|
-
if (
|
|
73722
|
+
if (graphql18.isEnumType(type)) {
|
|
73835
73723
|
ensureImports({
|
|
73836
73724
|
config: config2,
|
|
73837
73725
|
body,
|
|
@@ -73845,21 +73733,37 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
73845
73733
|
for (const field of Object.values(type.getFields())) {
|
|
73846
73734
|
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
73847
73735
|
members.push(
|
|
73848
|
-
|
|
73849
|
-
|
|
73850
|
-
|
|
73736
|
+
AST7.tsPropertySignature(
|
|
73737
|
+
AST7.identifier(field.name),
|
|
73738
|
+
AST7.tsTypeAnnotation(
|
|
73851
73739
|
tsTypeReference(config2, filepath, missingScalars, field, body)
|
|
73852
73740
|
),
|
|
73853
|
-
|
|
73741
|
+
graphql18.isNullableType(field.type)
|
|
73854
73742
|
)
|
|
73855
73743
|
);
|
|
73856
73744
|
}
|
|
73857
|
-
body.push(
|
|
73745
|
+
body.push(AST7.tsTypeAliasDeclaration(AST7.identifier(type.name), AST7.tsTypeLiteral(members)));
|
|
73858
73746
|
}
|
|
73859
73747
|
|
|
73860
73748
|
// src/codegen/generators/typescript/inlineType.ts
|
|
73861
73749
|
var recast9 = __toESM(require_main2(), 1);
|
|
73862
|
-
import * as
|
|
73750
|
+
import * as graphql19 from "graphql";
|
|
73751
|
+
|
|
73752
|
+
// src/codegen/generators/comments/jsdoc.ts
|
|
73753
|
+
var recast8 = __toESM(require_main2(), 1);
|
|
73754
|
+
var AST8 = recast8.types.builders;
|
|
73755
|
+
function jsdocComment(text, deprecated) {
|
|
73756
|
+
let commentContent = `*
|
|
73757
|
+
* ${text}
|
|
73758
|
+
`;
|
|
73759
|
+
if (deprecated) {
|
|
73760
|
+
commentContent = `${commentContent} * @deprecated ${deprecated}
|
|
73761
|
+
`;
|
|
73762
|
+
}
|
|
73763
|
+
return AST8.commentBlock(commentContent, true);
|
|
73764
|
+
}
|
|
73765
|
+
|
|
73766
|
+
// src/codegen/generators/typescript/inlineType.ts
|
|
73863
73767
|
var AST9 = recast9.types.builders;
|
|
73864
73768
|
var fragmentKey2 = " $fragments";
|
|
73865
73769
|
function inlineType({
|
|
@@ -73880,7 +73784,7 @@ function inlineType({
|
|
|
73880
73784
|
const { type, wrappers } = unwrapType(config2, rootType);
|
|
73881
73785
|
let result;
|
|
73882
73786
|
let forceNullable = false;
|
|
73883
|
-
if (
|
|
73787
|
+
if (graphql19.isScalarType(type)) {
|
|
73884
73788
|
result = scalarPropertyValue(
|
|
73885
73789
|
config2,
|
|
73886
73790
|
filepath,
|
|
@@ -73889,7 +73793,7 @@ function inlineType({
|
|
|
73889
73793
|
body,
|
|
73890
73794
|
field
|
|
73891
73795
|
);
|
|
73892
|
-
} else if (
|
|
73796
|
+
} else if (graphql19.isEnumType(type)) {
|
|
73893
73797
|
ensureImports({
|
|
73894
73798
|
config: config2,
|
|
73895
73799
|
body,
|
|
@@ -73914,11 +73818,11 @@ function inlineType({
|
|
|
73914
73818
|
for (const selection of selections) {
|
|
73915
73819
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73916
73820
|
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
73917
|
-
if (!
|
|
73821
|
+
if (!graphql19.isInterfaceType(type) && !graphql19.isUnionType(type)) {
|
|
73918
73822
|
selectedFields.push(...selection.selectionSet.selections);
|
|
73919
73823
|
continue;
|
|
73920
73824
|
}
|
|
73921
|
-
if (!
|
|
73825
|
+
if (!graphql19.isInterfaceType(fragmentType) && !graphql19.isUnionType(fragmentType)) {
|
|
73922
73826
|
if (!inlineFragments[fragmentType.name]) {
|
|
73923
73827
|
inlineFragments[fragmentType.name] = [];
|
|
73924
73828
|
}
|
|
@@ -74010,6 +73914,11 @@ function inlineType({
|
|
|
74010
73914
|
if (allOptional) {
|
|
74011
73915
|
prop.optional = true;
|
|
74012
73916
|
}
|
|
73917
|
+
if (field2.description || field2.deprecationReason) {
|
|
73918
|
+
prop.comments = [
|
|
73919
|
+
jsdocComment(field2.description ?? "", field2.deprecationReason ?? void 0)
|
|
73920
|
+
];
|
|
73921
|
+
}
|
|
74013
73922
|
return prop;
|
|
74014
73923
|
})
|
|
74015
73924
|
]);
|
|
@@ -74061,7 +73970,7 @@ function inlineType({
|
|
|
74061
73970
|
}
|
|
74062
73971
|
}
|
|
74063
73972
|
}
|
|
74064
|
-
if (objectType.type === "TSTypeLiteral" && !
|
|
73973
|
+
if (objectType.type === "TSTypeLiteral" && !graphql19.isInterfaceType(fragmentRootType) && !graphql19.isUnionType(fragmentRootType)) {
|
|
74065
73974
|
const existingTypenameIndex = objectType.members.findIndex(
|
|
74066
73975
|
(member) => member.type === "TSPropertySignature" && member.key.type === "Identifier" && member.key.name === "__typename"
|
|
74067
73976
|
);
|
|
@@ -74086,11 +73995,11 @@ function inlineType({
|
|
|
74086
73995
|
];
|
|
74087
73996
|
}
|
|
74088
73997
|
let coveredTypenames;
|
|
74089
|
-
if (
|
|
73998
|
+
if (graphql19.isInterfaceType(fragmentRootType)) {
|
|
74090
73999
|
coveredTypenames = interfaceCoveredTypenames(fragmentRootType);
|
|
74091
|
-
} else if (
|
|
74000
|
+
} else if (graphql19.isUnionType(fragmentRootType)) {
|
|
74092
74001
|
coveredTypenames = fragmentRootType.getTypes().map((type2) => type2.name);
|
|
74093
|
-
} else if (
|
|
74002
|
+
} else if (graphql19.isObjectType(fragmentRootType)) {
|
|
74094
74003
|
coveredTypenames = [fragmentRootType.name];
|
|
74095
74004
|
} else {
|
|
74096
74005
|
throw Error("unreachable code");
|
|
@@ -74126,7 +74035,7 @@ function inlineType({
|
|
|
74126
74035
|
);
|
|
74127
74036
|
}
|
|
74128
74037
|
);
|
|
74129
|
-
const parentIsUnionOrInterface = !
|
|
74038
|
+
const parentIsUnionOrInterface = !graphql19.isInterfaceType(type) && !graphql19.isUnionType(type);
|
|
74130
74039
|
const possibleTypenames = parentIsUnionOrInterface ? [parent.name] : config2.schema.getPossibleTypes(type).map((type2) => type2.name);
|
|
74131
74040
|
const coveredTypenames = new Set(
|
|
74132
74041
|
Object.values(inlineFragmentSelections).flatMap((sel) => sel.coveredTypenames)
|
|
@@ -74193,7 +74102,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
74193
74102
|
},
|
|
74194
74103
|
type: schema.getType("String")
|
|
74195
74104
|
};
|
|
74196
|
-
} else if (
|
|
74105
|
+
} else if (graphql19.isNonNullType(rootType) && "getFields" in rootType.ofType) {
|
|
74197
74106
|
fields = rootType.ofType.getFields();
|
|
74198
74107
|
} else {
|
|
74199
74108
|
fields = rootType.getFields();
|
|
@@ -74205,7 +74114,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
74205
74114
|
message: `Could not find type information for field ${rootType.toString()}.${selectionName} ${field}`
|
|
74206
74115
|
});
|
|
74207
74116
|
}
|
|
74208
|
-
const fieldType =
|
|
74117
|
+
const fieldType = graphql19.getNamedType(field.type);
|
|
74209
74118
|
if (!fieldType) {
|
|
74210
74119
|
throw new HoudiniError({
|
|
74211
74120
|
filepath,
|
|
@@ -74714,7 +74623,7 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
74714
74623
|
|
|
74715
74624
|
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
74716
74625
|
var recast12 = __toESM(require_main2(), 1);
|
|
74717
|
-
import * as
|
|
74626
|
+
import * as graphql20 from "graphql";
|
|
74718
74627
|
var AST12 = recast12.types.builders;
|
|
74719
74628
|
async function imperativeCacheTypef(config2, docs) {
|
|
74720
74629
|
const returnType = (doc) => config2.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
@@ -74765,7 +74674,7 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74765
74674
|
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
74766
74675
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
74767
74676
|
const types17 = Object.values(config2.schema.getTypeMap()).filter(
|
|
74768
|
-
(type) => !
|
|
74677
|
+
(type) => !graphql20.isAbstractType(type) && !graphql20.isScalarType(type) && !graphql20.isEnumType(type) && !graphql20.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
74769
74678
|
);
|
|
74770
74679
|
const fragmentMap = fragmentListMap(
|
|
74771
74680
|
config2,
|
|
@@ -74782,7 +74691,7 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74782
74691
|
}
|
|
74783
74692
|
let idFields = AST12.tsNeverKeyword();
|
|
74784
74693
|
const keys2 = keyFieldsForType(config2.configFile, type.name);
|
|
74785
|
-
if (
|
|
74694
|
+
if (graphql20.isObjectType(type) && keys2.length > 0 && keys2.every((key) => type.getFields()[key])) {
|
|
74786
74695
|
idFields = AST12.tsTypeLiteral(
|
|
74787
74696
|
keys2.map((key) => {
|
|
74788
74697
|
const fieldType = type.getFields()[key];
|
|
@@ -74809,13 +74718,13 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74809
74718
|
idFields = AST12.tsTypeLiteral([]);
|
|
74810
74719
|
}
|
|
74811
74720
|
let fields = AST12.tsTypeLiteral([]);
|
|
74812
|
-
if (
|
|
74721
|
+
if (graphql20.isObjectType(type)) {
|
|
74813
74722
|
fields = AST12.tsTypeLiteral(
|
|
74814
74723
|
Object.entries(type.getFields()).map(
|
|
74815
74724
|
([key, fieldType]) => {
|
|
74816
74725
|
const unwrapped = unwrapType(config2, fieldType.type);
|
|
74817
74726
|
let typeOptions = AST12.tsUnionType([]);
|
|
74818
|
-
if (
|
|
74727
|
+
if (graphql20.isScalarType(unwrapped.type)) {
|
|
74819
74728
|
typeOptions.types.push(
|
|
74820
74729
|
scalarPropertyValue(
|
|
74821
74730
|
config2,
|
|
@@ -74829,11 +74738,11 @@ function typeDefinitions(config2, filepath, body, docs, returnType) {
|
|
|
74829
74738
|
}
|
|
74830
74739
|
)
|
|
74831
74740
|
);
|
|
74832
|
-
} else if (
|
|
74741
|
+
} else if (graphql20.isEnumType(unwrapped.type)) {
|
|
74833
74742
|
typeOptions.types.push(
|
|
74834
74743
|
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
74835
74744
|
);
|
|
74836
|
-
} else if (!
|
|
74745
|
+
} else if (!graphql20.isAbstractType(unwrapped.type)) {
|
|
74837
74746
|
typeOptions.types.push(record(unwrapped.type.name));
|
|
74838
74747
|
} else {
|
|
74839
74748
|
typeOptions.types.push(
|
|
@@ -74929,7 +74838,7 @@ function listDefinitions(config2, filepath, body, docs) {
|
|
|
74929
74838
|
const lists = [];
|
|
74930
74839
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
74931
74840
|
for (const doc of docs) {
|
|
74932
|
-
|
|
74841
|
+
graphql20.visit(doc.document, {
|
|
74933
74842
|
Directive(node, key, parent2, path3, ancestors) {
|
|
74934
74843
|
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
74935
74844
|
return;
|
|
@@ -74951,7 +74860,7 @@ function listDefinitions(config2, filepath, body, docs) {
|
|
|
74951
74860
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74952
74861
|
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
74953
74862
|
const possibleTypes = [];
|
|
74954
|
-
if (
|
|
74863
|
+
if (graphql20.isAbstractType(listType)) {
|
|
74955
74864
|
possibleTypes.push(
|
|
74956
74865
|
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
74957
74866
|
);
|
|
@@ -75113,7 +75022,7 @@ async function typescriptGenerator(config2, docs) {
|
|
|
75113
75022
|
}
|
|
75114
75023
|
|
|
75115
75024
|
// src/codegen/generators/persistedQueries/index.ts
|
|
75116
|
-
import * as
|
|
75025
|
+
import * as graphql21 from "graphql";
|
|
75117
75026
|
async function persistOutputGenerator(config2, docs) {
|
|
75118
75027
|
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
75119
75028
|
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
@@ -75123,8 +75032,8 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75123
75032
|
if (!generateArtifact) {
|
|
75124
75033
|
return acc;
|
|
75125
75034
|
}
|
|
75126
|
-
let rawString =
|
|
75127
|
-
|
|
75035
|
+
let rawString = graphql21.print(
|
|
75036
|
+
graphql21.visit(document, {
|
|
75128
75037
|
Directive(node) {
|
|
75129
75038
|
if (config2.isInternalDirective(node.name.value)) {
|
|
75130
75039
|
return null;
|
|
@@ -75133,7 +75042,7 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75133
75042
|
})
|
|
75134
75043
|
);
|
|
75135
75044
|
const operations = document.definitions.filter(
|
|
75136
|
-
({ kind }) => kind ===
|
|
75045
|
+
({ kind }) => kind === graphql21.Kind.OPERATION_DEFINITION
|
|
75137
75046
|
);
|
|
75138
75047
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
75139
75048
|
if (artifact) {
|
|
@@ -75148,33 +75057,45 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
75148
75057
|
}
|
|
75149
75058
|
|
|
75150
75059
|
// src/codegen/generators/definitions/index.ts
|
|
75151
|
-
import * as
|
|
75060
|
+
import * as graphql23 from "graphql";
|
|
75152
75061
|
|
|
75153
75062
|
// src/codegen/generators/definitions/enums.ts
|
|
75154
75063
|
var recast13 = __toESM(require_main2(), 1);
|
|
75155
|
-
import * as
|
|
75064
|
+
import * as graphql22 from "graphql";
|
|
75156
75065
|
var AST13 = recast13.types.builders;
|
|
75157
75066
|
async function definitionsGenerator(config2) {
|
|
75158
|
-
const enums =
|
|
75067
|
+
const enums = graphql22.parse(graphql22.printSchema(config2.schema)).definitions.filter(
|
|
75159
75068
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
75160
75069
|
).filter((def) => !config2.isInternalEnum(def));
|
|
75161
75070
|
const { code: runtimeDefinitions } = await printJS(
|
|
75162
75071
|
AST13.program(
|
|
75163
75072
|
enums.map((defn) => {
|
|
75164
75073
|
const name = defn.name.value;
|
|
75165
|
-
|
|
75074
|
+
const declaration = moduleExport(
|
|
75166
75075
|
config2,
|
|
75167
75076
|
name,
|
|
75168
75077
|
AST13.objectExpression(
|
|
75169
75078
|
defn.values?.map((value) => {
|
|
75170
75079
|
const str = value.name.value;
|
|
75171
|
-
|
|
75080
|
+
const prop = AST13.objectProperty(
|
|
75172
75081
|
AST13.stringLiteral(str),
|
|
75173
75082
|
AST13.stringLiteral(str)
|
|
75174
75083
|
);
|
|
75084
|
+
const deprecationReason = value.directives?.find((d) => d.name.value === "deprecated")?.arguments?.find((a) => a.name.value === "reason")?.value?.value;
|
|
75085
|
+
if (value.description || deprecationReason)
|
|
75086
|
+
prop.comments = [
|
|
75087
|
+
jsdocComment(value.description?.value ?? "", deprecationReason)
|
|
75088
|
+
];
|
|
75089
|
+
return prop;
|
|
75175
75090
|
}) || []
|
|
75176
75091
|
)
|
|
75177
75092
|
);
|
|
75093
|
+
if (defn.description) {
|
|
75094
|
+
declaration.comments = [
|
|
75095
|
+
AST13.commentBlock(`* ${defn.description.value} `, true, false)
|
|
75096
|
+
];
|
|
75097
|
+
}
|
|
75098
|
+
return declaration;
|
|
75178
75099
|
})
|
|
75179
75100
|
)
|
|
75180
75101
|
);
|
|
@@ -75183,11 +75104,19 @@ type ValuesOf<T> = T[keyof T]
|
|
|
75183
75104
|
` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
|
|
75184
75105
|
const name = definition.name.value;
|
|
75185
75106
|
const values = definition.values;
|
|
75186
|
-
|
|
75107
|
+
let jsdoc = "";
|
|
75108
|
+
if (definition.description) {
|
|
75109
|
+
jsdoc = `
|
|
75110
|
+
/** ${definition.description.value} */`;
|
|
75111
|
+
}
|
|
75112
|
+
return `${jsdoc}
|
|
75187
75113
|
export declare const ${name}: {
|
|
75188
|
-
${values?.map(
|
|
75114
|
+
${values?.map(
|
|
75115
|
+
(value) => (value.description ? ` /** ${value.description.value} */
|
|
75116
|
+
` : "") + ` readonly ${value.name.value}: "${value.name.value}";`
|
|
75117
|
+
).join("\n")}
|
|
75189
75118
|
}
|
|
75190
|
-
|
|
75119
|
+
${jsdoc}
|
|
75191
75120
|
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
75192
75121
|
`;
|
|
75193
75122
|
}).join("");
|
|
@@ -75207,7 +75136,7 @@ async function schemaGenerator(config2) {
|
|
|
75207
75136
|
await Promise.all([
|
|
75208
75137
|
fs_exports.writeFile(
|
|
75209
75138
|
config2.definitionsSchemaPath,
|
|
75210
|
-
config2.localSchema ?
|
|
75139
|
+
config2.localSchema ? graphql23.printSchema(config2.schema) : config2.newSchema
|
|
75211
75140
|
),
|
|
75212
75141
|
fs_exports.writeFile(config2.definitionsDocumentsPath, config2.newDocuments),
|
|
75213
75142
|
definitionsGenerator(config2)
|
|
@@ -76912,7 +76841,7 @@ function mergeGraphQLTypes2(typeSource, config2) {
|
|
|
76912
76841
|
}
|
|
76913
76842
|
|
|
76914
76843
|
// src/codegen/transforms/schema.ts
|
|
76915
|
-
import * as
|
|
76844
|
+
import * as graphql24 from "graphql";
|
|
76916
76845
|
async function graphqlExtensions(config2, documents) {
|
|
76917
76846
|
let internalSchema = `
|
|
76918
76847
|
enum CachePolicy {
|
|
@@ -77035,7 +76964,7 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
|
|
|
77035
76964
|
const args = fragmentArguments(config2, "", field.parent);
|
|
77036
76965
|
if (args.length > 0) {
|
|
77037
76966
|
argString = "(" + args.map((arg) => {
|
|
77038
|
-
const typeName =
|
|
76967
|
+
const typeName = graphql24.print(arg.type);
|
|
77039
76968
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
77040
76969
|
}).join("\n") + ")";
|
|
77041
76970
|
}
|
|
@@ -77045,20 +76974,20 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
|
|
|
77045
76974
|
`;
|
|
77046
76975
|
}).join("\n");
|
|
77047
76976
|
extensions += `${Object.keys(config2.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
77048
|
-
config2.newSchema =
|
|
76977
|
+
config2.newSchema = graphql24.print(mergeTypeDefs2([internalSchema, config2.newSchema]));
|
|
77049
76978
|
config2.schemaString += extensions;
|
|
77050
|
-
config2.schema =
|
|
77051
|
-
|
|
77052
|
-
mergeTypeDefs2([
|
|
76979
|
+
config2.schema = graphql24.buildSchema(
|
|
76980
|
+
graphql24.print(
|
|
76981
|
+
mergeTypeDefs2([graphql24.printSchema(config2.schema), internalSchema, extensions])
|
|
77053
76982
|
)
|
|
77054
76983
|
);
|
|
77055
76984
|
}
|
|
77056
76985
|
|
|
77057
76986
|
// src/codegen/transforms/typename.ts
|
|
77058
|
-
import * as
|
|
76987
|
+
import * as graphql25 from "graphql";
|
|
77059
76988
|
async function addTypename(config2, documents) {
|
|
77060
76989
|
for (const doc of documents) {
|
|
77061
|
-
doc.document =
|
|
76990
|
+
doc.document = graphql25.visit(doc.document, {
|
|
77062
76991
|
Field(node, key, parent2, path3, ancestors) {
|
|
77063
76992
|
if (!node.selectionSet) {
|
|
77064
76993
|
return;
|
|
@@ -77070,7 +76999,7 @@ async function addTypename(config2, documents) {
|
|
|
77070
76999
|
);
|
|
77071
77000
|
const field = type.getFields()[node.name.value];
|
|
77072
77001
|
const fieldType = unwrapType(config2, field.type).type;
|
|
77073
|
-
if (
|
|
77002
|
+
if (graphql25.isInterfaceType(fieldType) || graphql25.isUnionType(fieldType)) {
|
|
77074
77003
|
return {
|
|
77075
77004
|
...node,
|
|
77076
77005
|
selectionSet: {
|
|
@@ -77078,9 +77007,9 @@ async function addTypename(config2, documents) {
|
|
|
77078
77007
|
selections: [
|
|
77079
77008
|
...node.selectionSet.selections,
|
|
77080
77009
|
{
|
|
77081
|
-
kind:
|
|
77010
|
+
kind: graphql25.Kind.FIELD,
|
|
77082
77011
|
name: {
|
|
77083
|
-
kind:
|
|
77012
|
+
kind: graphql25.Kind.NAME,
|
|
77084
77013
|
value: "__typename"
|
|
77085
77014
|
}
|
|
77086
77015
|
}
|
|
@@ -77097,9 +77026,9 @@ async function addTypename(config2, documents) {
|
|
|
77097
77026
|
selections: [
|
|
77098
77027
|
...node.selectionSet.selections,
|
|
77099
77028
|
{
|
|
77100
|
-
kind:
|
|
77029
|
+
kind: graphql25.Kind.FIELD,
|
|
77101
77030
|
name: {
|
|
77102
|
-
kind:
|
|
77031
|
+
kind: graphql25.Kind.NAME,
|
|
77103
77032
|
value: "__typename"
|
|
77104
77033
|
}
|
|
77105
77034
|
}
|
|
@@ -77112,10 +77041,10 @@ async function addTypename(config2, documents) {
|
|
|
77112
77041
|
}
|
|
77113
77042
|
|
|
77114
77043
|
// src/codegen/transforms/addID.ts
|
|
77115
|
-
import * as
|
|
77044
|
+
import * as graphql26 from "graphql";
|
|
77116
77045
|
async function addID(config2, documents) {
|
|
77117
77046
|
for (const doc of documents) {
|
|
77118
|
-
doc.document =
|
|
77047
|
+
doc.document = graphql26.visit(doc.document, {
|
|
77119
77048
|
Field(node, key, parent2, path3, ancestors) {
|
|
77120
77049
|
if (!node.selectionSet) {
|
|
77121
77050
|
return;
|
|
@@ -77153,7 +77082,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77153
77082
|
if (!node.selectionSet || node.selectionSet.selections.length == 0) {
|
|
77154
77083
|
return;
|
|
77155
77084
|
}
|
|
77156
|
-
if (!
|
|
77085
|
+
if (!graphql26.isObjectType(fieldType) && !graphql26.isInterfaceType(fieldType)) {
|
|
77157
77086
|
return;
|
|
77158
77087
|
}
|
|
77159
77088
|
const keyFields = config2.keyFieldsForType(fieldType.name);
|
|
@@ -77168,9 +77097,9 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77168
77097
|
continue;
|
|
77169
77098
|
}
|
|
77170
77099
|
selections.push({
|
|
77171
|
-
kind:
|
|
77100
|
+
kind: graphql26.Kind.FIELD,
|
|
77172
77101
|
name: {
|
|
77173
|
-
kind:
|
|
77102
|
+
kind: graphql26.Kind.NAME,
|
|
77174
77103
|
value: keyField
|
|
77175
77104
|
}
|
|
77176
77105
|
});
|
|
@@ -77185,13 +77114,13 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77185
77114
|
}
|
|
77186
77115
|
|
|
77187
77116
|
// src/codegen/transforms/componentFields.ts
|
|
77188
|
-
import * as
|
|
77117
|
+
import * as graphql27 from "graphql";
|
|
77189
77118
|
async function componentFields(config2, documents) {
|
|
77190
77119
|
for (const document of documents) {
|
|
77191
|
-
const typeInfo = new
|
|
77192
|
-
document.document =
|
|
77120
|
+
const typeInfo = new graphql27.TypeInfo(config2.schema);
|
|
77121
|
+
document.document = graphql27.visit(
|
|
77193
77122
|
document.document,
|
|
77194
|
-
|
|
77123
|
+
graphql27.visitWithTypeInfo(typeInfo, {
|
|
77195
77124
|
Field(node) {
|
|
77196
77125
|
const parentType = typeInfo.getParentType();
|
|
77197
77126
|
if (!parentType) {
|
|
@@ -77240,10 +77169,10 @@ async function componentFields(config2, documents) {
|
|
|
77240
77169
|
}
|
|
77241
77170
|
|
|
77242
77171
|
// src/codegen/transforms/runtimeScalars.ts
|
|
77243
|
-
import * as
|
|
77172
|
+
import * as graphql28 from "graphql";
|
|
77244
77173
|
async function addTypename2(config2, documents) {
|
|
77245
77174
|
for (const doc of documents) {
|
|
77246
|
-
doc.document =
|
|
77175
|
+
doc.document = graphql28.visit(doc.document, {
|
|
77247
77176
|
VariableDefinition(node) {
|
|
77248
77177
|
const { type, wrappers } = unwrapType(config2, node.type);
|
|
77249
77178
|
const runtimeScalar = config2.configFile.features?.runtimeScalars?.[type.name];
|
|
@@ -77282,7 +77211,7 @@ async function addTypename2(config2, documents) {
|
|
|
77282
77211
|
}
|
|
77283
77212
|
|
|
77284
77213
|
// src/codegen/validators/typeCheck.ts
|
|
77285
|
-
import * as
|
|
77214
|
+
import * as graphql29 from "graphql";
|
|
77286
77215
|
async function typeCheck(config2, docs) {
|
|
77287
77216
|
const errors = [];
|
|
77288
77217
|
const freeLists = [];
|
|
@@ -77290,7 +77219,7 @@ async function typeCheck(config2, docs) {
|
|
|
77290
77219
|
const listTypes = [];
|
|
77291
77220
|
const fragments = {};
|
|
77292
77221
|
for (const { document: parsed, originalString, filename } of docs) {
|
|
77293
|
-
|
|
77222
|
+
graphql29.visit(parsed, {
|
|
77294
77223
|
FragmentDefinition(definition) {
|
|
77295
77224
|
fragments[definition.name.value] = definition;
|
|
77296
77225
|
},
|
|
@@ -77335,14 +77264,14 @@ async function typeCheck(config2, docs) {
|
|
|
77335
77264
|
);
|
|
77336
77265
|
return;
|
|
77337
77266
|
}
|
|
77338
|
-
if (
|
|
77267
|
+
if (graphql29.isListType(rootType) || graphql29.isNonNullType(rootType) && graphql29.isListType(rootType.ofType)) {
|
|
77339
77268
|
needsParent = true;
|
|
77340
77269
|
break;
|
|
77341
77270
|
}
|
|
77342
|
-
if (
|
|
77271
|
+
if (graphql29.isNonNullType(rootType) && "ofType" in rootType) {
|
|
77343
77272
|
rootType = rootType.ofType;
|
|
77344
77273
|
}
|
|
77345
|
-
if (
|
|
77274
|
+
if (graphql29.isScalarType(rootType)) {
|
|
77346
77275
|
break;
|
|
77347
77276
|
}
|
|
77348
77277
|
rootType = rootType?.getFields()[parent3.name.value]?.type;
|
|
@@ -77418,9 +77347,9 @@ async function typeCheck(config2, docs) {
|
|
|
77418
77347
|
);
|
|
77419
77348
|
}
|
|
77420
77349
|
let targetTypes = [type];
|
|
77421
|
-
if (
|
|
77350
|
+
if (graphql29.isUnionType(type)) {
|
|
77422
77351
|
targetTypes = config2.schema.getPossibleTypes(type);
|
|
77423
|
-
} else if (
|
|
77352
|
+
} else if (graphql29.isInterfaceType(type)) {
|
|
77424
77353
|
try {
|
|
77425
77354
|
for (const key of config2.keyFieldsForType(type.name)) {
|
|
77426
77355
|
if (!type.getFields()[key]) {
|
|
@@ -77456,13 +77385,13 @@ async function typeCheck(config2, docs) {
|
|
|
77456
77385
|
if (errors.length > 0) {
|
|
77457
77386
|
throw errors;
|
|
77458
77387
|
}
|
|
77459
|
-
const rules = (filepath) => [...
|
|
77388
|
+
const rules = (filepath) => [...graphql29.specifiedRules].filter(
|
|
77460
77389
|
(rule) => ![
|
|
77461
|
-
|
|
77462
|
-
|
|
77463
|
-
|
|
77464
|
-
|
|
77465
|
-
|
|
77390
|
+
graphql29.NoUnusedFragmentsRule,
|
|
77391
|
+
graphql29.KnownFragmentNamesRule,
|
|
77392
|
+
graphql29.ExecutableDefinitionsRule,
|
|
77393
|
+
graphql29.KnownDirectivesRule,
|
|
77394
|
+
graphql29.KnownArgumentNamesRule
|
|
77466
77395
|
].includes(rule)
|
|
77467
77396
|
).concat(
|
|
77468
77397
|
validateLists({
|
|
@@ -77483,7 +77412,7 @@ async function typeCheck(config2, docs) {
|
|
|
77483
77412
|
validateLoadingDirective(config2)
|
|
77484
77413
|
);
|
|
77485
77414
|
for (const { filename, document: parsed, originalString } of docs) {
|
|
77486
|
-
for (const error of
|
|
77415
|
+
for (const error of graphql29.validate(config2.schema, parsed, rules(filename))) {
|
|
77487
77416
|
errors.push(
|
|
77488
77417
|
new HoudiniError({
|
|
77489
77418
|
filepath: filename,
|
|
@@ -77512,20 +77441,20 @@ function validateRequiredDirective(config2, filepath) {
|
|
|
77512
77441
|
if (!node.directives?.some(({ name }) => name.value === config2.requiredDirective))
|
|
77513
77442
|
return;
|
|
77514
77443
|
const parentType = parentTypeFromAncestors(config2.schema, filepath, ancestors);
|
|
77515
|
-
if (!
|
|
77444
|
+
if (!graphql29.isObjectType(parentType)) {
|
|
77516
77445
|
ctx.reportError(
|
|
77517
|
-
new
|
|
77446
|
+
new graphql29.GraphQLError(
|
|
77518
77447
|
`@${config2.requiredDirective} may only be used on objects, not arguments`
|
|
77519
77448
|
)
|
|
77520
77449
|
);
|
|
77521
77450
|
return;
|
|
77522
77451
|
}
|
|
77523
77452
|
const type = parentType.getFields()[node.name.value].type;
|
|
77524
|
-
const isServerNullable = !
|
|
77453
|
+
const isServerNullable = !graphql29.isNonNullType(type);
|
|
77525
77454
|
const isAlreadyClientNullable = isClientNullable(node, true);
|
|
77526
77455
|
if (!isServerNullable && !isAlreadyClientNullable) {
|
|
77527
77456
|
ctx.reportError(
|
|
77528
|
-
new
|
|
77457
|
+
new graphql29.GraphQLError(
|
|
77529
77458
|
`@${config2.requiredDirective} may only be used on nullable fields`
|
|
77530
77459
|
)
|
|
77531
77460
|
);
|
|
@@ -77547,7 +77476,7 @@ var validateLists = ({
|
|
|
77547
77476
|
if (!config2.isListFragment(node.name.value)) {
|
|
77548
77477
|
if (!fragments[node.name.value]) {
|
|
77549
77478
|
ctx.reportError(
|
|
77550
|
-
new
|
|
77479
|
+
new graphql29.GraphQLError(
|
|
77551
77480
|
"Encountered unknown fragment: " + node.name.value
|
|
77552
77481
|
)
|
|
77553
77482
|
);
|
|
@@ -77557,7 +77486,7 @@ var validateLists = ({
|
|
|
77557
77486
|
const listName = config2.listNameFromFragment(node.name.value);
|
|
77558
77487
|
if (!lists.includes(listName)) {
|
|
77559
77488
|
ctx.reportError(
|
|
77560
|
-
new
|
|
77489
|
+
new graphql29.GraphQLError(
|
|
77561
77490
|
"Encountered fragment referencing unknown list: " + listName
|
|
77562
77491
|
)
|
|
77563
77492
|
);
|
|
@@ -77582,7 +77511,7 @@ var validateLists = ({
|
|
|
77582
77511
|
);
|
|
77583
77512
|
if (parentArg) {
|
|
77584
77513
|
ctx.reportError(
|
|
77585
|
-
new
|
|
77514
|
+
new graphql29.GraphQLError(
|
|
77586
77515
|
`@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
77587
77516
|
)
|
|
77588
77517
|
);
|
|
@@ -77598,7 +77527,7 @@ var validateLists = ({
|
|
|
77598
77527
|
return;
|
|
77599
77528
|
}
|
|
77600
77529
|
ctx.reportError(
|
|
77601
|
-
new
|
|
77530
|
+
new graphql29.GraphQLError(
|
|
77602
77531
|
`For this list fragment, you need to add or @${config2.listParentDirective} or @${config2.listAllListsDirective} directive to specify the behavior`
|
|
77603
77532
|
)
|
|
77604
77533
|
);
|
|
@@ -77608,7 +77537,7 @@ var validateLists = ({
|
|
|
77608
77537
|
const directiveName = node.name.value;
|
|
77609
77538
|
if (directiveName === "connection") {
|
|
77610
77539
|
ctx.reportError(
|
|
77611
|
-
new
|
|
77540
|
+
new graphql29.GraphQLError(
|
|
77612
77541
|
"@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
77542
|
)
|
|
77614
77543
|
);
|
|
@@ -77617,7 +77546,7 @@ var validateLists = ({
|
|
|
77617
77546
|
if (!config2.isInternalDirective(node.name.value)) {
|
|
77618
77547
|
if (!config2.schema.getDirective(directiveName)) {
|
|
77619
77548
|
ctx.reportError(
|
|
77620
|
-
new
|
|
77549
|
+
new graphql29.GraphQLError(
|
|
77621
77550
|
"Encountered unknown directive: " + directiveName
|
|
77622
77551
|
)
|
|
77623
77552
|
);
|
|
@@ -77626,7 +77555,7 @@ var validateLists = ({
|
|
|
77626
77555
|
}
|
|
77627
77556
|
if (config2.isListOperationDirective(directiveName) && !listTypes.includes(config2.listNameFromDirective(directiveName))) {
|
|
77628
77557
|
ctx.reportError(
|
|
77629
|
-
new
|
|
77558
|
+
new graphql29.GraphQLError(
|
|
77630
77559
|
"Encountered directive referencing unknown list: " + directiveName
|
|
77631
77560
|
)
|
|
77632
77561
|
);
|
|
@@ -77637,7 +77566,7 @@ var validateLists = ({
|
|
|
77637
77566
|
};
|
|
77638
77567
|
function knownArguments(config2) {
|
|
77639
77568
|
return function(ctx) {
|
|
77640
|
-
const nativeValidator =
|
|
77569
|
+
const nativeValidator = graphql29.KnownArgumentNamesRule(ctx);
|
|
77641
77570
|
return {
|
|
77642
77571
|
...nativeValidator,
|
|
77643
77572
|
Directive(directiveNode) {
|
|
@@ -77672,7 +77601,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77672
77601
|
for (const arg of node.arguments || []) {
|
|
77673
77602
|
if (arg.value.kind !== "ObjectValue") {
|
|
77674
77603
|
ctx.reportError(
|
|
77675
|
-
new
|
|
77604
|
+
new graphql29.GraphQLError("values in @arguments must be an object")
|
|
77676
77605
|
);
|
|
77677
77606
|
return;
|
|
77678
77607
|
}
|
|
@@ -77682,13 +77611,13 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77682
77611
|
);
|
|
77683
77612
|
if (!typeArg) {
|
|
77684
77613
|
ctx.reportError(
|
|
77685
|
-
new
|
|
77614
|
+
new graphql29.GraphQLError("missing type field for @arguments directive")
|
|
77686
77615
|
);
|
|
77687
77616
|
return;
|
|
77688
77617
|
}
|
|
77689
|
-
if (typeArg.value.kind !==
|
|
77618
|
+
if (typeArg.value.kind !== graphql29.Kind.STRING) {
|
|
77690
77619
|
ctx.reportError(
|
|
77691
|
-
new
|
|
77620
|
+
new graphql29.GraphQLError("type field to @arguments must be a string")
|
|
77692
77621
|
);
|
|
77693
77622
|
return;
|
|
77694
77623
|
}
|
|
@@ -77701,7 +77630,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77701
77630
|
);
|
|
77702
77631
|
if (typeArg.value.value !== defaultValueType) {
|
|
77703
77632
|
ctx.reportError(
|
|
77704
|
-
new
|
|
77633
|
+
new graphql29.GraphQLError(
|
|
77705
77634
|
`Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
|
|
77706
77635
|
)
|
|
77707
77636
|
);
|
|
@@ -77719,7 +77648,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77719
77648
|
try {
|
|
77720
77649
|
args = fragmentArguments(config2, filepath, fragments[fragmentName]);
|
|
77721
77650
|
} catch (e2) {
|
|
77722
|
-
ctx.reportError(new
|
|
77651
|
+
ctx.reportError(new graphql29.GraphQLError(e2.message));
|
|
77723
77652
|
return;
|
|
77724
77653
|
}
|
|
77725
77654
|
fragmentArguments2[fragmentName] = args;
|
|
@@ -77742,7 +77671,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77742
77671
|
);
|
|
77743
77672
|
if (missing.length > 0) {
|
|
77744
77673
|
ctx.reportError(
|
|
77745
|
-
new
|
|
77674
|
+
new graphql29.GraphQLError(
|
|
77746
77675
|
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
77747
77676
|
)
|
|
77748
77677
|
);
|
|
@@ -77753,7 +77682,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77753
77682
|
);
|
|
77754
77683
|
if (unknown.length > 0) {
|
|
77755
77684
|
ctx.reportError(
|
|
77756
|
-
new
|
|
77685
|
+
new graphql29.GraphQLError(
|
|
77757
77686
|
"Encountered unknown arguments: " + JSON.stringify(unknown)
|
|
77758
77687
|
)
|
|
77759
77688
|
);
|
|
@@ -77765,7 +77694,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77765
77694
|
for (const [applied, target] of zipped) {
|
|
77766
77695
|
if (!valueIsType(config2, applied.value, target)) {
|
|
77767
77696
|
ctx.reportError(
|
|
77768
|
-
new
|
|
77697
|
+
new graphql29.GraphQLError(
|
|
77769
77698
|
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
77770
77699
|
)
|
|
77771
77700
|
);
|
|
@@ -77807,7 +77736,7 @@ function valueIsType(config2, value, targetType) {
|
|
|
77807
77736
|
}
|
|
77808
77737
|
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
77809
77738
|
const enumType = config2.schema.getType(targetType.name.value);
|
|
77810
|
-
if (!
|
|
77739
|
+
if (!graphql29.isEnumType(enumType)) {
|
|
77811
77740
|
return false;
|
|
77812
77741
|
}
|
|
77813
77742
|
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
@@ -77827,7 +77756,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77827
77756
|
}
|
|
77828
77757
|
if (alreadyPaginated) {
|
|
77829
77758
|
ctx.reportError(
|
|
77830
|
-
new
|
|
77759
|
+
new graphql29.GraphQLError(
|
|
77831
77760
|
`@${config2.paginateDirective} can only appear in a document once.`
|
|
77832
77761
|
)
|
|
77833
77762
|
);
|
|
@@ -77859,7 +77788,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77859
77788
|
const backwards = appliedArgs.has("last");
|
|
77860
77789
|
if (!forward && !backwards) {
|
|
77861
77790
|
ctx.reportError(
|
|
77862
|
-
new
|
|
77791
|
+
new graphql29.GraphQLError(
|
|
77863
77792
|
"A field with cursor-based pagination must have a first or last argument"
|
|
77864
77793
|
)
|
|
77865
77794
|
);
|
|
@@ -77873,7 +77802,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77873
77802
|
}
|
|
77874
77803
|
if (forward && backwards && paginateMode === "Infinite") {
|
|
77875
77804
|
ctx.reportError(
|
|
77876
|
-
new
|
|
77805
|
+
new graphql29.GraphQLError(
|
|
77877
77806
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
77878
77807
|
)
|
|
77879
77808
|
);
|
|
@@ -77887,7 +77816,7 @@ function paginateArgs(config2, filepath) {
|
|
|
77887
77816
|
);
|
|
77888
77817
|
if (!appliedLimitArg) {
|
|
77889
77818
|
ctx.reportError(
|
|
77890
|
-
new
|
|
77819
|
+
new graphql29.GraphQLError(
|
|
77891
77820
|
"A field with offset-based pagination must have a limit argument"
|
|
77892
77821
|
)
|
|
77893
77822
|
);
|
|
@@ -77903,20 +77832,20 @@ function noUnusedFragmentArguments(config2) {
|
|
|
77903
77832
|
const args = /* @__PURE__ */ new Set();
|
|
77904
77833
|
return {
|
|
77905
77834
|
enter(node) {
|
|
77906
|
-
if (node.kind ===
|
|
77835
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
77907
77836
|
const definitionArguments = node.directives?.filter((directive) => directive.name.value === config2.argumentsDirective).flatMap((directive) => directive.arguments);
|
|
77908
77837
|
for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
|
|
77909
77838
|
args.add(arg);
|
|
77910
77839
|
}
|
|
77911
|
-
} else if (node.kind ===
|
|
77840
|
+
} else if (node.kind === graphql29.Kind.VARIABLE) {
|
|
77912
77841
|
args.delete(node.name.value);
|
|
77913
77842
|
}
|
|
77914
77843
|
},
|
|
77915
77844
|
leave(node) {
|
|
77916
|
-
if (node.kind ===
|
|
77845
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
77917
77846
|
if (args.size > 0) {
|
|
77918
77847
|
ctx.reportError(
|
|
77919
|
-
new
|
|
77848
|
+
new graphql29.GraphQLError(
|
|
77920
77849
|
"Encountered unused fragment arguments: " + [...args].join(",")
|
|
77921
77850
|
)
|
|
77922
77851
|
);
|
|
@@ -77952,7 +77881,7 @@ function nodeDirectives(config2, directives) {
|
|
|
77952
77881
|
if (definition.kind === "OperationDefinition") {
|
|
77953
77882
|
if (definition.operation !== "query") {
|
|
77954
77883
|
ctx.reportError(
|
|
77955
|
-
new
|
|
77884
|
+
new graphql29.GraphQLError(
|
|
77956
77885
|
`@${node.name.value} must fall on a fragment or query document`
|
|
77957
77886
|
)
|
|
77958
77887
|
);
|
|
@@ -77964,7 +77893,7 @@ function nodeDirectives(config2, directives) {
|
|
|
77964
77893
|
}
|
|
77965
77894
|
if (!possibleNodes.includes(definitionType)) {
|
|
77966
77895
|
ctx.reportError(
|
|
77967
|
-
new
|
|
77896
|
+
new graphql29.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
77968
77897
|
);
|
|
77969
77898
|
}
|
|
77970
77899
|
}
|
|
@@ -77983,7 +77912,7 @@ function checkMutationOperation(config2) {
|
|
|
77983
77912
|
);
|
|
77984
77913
|
if (append && prepend) {
|
|
77985
77914
|
ctx.reportError(
|
|
77986
|
-
new
|
|
77915
|
+
new graphql29.GraphQLError(
|
|
77987
77916
|
`You can't apply both @${config2.listPrependDirective} and @${config2.listAppendDirective} at the same time`
|
|
77988
77917
|
)
|
|
77989
77918
|
);
|
|
@@ -77997,7 +77926,7 @@ function checkMutationOperation(config2) {
|
|
|
77997
77926
|
);
|
|
77998
77927
|
if (parentId && allLists) {
|
|
77999
77928
|
ctx.reportError(
|
|
78000
|
-
new
|
|
77929
|
+
new graphql29.GraphQLError(
|
|
78001
77930
|
`You can't apply both @${config2.listParentDirective} and @${config2.listAllListsDirective} at the same time`
|
|
78002
77931
|
)
|
|
78003
77932
|
);
|
|
@@ -78019,7 +77948,7 @@ function checkMaskDirectives(config2) {
|
|
|
78019
77948
|
);
|
|
78020
77949
|
if (maskEnableDirective && maskDisableDirective) {
|
|
78021
77950
|
ctx.reportError(
|
|
78022
|
-
new
|
|
77951
|
+
new graphql29.GraphQLError(
|
|
78023
77952
|
`You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
|
|
78024
77953
|
)
|
|
78025
77954
|
);
|
|
@@ -78061,7 +77990,7 @@ function validateLoadingDirective(config2) {
|
|
|
78061
77990
|
);
|
|
78062
77991
|
if (!parentLoading && !global2) {
|
|
78063
77992
|
ctx.reportError(
|
|
78064
|
-
new
|
|
77993
|
+
new graphql29.GraphQLError(
|
|
78065
77994
|
`@${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
77995
|
)
|
|
78067
77996
|
);
|
|
@@ -78083,7 +78012,7 @@ function validateLoadingDirective(config2) {
|
|
|
78083
78012
|
);
|
|
78084
78013
|
if (!parentLoading && !global2) {
|
|
78085
78014
|
ctx.reportError(
|
|
78086
|
-
new
|
|
78015
|
+
new graphql29.GraphQLError(
|
|
78087
78016
|
`@${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
78017
|
)
|
|
78089
78018
|
);
|
|
@@ -78098,7 +78027,7 @@ function getAndVerifyNodeInterface(config2) {
|
|
|
78098
78027
|
if (!nodeInterface) {
|
|
78099
78028
|
return null;
|
|
78100
78029
|
}
|
|
78101
|
-
if (!
|
|
78030
|
+
if (!graphql29.isInterfaceType(nodeInterface)) {
|
|
78102
78031
|
displayInvalidNodeFieldMessage(config2);
|
|
78103
78032
|
return null;
|
|
78104
78033
|
}
|
|
@@ -78193,11 +78122,11 @@ async function uniqueDocumentNames(config2, docs) {
|
|
|
78193
78122
|
}
|
|
78194
78123
|
|
|
78195
78124
|
// src/codegen/validators/noIDAlias.ts
|
|
78196
|
-
import * as
|
|
78125
|
+
import * as graphql30 from "graphql";
|
|
78197
78126
|
async function noIDAlias(config2, docs) {
|
|
78198
78127
|
const errors = [];
|
|
78199
78128
|
for (const { filename, document } of docs) {
|
|
78200
|
-
|
|
78129
|
+
graphql30.visit(document, {
|
|
78201
78130
|
Field(node, _, __, ___, ancestors) {
|
|
78202
78131
|
const fieldType = parentTypeFromAncestors(config2.schema, filename, ancestors).name;
|
|
78203
78132
|
if (config2.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
|
|
@@ -78236,11 +78165,11 @@ async function validatePlugins(config2, documents) {
|
|
|
78236
78165
|
}
|
|
78237
78166
|
|
|
78238
78167
|
// src/codegen/validators/componentFields.ts
|
|
78239
|
-
import * as
|
|
78168
|
+
import * as graphql31 from "graphql";
|
|
78240
78169
|
async function componentFields2(config2, docs) {
|
|
78241
78170
|
const errors = [];
|
|
78242
78171
|
for (const { filename: filepath, document } of docs) {
|
|
78243
|
-
|
|
78172
|
+
graphql31.visit(document, {
|
|
78244
78173
|
FragmentDefinition(node, _, __, ___, ancestors) {
|
|
78245
78174
|
const componentFieldDirective = node.directives?.find(
|
|
78246
78175
|
(dir) => dir.name.value === config2.componentFieldDirective
|
|
@@ -78288,7 +78217,7 @@ async function componentFields2(config2, docs) {
|
|
|
78288
78217
|
if (existingField && existingField.filepath !== filepath) {
|
|
78289
78218
|
conflict = true;
|
|
78290
78219
|
} else if (parentType && fieldValue) {
|
|
78291
|
-
const fieldDef =
|
|
78220
|
+
const fieldDef = graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
78292
78221
|
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
78293
78222
|
(dir) => dir.name.value === config2.componentFieldDirective
|
|
78294
78223
|
)) {
|
|
@@ -78301,7 +78230,7 @@ async function componentFields2(config2, docs) {
|
|
|
78301
78230
|
filepath
|
|
78302
78231
|
});
|
|
78303
78232
|
}
|
|
78304
|
-
if (parentType &&
|
|
78233
|
+
if (parentType && graphql31.isAbstractType(parentType)) {
|
|
78305
78234
|
errors.push({
|
|
78306
78235
|
message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
|
|
78307
78236
|
filepath
|
|
@@ -78522,12 +78451,12 @@ async function processJSFile(config2, contents) {
|
|
|
78522
78451
|
return documents;
|
|
78523
78452
|
}
|
|
78524
78453
|
async function processGraphQLDocument(config2, filepath, document) {
|
|
78525
|
-
const parsedDoc =
|
|
78454
|
+
const parsedDoc = graphql32.parse(document);
|
|
78526
78455
|
const operations = parsedDoc.definitions.filter(
|
|
78527
|
-
({ kind: kind2 }) => kind2 ===
|
|
78456
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.OPERATION_DEFINITION
|
|
78528
78457
|
);
|
|
78529
78458
|
const fragments = parsedDoc.definitions.filter(
|
|
78530
|
-
({ kind: kind2 }) => kind2 ===
|
|
78459
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.FRAGMENT_DEFINITION
|
|
78531
78460
|
);
|
|
78532
78461
|
if (operations.length > 1) {
|
|
78533
78462
|
throw new HoudiniError({
|