houdini 1.2.43 → 1.2.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +684 -786
- package/build/cmd-esm/index.js +534 -636
- package/build/codegen/generators/artifacts/inputs.d.ts +1 -1
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen/transforms/index.d.ts +1 -0
- package/build/codegen/transforms/runtimeScalars.d.ts +2 -0
- package/build/codegen-cjs/index.js +677 -782
- package/build/codegen-esm/index.js +527 -632
- package/build/lib/config.d.ts +1 -0
- 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 +711 -477
- package/build/lib-esm/index.js +705 -477
- 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/config.d.ts +12 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +17 -2
- package/build/runtime/router/session.d.ts +1 -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 +18 -11
- package/build/runtime-cjs/lib/config.d.ts +12 -2
- 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 +17 -2
- package/build/runtime-cjs/router/server.js +2 -3
- package/build/runtime-cjs/router/session.d.ts +1 -2
- package/build/runtime-cjs/router/session.js +25 -11
- 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 +15 -2
- package/build/runtime-esm/lib/config.d.ts +12 -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 +17 -2
- package/build/runtime-esm/router/server.js +2 -3
- package/build/runtime-esm/router/session.d.ts +1 -2
- package/build/runtime-esm/router/session.js +25 -11
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +706 -785
- package/build/test-esm/index.js +556 -635
- package/build/vite-cjs/index.js +793 -793
- package/build/vite-esm/index.js +643 -643
- 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/cmd-esm/index.js
CHANGED
|
@@ -30954,7 +30954,7 @@ var require_path_visitor = __commonJS({
|
|
|
30954
30954
|
}
|
|
30955
30955
|
return target;
|
|
30956
30956
|
}
|
|
30957
|
-
PathVisitor.visit = function
|
|
30957
|
+
PathVisitor.visit = function visit20(node, methods) {
|
|
30958
30958
|
return PathVisitor.fromMethodsObject(methods).visit(node);
|
|
30959
30959
|
};
|
|
30960
30960
|
var PVp = PathVisitor.prototype;
|
|
@@ -31145,7 +31145,7 @@ var require_path_visitor = __commonJS({
|
|
|
31145
31145
|
this.needToCallTraverse = false;
|
|
31146
31146
|
return visitChildren(path3, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
|
|
31147
31147
|
};
|
|
31148
|
-
sharedContextProtoMethods.visit = function
|
|
31148
|
+
sharedContextProtoMethods.visit = function visit20(path3, newVisitor) {
|
|
31149
31149
|
if (!(this instanceof this.Context)) {
|
|
31150
31150
|
throw new Error("");
|
|
31151
31151
|
}
|
|
@@ -32538,7 +32538,7 @@ var require_main = __commonJS({
|
|
|
32538
32538
|
var someField = _a.someField;
|
|
32539
32539
|
var Type = _a.Type;
|
|
32540
32540
|
var use = _a.use;
|
|
32541
|
-
var
|
|
32541
|
+
var visit20 = _a.visit;
|
|
32542
32542
|
exports.astNodesAreEquivalent = astNodesAreEquivalent;
|
|
32543
32543
|
exports.builders = builders;
|
|
32544
32544
|
exports.builtInTypes = builtInTypes;
|
|
@@ -32555,7 +32555,7 @@ var require_main = __commonJS({
|
|
|
32555
32555
|
exports.someField = someField;
|
|
32556
32556
|
exports.Type = Type;
|
|
32557
32557
|
exports.use = use;
|
|
32558
|
-
exports.visit =
|
|
32558
|
+
exports.visit = visit20;
|
|
32559
32559
|
Object.assign(namedTypes_1.namedTypes, n);
|
|
32560
32560
|
}
|
|
32561
32561
|
});
|
|
@@ -63311,47 +63311,6 @@ function deepMerge(...objects) {
|
|
|
63311
63311
|
return mergedObj;
|
|
63312
63312
|
}
|
|
63313
63313
|
|
|
63314
|
-
// src/runtime/lib/scalars.ts
|
|
63315
|
-
async function marshalSelection({
|
|
63316
|
-
selection,
|
|
63317
|
-
data
|
|
63318
|
-
}) {
|
|
63319
|
-
const config = getCurrentConfig();
|
|
63320
|
-
if (data === null || typeof data === "undefined") {
|
|
63321
|
-
return data;
|
|
63322
|
-
}
|
|
63323
|
-
if (Array.isArray(data)) {
|
|
63324
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
63325
|
-
}
|
|
63326
|
-
const targetSelection = getFieldsForType(selection, data["__typename"], false);
|
|
63327
|
-
return Object.fromEntries(
|
|
63328
|
-
await Promise.all(
|
|
63329
|
-
Object.entries(data).map(async ([fieldName, value]) => {
|
|
63330
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
63331
|
-
if (!type) {
|
|
63332
|
-
return [fieldName, value];
|
|
63333
|
-
}
|
|
63334
|
-
if (selection2) {
|
|
63335
|
-
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
63336
|
-
}
|
|
63337
|
-
if (config.scalars?.[type]) {
|
|
63338
|
-
const marshalFn = config.scalars[type].marshal;
|
|
63339
|
-
if (!marshalFn) {
|
|
63340
|
-
throw new Error(
|
|
63341
|
-
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
63342
|
-
);
|
|
63343
|
-
}
|
|
63344
|
-
if (Array.isArray(value)) {
|
|
63345
|
-
return [fieldName, value.map(marshalFn)];
|
|
63346
|
-
}
|
|
63347
|
-
return [fieldName, marshalFn(value)];
|
|
63348
|
-
}
|
|
63349
|
-
return [fieldName, value];
|
|
63350
|
-
})
|
|
63351
|
-
)
|
|
63352
|
-
);
|
|
63353
|
-
}
|
|
63354
|
-
|
|
63355
63314
|
// src/runtime/lib/types.ts
|
|
63356
63315
|
var CachePolicy = {
|
|
63357
63316
|
CacheOrNetwork: "CacheOrNetwork",
|
|
@@ -63379,11 +63338,6 @@ var RefetchUpdateMode = {
|
|
|
63379
63338
|
prepend: "prepend",
|
|
63380
63339
|
replace: "replace"
|
|
63381
63340
|
};
|
|
63382
|
-
var DataSource = {
|
|
63383
|
-
Cache: "cache",
|
|
63384
|
-
Network: "network",
|
|
63385
|
-
Ssr: "ssr"
|
|
63386
|
-
};
|
|
63387
63341
|
var fragmentKey = " $fragments";
|
|
63388
63342
|
var PendingValue = Symbol("houdini_loading");
|
|
63389
63343
|
|
|
@@ -67291,188 +67245,6 @@ var cache_default = new Cache();
|
|
|
67291
67245
|
// src/runtime/client/plugins/cache.ts
|
|
67292
67246
|
var serverSide = typeof globalThis.window === "undefined";
|
|
67293
67247
|
|
|
67294
|
-
// src/runtime/client/utils/documentPlugins.ts
|
|
67295
|
-
var documentPlugin = (kind, source) => {
|
|
67296
|
-
return () => {
|
|
67297
|
-
const sourceHandlers = source();
|
|
67298
|
-
const enterWrapper = (handler) => {
|
|
67299
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
67300
|
-
if (ctx.artifact.kind !== kind) {
|
|
67301
|
-
return handlers.next(ctx);
|
|
67302
|
-
}
|
|
67303
|
-
return handler(ctx, handlers);
|
|
67304
|
-
};
|
|
67305
|
-
};
|
|
67306
|
-
const exitWrapper = (handler) => {
|
|
67307
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
67308
|
-
if (ctx.artifact.kind !== kind) {
|
|
67309
|
-
return handlers.resolve(ctx);
|
|
67310
|
-
}
|
|
67311
|
-
return handler(ctx, handlers);
|
|
67312
|
-
};
|
|
67313
|
-
};
|
|
67314
|
-
return {
|
|
67315
|
-
start: enterWrapper(sourceHandlers.start),
|
|
67316
|
-
network: enterWrapper(sourceHandlers.network),
|
|
67317
|
-
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
67318
|
-
end: exitWrapper(sourceHandlers.end),
|
|
67319
|
-
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
67320
|
-
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
67321
|
-
};
|
|
67322
|
-
};
|
|
67323
|
-
};
|
|
67324
|
-
|
|
67325
|
-
// src/runtime/client/plugins/query.ts
|
|
67326
|
-
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
67327
|
-
let subscriptionSpec = null;
|
|
67328
|
-
let lastVariables = null;
|
|
67329
|
-
return {
|
|
67330
|
-
start(ctx, { next }) {
|
|
67331
|
-
ctx.variables = {
|
|
67332
|
-
...lastVariables,
|
|
67333
|
-
...ctx.variables
|
|
67334
|
-
};
|
|
67335
|
-
next(ctx);
|
|
67336
|
-
},
|
|
67337
|
-
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
67338
|
-
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
67339
|
-
if (subscriptionSpec) {
|
|
67340
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
67341
|
-
}
|
|
67342
|
-
lastVariables = { ...marshalVariables(ctx) };
|
|
67343
|
-
const variables = lastVariables;
|
|
67344
|
-
subscriptionSpec = {
|
|
67345
|
-
rootType: ctx.artifact.rootType,
|
|
67346
|
-
selection: ctx.artifact.selection,
|
|
67347
|
-
variables: () => variables,
|
|
67348
|
-
set: (newValue) => {
|
|
67349
|
-
resolve2(ctx, {
|
|
67350
|
-
data: newValue,
|
|
67351
|
-
errors: null,
|
|
67352
|
-
fetching: false,
|
|
67353
|
-
partial: false,
|
|
67354
|
-
stale: false,
|
|
67355
|
-
source: DataSource.Cache,
|
|
67356
|
-
variables: ctx.variables ?? {}
|
|
67357
|
-
});
|
|
67358
|
-
}
|
|
67359
|
-
};
|
|
67360
|
-
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
67361
|
-
}
|
|
67362
|
-
resolve2(ctx);
|
|
67363
|
-
},
|
|
67364
|
-
cleanup() {
|
|
67365
|
-
if (subscriptionSpec) {
|
|
67366
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
67367
|
-
lastVariables = null;
|
|
67368
|
-
}
|
|
67369
|
-
}
|
|
67370
|
-
};
|
|
67371
|
-
});
|
|
67372
|
-
|
|
67373
|
-
// src/runtime/client/plugins/fragment.ts
|
|
67374
|
-
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
67375
|
-
let subscriptionSpec = null;
|
|
67376
|
-
let lastReference = null;
|
|
67377
|
-
return {
|
|
67378
|
-
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
67379
|
-
if (!ctx.stuff.parentID) {
|
|
67380
|
-
return next(ctx);
|
|
67381
|
-
}
|
|
67382
|
-
const currentReference = {
|
|
67383
|
-
parent: ctx.stuff.parentID,
|
|
67384
|
-
variables: marshalVariables(ctx)
|
|
67385
|
-
};
|
|
67386
|
-
if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
67387
|
-
if (subscriptionSpec) {
|
|
67388
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
67389
|
-
}
|
|
67390
|
-
const variables = marshalVariables(ctx);
|
|
67391
|
-
subscriptionSpec = {
|
|
67392
|
-
rootType: ctx.artifact.rootType,
|
|
67393
|
-
selection: ctx.artifact.selection,
|
|
67394
|
-
variables: () => variables,
|
|
67395
|
-
parentID: ctx.stuff.parentID,
|
|
67396
|
-
set: (newValue) => {
|
|
67397
|
-
resolve2(ctx, {
|
|
67398
|
-
data: newValue,
|
|
67399
|
-
errors: null,
|
|
67400
|
-
fetching: false,
|
|
67401
|
-
partial: false,
|
|
67402
|
-
stale: false,
|
|
67403
|
-
source: DataSource.Cache,
|
|
67404
|
-
variables
|
|
67405
|
-
});
|
|
67406
|
-
}
|
|
67407
|
-
};
|
|
67408
|
-
cache_default.subscribe(subscriptionSpec, variables);
|
|
67409
|
-
lastReference = currentReference;
|
|
67410
|
-
}
|
|
67411
|
-
next(ctx);
|
|
67412
|
-
},
|
|
67413
|
-
cleanup() {
|
|
67414
|
-
if (subscriptionSpec) {
|
|
67415
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
67416
|
-
}
|
|
67417
|
-
}
|
|
67418
|
-
};
|
|
67419
|
-
});
|
|
67420
|
-
|
|
67421
|
-
// src/runtime/client/plugins/mutation.ts
|
|
67422
|
-
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
67423
|
-
return {
|
|
67424
|
-
async start(ctx, { next, marshalVariables }) {
|
|
67425
|
-
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
67426
|
-
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
67427
|
-
let toNotify = [];
|
|
67428
|
-
if (optimisticResponse) {
|
|
67429
|
-
toNotify = cache_default.write({
|
|
67430
|
-
selection: ctx.artifact.selection,
|
|
67431
|
-
data: await marshalSelection({
|
|
67432
|
-
selection: ctx.artifact.selection,
|
|
67433
|
-
data: optimisticResponse
|
|
67434
|
-
}),
|
|
67435
|
-
variables: marshalVariables(ctx),
|
|
67436
|
-
layer: layerOptimistic.id
|
|
67437
|
-
});
|
|
67438
|
-
}
|
|
67439
|
-
ctx.cacheParams = {
|
|
67440
|
-
...ctx.cacheParams,
|
|
67441
|
-
layer: layerOptimistic,
|
|
67442
|
-
notifySubscribers: toNotify,
|
|
67443
|
-
forceNotify: true
|
|
67444
|
-
};
|
|
67445
|
-
next(ctx);
|
|
67446
|
-
},
|
|
67447
|
-
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
67448
|
-
if (ctx.cacheParams?.layer) {
|
|
67449
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
67450
|
-
}
|
|
67451
|
-
resolve2(ctx);
|
|
67452
|
-
},
|
|
67453
|
-
end(ctx, { resolve: resolve2, value }) {
|
|
67454
|
-
const hasErrors = value.errors && value.errors.length > 0;
|
|
67455
|
-
if (hasErrors) {
|
|
67456
|
-
if (ctx.cacheParams?.layer) {
|
|
67457
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
67458
|
-
}
|
|
67459
|
-
}
|
|
67460
|
-
if (ctx.cacheParams?.layer) {
|
|
67461
|
-
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
67462
|
-
}
|
|
67463
|
-
resolve2(ctx);
|
|
67464
|
-
},
|
|
67465
|
-
catch(ctx, { error }) {
|
|
67466
|
-
if (ctx.cacheParams?.layer) {
|
|
67467
|
-
const { layer } = ctx.cacheParams;
|
|
67468
|
-
cache_default.clearLayer(layer.id);
|
|
67469
|
-
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
67470
|
-
}
|
|
67471
|
-
throw error;
|
|
67472
|
-
}
|
|
67473
|
-
};
|
|
67474
|
-
});
|
|
67475
|
-
|
|
67476
67248
|
// src/lib/types.ts
|
|
67477
67249
|
var LogLevel = {
|
|
67478
67250
|
Full: "full",
|
|
@@ -67909,6 +67681,9 @@ var Config = class {
|
|
|
67909
67681
|
get loadingDirective() {
|
|
67910
67682
|
return `loading`;
|
|
67911
67683
|
}
|
|
67684
|
+
get runtimeScalarDirective() {
|
|
67685
|
+
return "__houdini__runtimeScalar";
|
|
67686
|
+
}
|
|
67912
67687
|
get whenDirective() {
|
|
67913
67688
|
return "when";
|
|
67914
67689
|
}
|
|
@@ -67979,7 +67754,7 @@ var Config = class {
|
|
|
67979
67754
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
67980
67755
|
return list.concat(directive.name);
|
|
67981
67756
|
}, []) ?? [];
|
|
67982
|
-
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
67757
|
+
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name) || name === this.runtimeScalarDirective);
|
|
67983
67758
|
}
|
|
67984
67759
|
get componentFieldDirective() {
|
|
67985
67760
|
return "componentField";
|
|
@@ -68482,7 +68257,7 @@ function formatErrors(e3, afterError) {
|
|
|
68482
68257
|
afterError?.(e3);
|
|
68483
68258
|
}
|
|
68484
68259
|
}
|
|
68485
|
-
function unwrapType(config, type, wrappers = []) {
|
|
68260
|
+
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
68486
68261
|
if (type.kind === "NonNullType") {
|
|
68487
68262
|
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
68488
68263
|
}
|
|
@@ -68498,9 +68273,14 @@ function unwrapType(config, type, wrappers = []) {
|
|
|
68498
68273
|
if (type instanceof graphql3.GraphQLList) {
|
|
68499
68274
|
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
68500
68275
|
}
|
|
68276
|
+
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
68277
|
+
type = config.schema.getType(
|
|
68278
|
+
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
68279
|
+
);
|
|
68280
|
+
}
|
|
68501
68281
|
const namedType = config.schema.getType(type.name.value || type.name);
|
|
68502
68282
|
if (!namedType) {
|
|
68503
|
-
throw new Error("
|
|
68283
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
68504
68284
|
}
|
|
68505
68285
|
return { type: namedType, wrappers };
|
|
68506
68286
|
}
|
|
@@ -68692,6 +68472,152 @@ async function detectTools(cwd = process.cwd()) {
|
|
|
68692
68472
|
};
|
|
68693
68473
|
}
|
|
68694
68474
|
|
|
68475
|
+
// src/lib/typescript.ts
|
|
68476
|
+
var recast2 = __toESM(require_main2(), 1);
|
|
68477
|
+
import * as graphql4 from "graphql";
|
|
68478
|
+
var AST2 = recast2.types.builders;
|
|
68479
|
+
function unwrappedTsTypeReference(config, filepath, missingScalars, {
|
|
68480
|
+
type,
|
|
68481
|
+
wrappers
|
|
68482
|
+
}, body) {
|
|
68483
|
+
let result;
|
|
68484
|
+
if (graphql4.isScalarType(type)) {
|
|
68485
|
+
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
68486
|
+
} else if (graphql4.isEnumType(type)) {
|
|
68487
|
+
result = enumReference(config, body, type.name);
|
|
68488
|
+
} else {
|
|
68489
|
+
result = AST2.tsTypeReference(AST2.identifier(type.name));
|
|
68490
|
+
}
|
|
68491
|
+
for (const toWrap of wrappers) {
|
|
68492
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
68493
|
+
continue;
|
|
68494
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
68495
|
+
result = nullableField(result, true);
|
|
68496
|
+
} else if (toWrap === "List" /* List */) {
|
|
68497
|
+
result = AST2.tsArrayType(AST2.tsParenthesizedType(result));
|
|
68498
|
+
}
|
|
68499
|
+
}
|
|
68500
|
+
return result;
|
|
68501
|
+
}
|
|
68502
|
+
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
68503
|
+
const { type, wrappers } = unwrapType(config, definition.type);
|
|
68504
|
+
return unwrappedTsTypeReference(
|
|
68505
|
+
config,
|
|
68506
|
+
filepath,
|
|
68507
|
+
missingScalars,
|
|
68508
|
+
{ type, wrappers },
|
|
68509
|
+
body
|
|
68510
|
+
);
|
|
68511
|
+
}
|
|
68512
|
+
function enumReference(config, body, name) {
|
|
68513
|
+
ensureImports({
|
|
68514
|
+
config,
|
|
68515
|
+
body,
|
|
68516
|
+
import: ["ValueOf"],
|
|
68517
|
+
importKind: "type",
|
|
68518
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
68519
|
+
});
|
|
68520
|
+
return AST2.tsTypeReference(
|
|
68521
|
+
AST2.identifier("ValueOf"),
|
|
68522
|
+
AST2.tsTypeParameterInstantiation([AST2.tsTypeQuery(AST2.identifier(name))])
|
|
68523
|
+
);
|
|
68524
|
+
}
|
|
68525
|
+
function readonlyProperty(prop, enable = true) {
|
|
68526
|
+
if (enable) {
|
|
68527
|
+
prop.readonly = true;
|
|
68528
|
+
}
|
|
68529
|
+
return prop;
|
|
68530
|
+
}
|
|
68531
|
+
function nullableField(inner, input = false) {
|
|
68532
|
+
const members = [inner, AST2.tsNullKeyword()];
|
|
68533
|
+
if (input) {
|
|
68534
|
+
members.push(AST2.tsUndefinedKeyword());
|
|
68535
|
+
}
|
|
68536
|
+
return AST2.tsUnionType(members);
|
|
68537
|
+
}
|
|
68538
|
+
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
68539
|
+
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
68540
|
+
if (!field) {
|
|
68541
|
+
return AST2.tsNeverKeyword();
|
|
68542
|
+
}
|
|
68543
|
+
const component = config.componentFields[field.parent][field.field];
|
|
68544
|
+
const sourcePathRelative = path_exports.relative(
|
|
68545
|
+
path_exports.join(config.projectRoot, "src"),
|
|
68546
|
+
component.filepath
|
|
68547
|
+
);
|
|
68548
|
+
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
68549
|
+
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
68550
|
+
const localImport = ensureImports({
|
|
68551
|
+
config,
|
|
68552
|
+
body,
|
|
68553
|
+
import: "__component__" + component.fragment,
|
|
68554
|
+
sourceModule: path_exports.join(
|
|
68555
|
+
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
68556
|
+
"src",
|
|
68557
|
+
sourcePath
|
|
68558
|
+
)
|
|
68559
|
+
}) ?? "__component__" + component.fragment;
|
|
68560
|
+
const parameters = AST2.tsTypeReference(AST2.identifier("Parameters"));
|
|
68561
|
+
parameters.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
68562
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
68563
|
+
]);
|
|
68564
|
+
const indexed = AST2.tsIndexedAccessType(
|
|
68565
|
+
parameters,
|
|
68566
|
+
AST2.tsLiteralType(AST2.numericLiteral(0))
|
|
68567
|
+
);
|
|
68568
|
+
const omit = AST2.tsTypeReference(AST2.identifier("Omit"));
|
|
68569
|
+
omit.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
68570
|
+
indexed,
|
|
68571
|
+
AST2.tsLiteralType(AST2.stringLiteral(component.prop))
|
|
68572
|
+
]);
|
|
68573
|
+
const arg = AST2.identifier("props");
|
|
68574
|
+
arg.typeAnnotation = AST2.tsTypeAnnotation(omit);
|
|
68575
|
+
const returnType = AST2.tsTypeReference(AST2.identifier("ReturnType"));
|
|
68576
|
+
returnType.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
68577
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
68578
|
+
]);
|
|
68579
|
+
const fnType = AST2.tsFunctionType([arg]);
|
|
68580
|
+
fnType.typeAnnotation = AST2.tsTypeAnnotation(returnType);
|
|
68581
|
+
return fnType;
|
|
68582
|
+
}
|
|
68583
|
+
switch (target.name) {
|
|
68584
|
+
case "String": {
|
|
68585
|
+
return AST2.tsStringKeyword();
|
|
68586
|
+
}
|
|
68587
|
+
case "Int": {
|
|
68588
|
+
return AST2.tsNumberKeyword();
|
|
68589
|
+
}
|
|
68590
|
+
case "Float": {
|
|
68591
|
+
return AST2.tsNumberKeyword();
|
|
68592
|
+
}
|
|
68593
|
+
case "Boolean": {
|
|
68594
|
+
return AST2.tsBooleanKeyword();
|
|
68595
|
+
}
|
|
68596
|
+
case "ID": {
|
|
68597
|
+
return AST2.tsStringKeyword();
|
|
68598
|
+
}
|
|
68599
|
+
default: {
|
|
68600
|
+
if (graphql4.isNonNullType(target) && "ofType" in target) {
|
|
68601
|
+
return scalarPropertyValue(
|
|
68602
|
+
config,
|
|
68603
|
+
filepath,
|
|
68604
|
+
missingScalars,
|
|
68605
|
+
target.ofType,
|
|
68606
|
+
body,
|
|
68607
|
+
field
|
|
68608
|
+
);
|
|
68609
|
+
}
|
|
68610
|
+
if (config.scalars?.[target.name]) {
|
|
68611
|
+
return AST2.tsTypeReference(AST2.identifier(config.scalars?.[target.name].type));
|
|
68612
|
+
}
|
|
68613
|
+
if (target.name !== config.componentScalar) {
|
|
68614
|
+
missingScalars.add(target.name);
|
|
68615
|
+
}
|
|
68616
|
+
return AST2.tsAnyKeyword();
|
|
68617
|
+
}
|
|
68618
|
+
}
|
|
68619
|
+
}
|
|
68620
|
+
|
|
68695
68621
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
68696
68622
|
var WalkerBase = class {
|
|
68697
68623
|
constructor() {
|
|
@@ -68805,7 +68731,7 @@ async function asyncWalk(ast, { enter, leave }) {
|
|
|
68805
68731
|
}
|
|
68806
68732
|
|
|
68807
68733
|
// src/lib/walk.ts
|
|
68808
|
-
import * as
|
|
68734
|
+
import * as graphql5 from "graphql";
|
|
68809
68735
|
async function find_graphql(config, parsedScript, walker) {
|
|
68810
68736
|
await asyncWalk(parsedScript, {
|
|
68811
68737
|
async enter(node, parent2) {
|
|
@@ -68860,7 +68786,7 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
68860
68786
|
} else if (!documentString) {
|
|
68861
68787
|
return;
|
|
68862
68788
|
}
|
|
68863
|
-
const parsedTag =
|
|
68789
|
+
const parsedTag = graphql5.parse(documentString);
|
|
68864
68790
|
if (walker.where && !walker.where(parsedTag, { node, parent: parent2 })) {
|
|
68865
68791
|
return;
|
|
68866
68792
|
}
|
|
@@ -68992,7 +68918,7 @@ function extractAnonymousQuery(config, raw, expr, propName) {
|
|
|
68992
68918
|
};
|
|
68993
68919
|
return defs.concat([
|
|
68994
68920
|
{
|
|
68995
|
-
raw:
|
|
68921
|
+
raw: graphql5.print(parsed),
|
|
68996
68922
|
parsed
|
|
68997
68923
|
}
|
|
68998
68924
|
]);
|
|
@@ -69007,7 +68933,7 @@ function extractAnonymousQuery(config, raw, expr, propName) {
|
|
|
69007
68933
|
|
|
69008
68934
|
// src/lib/router/manifest.ts
|
|
69009
68935
|
var t2 = __toESM(require_lib6(), 1);
|
|
69010
|
-
import * as
|
|
68936
|
+
import * as graphql6 from "graphql";
|
|
69011
68937
|
|
|
69012
68938
|
// src/lib/router/server.ts
|
|
69013
68939
|
import path2 from "node:path";
|
|
@@ -69048,8 +68974,8 @@ async function loadLocalSchema(config) {
|
|
|
69048
68974
|
import * as graphql32 from "graphql";
|
|
69049
68975
|
|
|
69050
68976
|
// src/codegen/generators/artifacts/index.ts
|
|
69051
|
-
var
|
|
69052
|
-
import * as
|
|
68977
|
+
var recast5 = __toESM(require_main2(), 1);
|
|
68978
|
+
import * as graphql17 from "graphql";
|
|
69053
68979
|
|
|
69054
68980
|
// src/codegen/utils/commonjs.ts
|
|
69055
68981
|
var cjsIndexFilePreamble = `"use strict";
|
|
@@ -69291,19 +69217,19 @@ var FieldCollection = class {
|
|
|
69291
69217
|
};
|
|
69292
69218
|
|
|
69293
69219
|
// src/codegen/utils/moduleExport.ts
|
|
69294
|
-
var
|
|
69295
|
-
var
|
|
69220
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
69221
|
+
var AST3 = recast3.types.builders;
|
|
69296
69222
|
function moduleExport(config, key, value) {
|
|
69297
69223
|
if (config.module === "commonjs") {
|
|
69298
|
-
let target =
|
|
69224
|
+
let target = AST3.memberExpression(AST3.identifier("module"), AST3.identifier("exports"));
|
|
69299
69225
|
if (key !== "default") {
|
|
69300
|
-
target =
|
|
69226
|
+
target = AST3.memberExpression(target, AST3.identifier(key));
|
|
69301
69227
|
}
|
|
69302
|
-
return
|
|
69228
|
+
return AST3.expressionStatement(AST3.assignmentExpression("=", target, value));
|
|
69303
69229
|
}
|
|
69304
|
-
return key === "default" ?
|
|
69305
|
-
|
|
69306
|
-
|
|
69230
|
+
return key === "default" ? AST3.exportDefaultDeclaration(value) : AST3.exportNamedDeclaration(
|
|
69231
|
+
AST3.variableDeclaration("const", [
|
|
69232
|
+
AST3.variableDeclarator(AST3.identifier(key), value)
|
|
69307
69233
|
])
|
|
69308
69234
|
);
|
|
69309
69235
|
}
|
|
@@ -69560,7 +69486,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
69560
69486
|
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));
|
|
69561
69487
|
|
|
69562
69488
|
// src/codegen/transforms/fragmentVariables.ts
|
|
69563
|
-
import * as
|
|
69489
|
+
import * as graphql8 from "graphql";
|
|
69564
69490
|
|
|
69565
69491
|
// src/codegen/utils/stripLoc.ts
|
|
69566
69492
|
function stripLoc(value) {
|
|
@@ -69581,7 +69507,7 @@ function stripLoc(value) {
|
|
|
69581
69507
|
}
|
|
69582
69508
|
|
|
69583
69509
|
// src/codegen/transforms/collectDefinitions.ts
|
|
69584
|
-
import * as
|
|
69510
|
+
import * as graphql7 from "graphql";
|
|
69585
69511
|
import { Kind as GraphqlKinds } from "graphql";
|
|
69586
69512
|
async function includeFragmentDefinitions(config, documents) {
|
|
69587
69513
|
const fragments = collectDefinitions(config, documents);
|
|
@@ -69631,10 +69557,10 @@ function collectDefinitions(config, docs) {
|
|
|
69631
69557
|
}
|
|
69632
69558
|
function findRequiredFragments(config, definition) {
|
|
69633
69559
|
const referencedFragments = [];
|
|
69634
|
-
const typeInfo = new
|
|
69635
|
-
definition.selectionSet =
|
|
69560
|
+
const typeInfo = new graphql7.TypeInfo(config.schema);
|
|
69561
|
+
definition.selectionSet = graphql7.visit(
|
|
69636
69562
|
definition,
|
|
69637
|
-
|
|
69563
|
+
graphql7.visitWithTypeInfo(typeInfo, {
|
|
69638
69564
|
FragmentSpread(node) {
|
|
69639
69565
|
referencedFragments.push(node.name.value);
|
|
69640
69566
|
}
|
|
@@ -69668,7 +69594,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
69668
69594
|
}
|
|
69669
69595
|
|
|
69670
69596
|
// src/codegen/transforms/fragmentVariables.ts
|
|
69671
|
-
var GraphqlKinds2 =
|
|
69597
|
+
var GraphqlKinds2 = graphql8.Kind;
|
|
69672
69598
|
async function fragmentVariables(config, documents) {
|
|
69673
69599
|
const fragments = collectDefinitions(config, documents);
|
|
69674
69600
|
const generatedFragments = {};
|
|
@@ -69691,7 +69617,7 @@ async function fragmentVariables(config, documents) {
|
|
|
69691
69617
|
});
|
|
69692
69618
|
}
|
|
69693
69619
|
const doc = {
|
|
69694
|
-
kind:
|
|
69620
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
69695
69621
|
definitions: Object.values(generatedFragments)
|
|
69696
69622
|
};
|
|
69697
69623
|
documents.push({
|
|
@@ -69762,7 +69688,7 @@ function inlineFragmentArgs({
|
|
|
69762
69688
|
return null;
|
|
69763
69689
|
};
|
|
69764
69690
|
const result = esm_default(
|
|
69765
|
-
|
|
69691
|
+
graphql8.visit(document, {
|
|
69766
69692
|
FragmentSpread(node) {
|
|
69767
69693
|
if (!fragmentDefinitions[node.name.value]) {
|
|
69768
69694
|
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
@@ -69848,7 +69774,7 @@ function inlineFragmentArgs({
|
|
|
69848
69774
|
);
|
|
69849
69775
|
if (newName) {
|
|
69850
69776
|
result.name = {
|
|
69851
|
-
kind:
|
|
69777
|
+
kind: graphql8.Kind.NAME,
|
|
69852
69778
|
value: newName
|
|
69853
69779
|
};
|
|
69854
69780
|
}
|
|
@@ -70015,8 +69941,8 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
70015
69941
|
}
|
|
70016
69942
|
|
|
70017
69943
|
// src/codegen/generators/artifacts/inputs.ts
|
|
70018
|
-
import * as
|
|
70019
|
-
function inputObject(config, inputs) {
|
|
69944
|
+
import * as graphql9 from "graphql";
|
|
69945
|
+
function inputObject(config, inputs, runtimeScalars) {
|
|
70020
69946
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
70021
69947
|
const inputObj = {
|
|
70022
69948
|
fields: inputs.reduce((fields, input) => {
|
|
@@ -70032,7 +69958,8 @@ function inputObject(config, inputs) {
|
|
|
70032
69958
|
...fields,
|
|
70033
69959
|
[input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
|
|
70034
69960
|
};
|
|
70035
|
-
}, {})
|
|
69961
|
+
}, {}),
|
|
69962
|
+
runtimeScalars
|
|
70036
69963
|
};
|
|
70037
69964
|
for (const input of inputs) {
|
|
70038
69965
|
walkInputs(config, visitedTypes, inputObj, input.type);
|
|
@@ -70044,10 +69971,10 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
70044
69971
|
if (visitedTypes.has(type.name)) {
|
|
70045
69972
|
return;
|
|
70046
69973
|
}
|
|
70047
|
-
if (
|
|
69974
|
+
if (graphql9.isEnumType(type) || graphql9.isScalarType(type)) {
|
|
70048
69975
|
return;
|
|
70049
69976
|
}
|
|
70050
|
-
if (
|
|
69977
|
+
if (graphql9.isUnionType(type)) {
|
|
70051
69978
|
return;
|
|
70052
69979
|
}
|
|
70053
69980
|
visitedTypes.add(type.name);
|
|
@@ -70065,50 +69992,50 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
70065
69992
|
}
|
|
70066
69993
|
|
|
70067
69994
|
// src/codegen/generators/artifacts/operations.ts
|
|
70068
|
-
import * as
|
|
69995
|
+
import * as graphql11 from "graphql";
|
|
70069
69996
|
|
|
70070
69997
|
// src/codegen/generators/artifacts/utils.ts
|
|
70071
|
-
var
|
|
70072
|
-
import * as
|
|
70073
|
-
var
|
|
69998
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
69999
|
+
import * as graphql10 from "graphql";
|
|
70000
|
+
var AST4 = recast4.types.builders;
|
|
70074
70001
|
function serializeValue(value) {
|
|
70075
70002
|
if (Array.isArray(value)) {
|
|
70076
|
-
return
|
|
70003
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
70077
70004
|
}
|
|
70078
70005
|
if (typeof value === "object" && value !== null) {
|
|
70079
|
-
return
|
|
70006
|
+
return AST4.objectExpression(
|
|
70080
70007
|
Object.entries(value).filter(([key, value2]) => typeof value2 !== "undefined").map(([key, val]) => {
|
|
70081
|
-
return
|
|
70008
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
70082
70009
|
})
|
|
70083
70010
|
);
|
|
70084
70011
|
}
|
|
70085
70012
|
if (typeof value === "string") {
|
|
70086
70013
|
if (value.indexOf("\n") !== -1) {
|
|
70087
|
-
return
|
|
70088
|
-
[
|
|
70014
|
+
return AST4.templateLiteral(
|
|
70015
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
70089
70016
|
[]
|
|
70090
70017
|
);
|
|
70091
70018
|
}
|
|
70092
|
-
return
|
|
70019
|
+
return AST4.stringLiteral(value);
|
|
70093
70020
|
}
|
|
70094
|
-
return
|
|
70021
|
+
return AST4.literal(value);
|
|
70095
70022
|
}
|
|
70096
70023
|
function convertValue(config, val) {
|
|
70097
70024
|
let value;
|
|
70098
70025
|
let kind;
|
|
70099
|
-
if (val.kind ===
|
|
70026
|
+
if (val.kind === graphql10.Kind.INT) {
|
|
70100
70027
|
value = parseInt(val.value, 10);
|
|
70101
70028
|
kind = "Int";
|
|
70102
|
-
} else if (val.kind ===
|
|
70029
|
+
} else if (val.kind === graphql10.Kind.FLOAT) {
|
|
70103
70030
|
value = parseFloat(val.value);
|
|
70104
70031
|
kind = "Float";
|
|
70105
|
-
} else if (val.kind ===
|
|
70032
|
+
} else if (val.kind === graphql10.Kind.BOOLEAN) {
|
|
70106
70033
|
value = val.value;
|
|
70107
70034
|
kind = "Boolean";
|
|
70108
|
-
} else if (val.kind ===
|
|
70035
|
+
} else if (val.kind === graphql10.Kind.VARIABLE) {
|
|
70109
70036
|
value = val.name.value;
|
|
70110
70037
|
kind = "Variable";
|
|
70111
|
-
} else if (val.kind ===
|
|
70038
|
+
} else if (val.kind === graphql10.Kind.STRING) {
|
|
70112
70039
|
value = val.value;
|
|
70113
70040
|
kind = "String";
|
|
70114
70041
|
}
|
|
@@ -70121,7 +70048,7 @@ function operationsByPath(config, filepath, definition, filterTypes) {
|
|
|
70121
70048
|
return {};
|
|
70122
70049
|
}
|
|
70123
70050
|
const pathOperations = {};
|
|
70124
|
-
|
|
70051
|
+
graphql11.visit(definition, {
|
|
70125
70052
|
FragmentSpread(node, _3, __, ___, ancestors) {
|
|
70126
70053
|
if (!config.isListFragment(node.name.value)) {
|
|
70127
70054
|
return;
|
|
@@ -70280,19 +70207,19 @@ function ancestorKey(ancestors) {
|
|
|
70280
70207
|
}
|
|
70281
70208
|
|
|
70282
70209
|
// src/codegen/generators/artifacts/selection.ts
|
|
70283
|
-
import * as
|
|
70210
|
+
import * as graphql16 from "graphql";
|
|
70284
70211
|
|
|
70285
70212
|
// src/codegen/transforms/list.ts
|
|
70286
|
-
import * as
|
|
70213
|
+
import * as graphql14 from "graphql";
|
|
70287
70214
|
|
|
70288
70215
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
70289
|
-
import * as
|
|
70216
|
+
import * as graphql12 from "graphql";
|
|
70290
70217
|
var objectIdentificationSelection = (config, type) => {
|
|
70291
70218
|
return config.keyFieldsForType(type.name).map((key) => {
|
|
70292
70219
|
return {
|
|
70293
|
-
kind:
|
|
70220
|
+
kind: graphql12.Kind.FIELD,
|
|
70294
70221
|
name: {
|
|
70295
|
-
kind:
|
|
70222
|
+
kind: graphql12.Kind.NAME,
|
|
70296
70223
|
value: key
|
|
70297
70224
|
}
|
|
70298
70225
|
};
|
|
@@ -70300,7 +70227,7 @@ var objectIdentificationSelection = (config, type) => {
|
|
|
70300
70227
|
};
|
|
70301
70228
|
|
|
70302
70229
|
// src/codegen/transforms/paginate.ts
|
|
70303
|
-
import * as
|
|
70230
|
+
import * as graphql13 from "graphql";
|
|
70304
70231
|
async function paginate(config, documents) {
|
|
70305
70232
|
const newDocs = [];
|
|
70306
70233
|
for (const doc of documents) {
|
|
@@ -70333,7 +70260,7 @@ async function paginate(config, documents) {
|
|
|
70333
70260
|
};
|
|
70334
70261
|
let cursorType = "String";
|
|
70335
70262
|
let paginationPath = [];
|
|
70336
|
-
doc.document =
|
|
70263
|
+
doc.document = graphql13.visit(doc.document, {
|
|
70337
70264
|
Field(node, _3, __, ___, ancestors) {
|
|
70338
70265
|
const paginateDirective = node.directives?.find(
|
|
70339
70266
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -70359,7 +70286,7 @@ async function paginate(config, documents) {
|
|
|
70359
70286
|
flags.offset.enabled = offsetPagination;
|
|
70360
70287
|
flags.limit.enabled = offsetPagination;
|
|
70361
70288
|
paginationPath = ancestors.filter(
|
|
70362
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
70289
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql13.Kind.FIELD
|
|
70363
70290
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
70364
70291
|
return {
|
|
70365
70292
|
...node,
|
|
@@ -70378,7 +70305,7 @@ async function paginate(config, documents) {
|
|
|
70378
70305
|
let fragment2 = "";
|
|
70379
70306
|
let paginateMode = config.defaultPaginateMode;
|
|
70380
70307
|
const requiredArgs = [];
|
|
70381
|
-
doc.document =
|
|
70308
|
+
doc.document = graphql13.visit(doc.document, {
|
|
70382
70309
|
OperationDefinition(node) {
|
|
70383
70310
|
if (node.operation !== "query") {
|
|
70384
70311
|
throw new HoudiniError({
|
|
@@ -70437,9 +70364,9 @@ async function paginate(config, documents) {
|
|
|
70437
70364
|
directives: [
|
|
70438
70365
|
...node.directives || [],
|
|
70439
70366
|
{
|
|
70440
|
-
kind:
|
|
70367
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
70441
70368
|
name: {
|
|
70442
|
-
kind:
|
|
70369
|
+
kind: graphql13.Kind.NAME,
|
|
70443
70370
|
value: config.argumentsDirective
|
|
70444
70371
|
}
|
|
70445
70372
|
}
|
|
@@ -70509,22 +70436,22 @@ async function paginate(config, documents) {
|
|
|
70509
70436
|
const paginationArgs = Object.entries(flags).filter(([_3, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
70510
70437
|
const fragmentSpreadSelection = [
|
|
70511
70438
|
{
|
|
70512
|
-
kind:
|
|
70439
|
+
kind: graphql13.Kind.FRAGMENT_SPREAD,
|
|
70513
70440
|
name: {
|
|
70514
|
-
kind:
|
|
70441
|
+
kind: graphql13.Kind.NAME,
|
|
70515
70442
|
value: fragmentName
|
|
70516
70443
|
},
|
|
70517
70444
|
directives: [
|
|
70518
70445
|
{
|
|
70519
|
-
kind:
|
|
70446
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
70520
70447
|
name: {
|
|
70521
|
-
kind:
|
|
70448
|
+
kind: graphql13.Kind.NAME,
|
|
70522
70449
|
value: config.withDirective
|
|
70523
70450
|
},
|
|
70524
70451
|
["arguments"]: requiredArgs.map((arg) => variableAsArgument(arg.name)).concat(paginationArgs.map(({ name }) => variableAsArgument(name)))
|
|
70525
70452
|
},
|
|
70526
70453
|
{
|
|
70527
|
-
kind:
|
|
70454
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
70528
70455
|
name: {
|
|
70529
70456
|
kind: "Name",
|
|
70530
70457
|
value: config.maskDisableDirective
|
|
@@ -70551,23 +70478,23 @@ async function paginate(config, documents) {
|
|
|
70551
70478
|
});
|
|
70552
70479
|
const typeConfig = config.typeConfig?.[fragment2];
|
|
70553
70480
|
const queryDoc = {
|
|
70554
|
-
kind:
|
|
70481
|
+
kind: graphql13.Kind.DOCUMENT,
|
|
70555
70482
|
definitions: [
|
|
70556
70483
|
{
|
|
70557
|
-
kind:
|
|
70484
|
+
kind: graphql13.Kind.OPERATION_DEFINITION,
|
|
70558
70485
|
name: {
|
|
70559
|
-
kind:
|
|
70486
|
+
kind: graphql13.Kind.NAME,
|
|
70560
70487
|
value: refetchQueryName
|
|
70561
70488
|
},
|
|
70562
70489
|
operation: "query",
|
|
70563
70490
|
variableDefinitions: requiredArgs.map(
|
|
70564
70491
|
(arg) => ({
|
|
70565
|
-
kind:
|
|
70492
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
70566
70493
|
type: arg.type,
|
|
70567
70494
|
variable: {
|
|
70568
|
-
kind:
|
|
70495
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70569
70496
|
name: {
|
|
70570
|
-
kind:
|
|
70497
|
+
kind: graphql13.Kind.NAME,
|
|
70571
70498
|
value: arg.name
|
|
70572
70499
|
}
|
|
70573
70500
|
}
|
|
@@ -70575,18 +70502,18 @@ async function paginate(config, documents) {
|
|
|
70575
70502
|
).concat(
|
|
70576
70503
|
paginationArgs.map(
|
|
70577
70504
|
(arg) => ({
|
|
70578
|
-
kind:
|
|
70505
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
70579
70506
|
type: {
|
|
70580
|
-
kind:
|
|
70507
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
70581
70508
|
name: {
|
|
70582
|
-
kind:
|
|
70509
|
+
kind: graphql13.Kind.NAME,
|
|
70583
70510
|
value: arg.type
|
|
70584
70511
|
}
|
|
70585
70512
|
},
|
|
70586
70513
|
variable: {
|
|
70587
|
-
kind:
|
|
70514
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70588
70515
|
name: {
|
|
70589
|
-
kind:
|
|
70516
|
+
kind: graphql13.Kind.NAME,
|
|
70590
70517
|
value: arg.name
|
|
70591
70518
|
}
|
|
70592
70519
|
},
|
|
@@ -70598,12 +70525,12 @@ async function paginate(config, documents) {
|
|
|
70598
70525
|
).concat(
|
|
70599
70526
|
!nodeQuery ? [] : keys2.map(
|
|
70600
70527
|
(key) => ({
|
|
70601
|
-
kind:
|
|
70528
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
70602
70529
|
type: key.type,
|
|
70603
70530
|
variable: {
|
|
70604
|
-
kind:
|
|
70531
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70605
70532
|
name: {
|
|
70606
|
-
kind:
|
|
70533
|
+
kind: graphql13.Kind.NAME,
|
|
70607
70534
|
value: key.name
|
|
70608
70535
|
}
|
|
70609
70536
|
}
|
|
@@ -70612,42 +70539,42 @@ async function paginate(config, documents) {
|
|
|
70612
70539
|
)
|
|
70613
70540
|
),
|
|
70614
70541
|
selectionSet: {
|
|
70615
|
-
kind:
|
|
70542
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
70616
70543
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
70617
70544
|
{
|
|
70618
|
-
kind:
|
|
70545
|
+
kind: graphql13.Kind.FIELD,
|
|
70619
70546
|
name: {
|
|
70620
|
-
kind:
|
|
70547
|
+
kind: graphql13.Kind.NAME,
|
|
70621
70548
|
value: typeConfig?.resolve?.queryField || "node"
|
|
70622
70549
|
},
|
|
70623
70550
|
["arguments"]: keys2.map((key) => ({
|
|
70624
|
-
kind:
|
|
70551
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
70625
70552
|
name: {
|
|
70626
|
-
kind:
|
|
70553
|
+
kind: graphql13.Kind.NAME,
|
|
70627
70554
|
value: key.name
|
|
70628
70555
|
},
|
|
70629
70556
|
value: {
|
|
70630
|
-
kind:
|
|
70557
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70631
70558
|
name: {
|
|
70632
|
-
kind:
|
|
70559
|
+
kind: graphql13.Kind.NAME,
|
|
70633
70560
|
value: key.name
|
|
70634
70561
|
}
|
|
70635
70562
|
}
|
|
70636
70563
|
})),
|
|
70637
70564
|
selectionSet: {
|
|
70638
|
-
kind:
|
|
70565
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
70639
70566
|
selections: [
|
|
70640
70567
|
{
|
|
70641
|
-
kind:
|
|
70568
|
+
kind: graphql13.Kind.FIELD,
|
|
70642
70569
|
name: {
|
|
70643
|
-
kind:
|
|
70570
|
+
kind: graphql13.Kind.NAME,
|
|
70644
70571
|
value: "__typename"
|
|
70645
70572
|
}
|
|
70646
70573
|
},
|
|
70647
70574
|
...(typeConfig?.keys || [config.defaultKeys[0]]).map((key) => ({
|
|
70648
|
-
kind:
|
|
70575
|
+
kind: graphql13.Kind.FIELD,
|
|
70649
70576
|
name: {
|
|
70650
|
-
kind:
|
|
70577
|
+
kind: graphql13.Kind.NAME,
|
|
70651
70578
|
value: key
|
|
70652
70579
|
}
|
|
70653
70580
|
})),
|
|
@@ -70704,15 +70631,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
70704
70631
|
}
|
|
70705
70632
|
function variableAsArgument(name, variable) {
|
|
70706
70633
|
return {
|
|
70707
|
-
kind:
|
|
70634
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
70708
70635
|
name: {
|
|
70709
|
-
kind:
|
|
70636
|
+
kind: graphql13.Kind.NAME,
|
|
70710
70637
|
value: name
|
|
70711
70638
|
},
|
|
70712
70639
|
value: {
|
|
70713
|
-
kind:
|
|
70640
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70714
70641
|
name: {
|
|
70715
|
-
kind:
|
|
70642
|
+
kind: graphql13.Kind.NAME,
|
|
70716
70643
|
value: variable ?? name
|
|
70717
70644
|
}
|
|
70718
70645
|
}
|
|
@@ -70720,18 +70647,18 @@ function variableAsArgument(name, variable) {
|
|
|
70720
70647
|
}
|
|
70721
70648
|
function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
70722
70649
|
return {
|
|
70723
|
-
kind:
|
|
70650
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
70724
70651
|
type: {
|
|
70725
|
-
kind:
|
|
70652
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
70726
70653
|
name: {
|
|
70727
|
-
kind:
|
|
70654
|
+
kind: graphql13.Kind.NAME,
|
|
70728
70655
|
value: type
|
|
70729
70656
|
}
|
|
70730
70657
|
},
|
|
70731
70658
|
variable: {
|
|
70732
|
-
kind:
|
|
70659
|
+
kind: graphql13.Kind.VARIABLE,
|
|
70733
70660
|
name: {
|
|
70734
|
-
kind:
|
|
70661
|
+
kind: graphql13.Kind.NAME,
|
|
70735
70662
|
value: variableName ?? name
|
|
70736
70663
|
}
|
|
70737
70664
|
},
|
|
@@ -70743,9 +70670,9 @@ function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
|
70743
70670
|
}
|
|
70744
70671
|
function argumentNode(name, value) {
|
|
70745
70672
|
return {
|
|
70746
|
-
kind:
|
|
70673
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
70747
70674
|
name: {
|
|
70748
|
-
kind:
|
|
70675
|
+
kind: graphql13.Kind.NAME,
|
|
70749
70676
|
value: name
|
|
70750
70677
|
},
|
|
70751
70678
|
value: objectNode(value)
|
|
@@ -70753,16 +70680,16 @@ function argumentNode(name, value) {
|
|
|
70753
70680
|
}
|
|
70754
70681
|
function objectNode([type, defaultValue]) {
|
|
70755
70682
|
const node = {
|
|
70756
|
-
kind:
|
|
70683
|
+
kind: graphql13.Kind.OBJECT,
|
|
70757
70684
|
fields: [
|
|
70758
70685
|
{
|
|
70759
|
-
kind:
|
|
70686
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
70760
70687
|
name: {
|
|
70761
|
-
kind:
|
|
70688
|
+
kind: graphql13.Kind.NAME,
|
|
70762
70689
|
value: "type"
|
|
70763
70690
|
},
|
|
70764
70691
|
value: {
|
|
70765
|
-
kind:
|
|
70692
|
+
kind: graphql13.Kind.STRING,
|
|
70766
70693
|
value: type
|
|
70767
70694
|
}
|
|
70768
70695
|
}
|
|
@@ -70770,8 +70697,8 @@ function objectNode([type, defaultValue]) {
|
|
|
70770
70697
|
};
|
|
70771
70698
|
if (defaultValue) {
|
|
70772
70699
|
node.fields.push({
|
|
70773
|
-
kind:
|
|
70774
|
-
name: { kind:
|
|
70700
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
70701
|
+
name: { kind: graphql13.Kind.NAME, value: "default" },
|
|
70775
70702
|
value: {
|
|
70776
70703
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
70777
70704
|
value: defaultValue.toString()
|
|
@@ -70782,34 +70709,34 @@ function objectNode([type, defaultValue]) {
|
|
|
70782
70709
|
}
|
|
70783
70710
|
var pageInfoSelection = [
|
|
70784
70711
|
{
|
|
70785
|
-
kind:
|
|
70712
|
+
kind: graphql13.Kind.FIELD,
|
|
70786
70713
|
name: {
|
|
70787
|
-
kind:
|
|
70714
|
+
kind: graphql13.Kind.NAME,
|
|
70788
70715
|
value: "edges"
|
|
70789
70716
|
},
|
|
70790
70717
|
selectionSet: {
|
|
70791
|
-
kind:
|
|
70718
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
70792
70719
|
selections: [
|
|
70793
70720
|
{
|
|
70794
|
-
kind:
|
|
70721
|
+
kind: graphql13.Kind.FIELD,
|
|
70795
70722
|
name: {
|
|
70796
|
-
kind:
|
|
70723
|
+
kind: graphql13.Kind.NAME,
|
|
70797
70724
|
value: "cursor"
|
|
70798
70725
|
}
|
|
70799
70726
|
},
|
|
70800
70727
|
{
|
|
70801
|
-
kind:
|
|
70728
|
+
kind: graphql13.Kind.FIELD,
|
|
70802
70729
|
name: {
|
|
70803
|
-
kind:
|
|
70730
|
+
kind: graphql13.Kind.NAME,
|
|
70804
70731
|
value: "node"
|
|
70805
70732
|
},
|
|
70806
70733
|
selectionSet: {
|
|
70807
|
-
kind:
|
|
70734
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
70808
70735
|
selections: [
|
|
70809
70736
|
{
|
|
70810
|
-
kind:
|
|
70737
|
+
kind: graphql13.Kind.FIELD,
|
|
70811
70738
|
name: {
|
|
70812
|
-
kind:
|
|
70739
|
+
kind: graphql13.Kind.NAME,
|
|
70813
70740
|
value: "__typename"
|
|
70814
70741
|
}
|
|
70815
70742
|
}
|
|
@@ -70820,39 +70747,39 @@ var pageInfoSelection = [
|
|
|
70820
70747
|
}
|
|
70821
70748
|
},
|
|
70822
70749
|
{
|
|
70823
|
-
kind:
|
|
70750
|
+
kind: graphql13.Kind.FIELD,
|
|
70824
70751
|
name: {
|
|
70825
|
-
kind:
|
|
70752
|
+
kind: graphql13.Kind.NAME,
|
|
70826
70753
|
value: "pageInfo"
|
|
70827
70754
|
},
|
|
70828
70755
|
selectionSet: {
|
|
70829
|
-
kind:
|
|
70756
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
70830
70757
|
selections: [
|
|
70831
70758
|
{
|
|
70832
|
-
kind:
|
|
70759
|
+
kind: graphql13.Kind.FIELD,
|
|
70833
70760
|
name: {
|
|
70834
|
-
kind:
|
|
70761
|
+
kind: graphql13.Kind.NAME,
|
|
70835
70762
|
value: "hasPreviousPage"
|
|
70836
70763
|
}
|
|
70837
70764
|
},
|
|
70838
70765
|
{
|
|
70839
|
-
kind:
|
|
70766
|
+
kind: graphql13.Kind.FIELD,
|
|
70840
70767
|
name: {
|
|
70841
|
-
kind:
|
|
70768
|
+
kind: graphql13.Kind.NAME,
|
|
70842
70769
|
value: "hasNextPage"
|
|
70843
70770
|
}
|
|
70844
70771
|
},
|
|
70845
70772
|
{
|
|
70846
|
-
kind:
|
|
70773
|
+
kind: graphql13.Kind.FIELD,
|
|
70847
70774
|
name: {
|
|
70848
|
-
kind:
|
|
70775
|
+
kind: graphql13.Kind.NAME,
|
|
70849
70776
|
value: "startCursor"
|
|
70850
70777
|
}
|
|
70851
70778
|
},
|
|
70852
70779
|
{
|
|
70853
|
-
kind:
|
|
70780
|
+
kind: graphql13.Kind.FIELD,
|
|
70854
70781
|
name: {
|
|
70855
|
-
kind:
|
|
70782
|
+
kind: graphql13.Kind.NAME,
|
|
70856
70783
|
value: "endCursor"
|
|
70857
70784
|
}
|
|
70858
70785
|
}
|
|
@@ -70866,17 +70793,17 @@ async function addListFragments(config, documents) {
|
|
|
70866
70793
|
const lists = {};
|
|
70867
70794
|
const errors = [];
|
|
70868
70795
|
for (const doc of documents) {
|
|
70869
|
-
doc.document =
|
|
70796
|
+
doc.document = graphql14.visit(doc.document, {
|
|
70870
70797
|
Directive(node, key, parent2, path3, ancestors) {
|
|
70871
70798
|
if ([config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
70872
70799
|
const nameArg = node.arguments?.find(
|
|
70873
70800
|
(arg) => arg.name.value === config.listOrPaginateNameArg
|
|
70874
70801
|
);
|
|
70875
70802
|
let error = {
|
|
70876
|
-
...new
|
|
70803
|
+
...new graphql14.GraphQLError(
|
|
70877
70804
|
"",
|
|
70878
70805
|
node,
|
|
70879
|
-
new
|
|
70806
|
+
new graphql14.Source(""),
|
|
70880
70807
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
70881
70808
|
path3
|
|
70882
70809
|
),
|
|
@@ -70928,7 +70855,7 @@ async function addListFragments(config, documents) {
|
|
|
70928
70855
|
{
|
|
70929
70856
|
kind: "Argument",
|
|
70930
70857
|
name: {
|
|
70931
|
-
kind:
|
|
70858
|
+
kind: graphql14.Kind.NAME,
|
|
70932
70859
|
value: "connection"
|
|
70933
70860
|
},
|
|
70934
70861
|
value: {
|
|
@@ -70978,7 +70905,7 @@ async function addListFragments(config, documents) {
|
|
|
70978
70905
|
const validDeletes = [
|
|
70979
70906
|
...new Set(
|
|
70980
70907
|
Object.values(lists).map(({ type }) => {
|
|
70981
|
-
if (!(type instanceof
|
|
70908
|
+
if (!(type instanceof graphql14.GraphQLObjectType)) {
|
|
70982
70909
|
return "";
|
|
70983
70910
|
}
|
|
70984
70911
|
if (config.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -70992,7 +70919,7 @@ async function addListFragments(config, documents) {
|
|
|
70992
70919
|
return;
|
|
70993
70920
|
}
|
|
70994
70921
|
const generatedDoc = {
|
|
70995
|
-
kind:
|
|
70922
|
+
kind: graphql14.Kind.DOCUMENT,
|
|
70996
70923
|
definitions: Object.entries(lists).flatMap(
|
|
70997
70924
|
([name, { selection, type }]) => {
|
|
70998
70925
|
const schemaType = config.schema.getType(type.name);
|
|
@@ -71000,7 +70927,7 @@ async function addListFragments(config, documents) {
|
|
|
71000
70927
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
71001
70928
|
}
|
|
71002
70929
|
const fragmentSelection = {
|
|
71003
|
-
kind:
|
|
70930
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
71004
70931
|
selections: [...selection.selections]
|
|
71005
70932
|
};
|
|
71006
70933
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -71015,14 +70942,14 @@ async function addListFragments(config, documents) {
|
|
|
71015
70942
|
{
|
|
71016
70943
|
name: {
|
|
71017
70944
|
value: config.listInsertFragment(name),
|
|
71018
|
-
kind:
|
|
70945
|
+
kind: graphql14.Kind.NAME
|
|
71019
70946
|
},
|
|
71020
|
-
kind:
|
|
70947
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
71021
70948
|
selectionSet: fragmentSelection,
|
|
71022
70949
|
typeCondition: {
|
|
71023
|
-
kind:
|
|
70950
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
71024
70951
|
name: {
|
|
71025
|
-
kind:
|
|
70952
|
+
kind: graphql14.Kind.NAME,
|
|
71026
70953
|
value: type.name
|
|
71027
70954
|
}
|
|
71028
70955
|
}
|
|
@@ -71030,32 +70957,32 @@ async function addListFragments(config, documents) {
|
|
|
71030
70957
|
{
|
|
71031
70958
|
name: {
|
|
71032
70959
|
value: config.listToggleFragment(name),
|
|
71033
|
-
kind:
|
|
70960
|
+
kind: graphql14.Kind.NAME
|
|
71034
70961
|
},
|
|
71035
|
-
kind:
|
|
70962
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
71036
70963
|
selectionSet: fragmentSelection,
|
|
71037
70964
|
typeCondition: {
|
|
71038
|
-
kind:
|
|
70965
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
71039
70966
|
name: {
|
|
71040
|
-
kind:
|
|
70967
|
+
kind: graphql14.Kind.NAME,
|
|
71041
70968
|
value: type.name
|
|
71042
70969
|
}
|
|
71043
70970
|
}
|
|
71044
70971
|
},
|
|
71045
70972
|
{
|
|
71046
|
-
kind:
|
|
70973
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
71047
70974
|
name: {
|
|
71048
70975
|
value: config.listRemoveFragment(name),
|
|
71049
|
-
kind:
|
|
70976
|
+
kind: graphql14.Kind.NAME
|
|
71050
70977
|
},
|
|
71051
70978
|
selectionSet: {
|
|
71052
|
-
kind:
|
|
70979
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
71053
70980
|
selections: [...objectIdentificationSelection(config, type)]
|
|
71054
70981
|
},
|
|
71055
70982
|
typeCondition: {
|
|
71056
|
-
kind:
|
|
70983
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
71057
70984
|
name: {
|
|
71058
|
-
kind:
|
|
70985
|
+
kind: graphql14.Kind.NAME,
|
|
71059
70986
|
value: type.name
|
|
71060
70987
|
}
|
|
71061
70988
|
}
|
|
@@ -71064,14 +70991,14 @@ async function addListFragments(config, documents) {
|
|
|
71064
70991
|
}
|
|
71065
70992
|
).concat(
|
|
71066
70993
|
...validDeletes.map((typeName) => ({
|
|
71067
|
-
kind:
|
|
70994
|
+
kind: graphql14.Kind.DIRECTIVE_DEFINITION,
|
|
71068
70995
|
name: {
|
|
71069
|
-
kind:
|
|
70996
|
+
kind: graphql14.Kind.NAME,
|
|
71070
70997
|
value: config.listDeleteDirective(typeName)
|
|
71071
70998
|
},
|
|
71072
70999
|
locations: [
|
|
71073
71000
|
{
|
|
71074
|
-
kind:
|
|
71001
|
+
kind: graphql14.Kind.NAME,
|
|
71075
71002
|
value: "FIELD"
|
|
71076
71003
|
}
|
|
71077
71004
|
],
|
|
@@ -71079,8 +71006,8 @@ async function addListFragments(config, documents) {
|
|
|
71079
71006
|
}))
|
|
71080
71007
|
)
|
|
71081
71008
|
};
|
|
71082
|
-
config.newSchema += "\n" + generatedDoc.definitions.filter((c2) => c2.kind !== "FragmentDefinition").map(
|
|
71083
|
-
config.newDocuments += "\n" + generatedDoc.definitions.filter((c2) => c2.kind === "FragmentDefinition").map(
|
|
71009
|
+
config.newSchema += "\n" + generatedDoc.definitions.filter((c2) => c2.kind !== "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
71010
|
+
config.newDocuments += "\n" + generatedDoc.definitions.filter((c2) => c2.kind === "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
71084
71011
|
documents.push({
|
|
71085
71012
|
name: "generated::lists",
|
|
71086
71013
|
kind: ArtifactKind.Fragment,
|
|
@@ -71166,11 +71093,11 @@ var nodeNotDefinedMessage = (config) => `Looks like you are trying to use the ${
|
|
|
71166
71093
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
71167
71094
|
|
|
71168
71095
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
71169
|
-
import * as
|
|
71096
|
+
import * as graphql15 from "graphql";
|
|
71170
71097
|
function fieldKey(config, field) {
|
|
71171
71098
|
const attributeName = field.alias?.value || field.name.value;
|
|
71172
|
-
const printed =
|
|
71173
|
-
const secondParse =
|
|
71099
|
+
const printed = graphql15.print(field);
|
|
71100
|
+
const secondParse = graphql15.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
71174
71101
|
let paginateMode = config.defaultPaginateMode;
|
|
71175
71102
|
const paginatedDirective = field.directives?.find(
|
|
71176
71103
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -71293,13 +71220,13 @@ function prepareSelection({
|
|
|
71293
71220
|
} else if ("getFields" in type) {
|
|
71294
71221
|
let typeRef = type.getFields()[field.name.value].type;
|
|
71295
71222
|
fieldType = getRootType(typeRef);
|
|
71296
|
-
nullable = !
|
|
71297
|
-
} else if (
|
|
71223
|
+
nullable = !graphql16.isNonNullType(typeRef);
|
|
71224
|
+
} else if (graphql16.isAbstractType(type)) {
|
|
71298
71225
|
for (const possible of config.schema.getPossibleTypes(type)) {
|
|
71299
|
-
if (
|
|
71226
|
+
if (graphql16.isObjectType(possible)) {
|
|
71300
71227
|
if (possible.getFields()[field.name.value]) {
|
|
71301
71228
|
fieldType = possible.getFields()[field.name.value].type;
|
|
71302
|
-
nullable = !
|
|
71229
|
+
nullable = !graphql16.isNonNullType(fieldType);
|
|
71303
71230
|
break;
|
|
71304
71231
|
}
|
|
71305
71232
|
}
|
|
@@ -71436,7 +71363,7 @@ function prepareSelection({
|
|
|
71436
71363
|
kind: "value"
|
|
71437
71364
|
} : { kind: "continue" };
|
|
71438
71365
|
const parentType = config.schema.getType(rootType);
|
|
71439
|
-
if (
|
|
71366
|
+
if (graphql16.isObjectType(parentType) || graphql16.isInterfaceType(parentType)) {
|
|
71440
71367
|
const fieldType2 = parentType.getFields()[field.name.value]?.type;
|
|
71441
71368
|
if (fieldType2) {
|
|
71442
71369
|
const listCount = unwrapType(config, fieldType2).wrappers.filter(
|
|
@@ -71459,7 +71386,7 @@ function prepareSelection({
|
|
|
71459
71386
|
}
|
|
71460
71387
|
fieldObj.loading = loadingValue;
|
|
71461
71388
|
}
|
|
71462
|
-
if (
|
|
71389
|
+
if (graphql16.isInterfaceType(fieldType) || graphql16.isUnionType(fieldType)) {
|
|
71463
71390
|
fieldObj.abstract = true;
|
|
71464
71391
|
if (Object.values(fieldObj.selection?.abstractFields?.fields ?? {}).some(
|
|
71465
71392
|
(fields) => Object.values(fields ?? {}).some((field2) => field2.required)
|
|
@@ -71541,7 +71468,7 @@ function mergeSelection({
|
|
|
71541
71468
|
typeSelection,
|
|
71542
71469
|
abstractSelection.fields[typeName] ?? {}
|
|
71543
71470
|
);
|
|
71544
|
-
if (
|
|
71471
|
+
if (graphql16.isAbstractType(gqlType)) {
|
|
71545
71472
|
for (const possible of config.schema.getPossibleTypes(gqlType)) {
|
|
71546
71473
|
if (!possibleSelectionTypes[typeName]) {
|
|
71547
71474
|
possibleSelectionTypes[typeName] = [];
|
|
@@ -71576,7 +71503,7 @@ function mergeSelection({
|
|
|
71576
71503
|
}
|
|
71577
71504
|
}
|
|
71578
71505
|
const parentType = config.schema.getType(rootType);
|
|
71579
|
-
const possibleParents =
|
|
71506
|
+
const possibleParents = graphql16.isAbstractType(parentType) ? config.schema.getPossibleTypes(parentType)?.map((t3) => t3.name) : [parentType.name];
|
|
71580
71507
|
for (const key of Object.keys(abstractSelection.typeMap)) {
|
|
71581
71508
|
if (!possibleParents.includes(key) && rootType !== key || abstractSelection.fields[key]) {
|
|
71582
71509
|
delete abstractSelection.typeMap[key];
|
|
@@ -71633,12 +71560,12 @@ function mergeSelection({
|
|
|
71633
71560
|
}
|
|
71634
71561
|
|
|
71635
71562
|
// src/codegen/generators/artifacts/index.ts
|
|
71636
|
-
var
|
|
71563
|
+
var AST5 = recast5.types.builders;
|
|
71637
71564
|
function artifactGenerator(stats) {
|
|
71638
71565
|
return async function(config, docs) {
|
|
71639
71566
|
const filterTypes = {};
|
|
71640
71567
|
for (const doc of docs) {
|
|
71641
|
-
|
|
71568
|
+
graphql17.visit(doc.document, {
|
|
71642
71569
|
Directive(node, _3, __, ___, ancestors) {
|
|
71643
71570
|
if (node.name.value !== config.listDirective) {
|
|
71644
71571
|
return;
|
|
@@ -71698,7 +71625,7 @@ function artifactGenerator(stats) {
|
|
|
71698
71625
|
return;
|
|
71699
71626
|
}
|
|
71700
71627
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
71701
|
-
let documentWithoutInternalDirectives =
|
|
71628
|
+
let documentWithoutInternalDirectives = graphql17.visit(document, {
|
|
71702
71629
|
Directive(node) {
|
|
71703
71630
|
if (config.isInternalDirective(node.name.value)) {
|
|
71704
71631
|
return null;
|
|
@@ -71711,7 +71638,7 @@ function artifactGenerator(stats) {
|
|
|
71711
71638
|
}
|
|
71712
71639
|
}
|
|
71713
71640
|
});
|
|
71714
|
-
let documentWithoutExtraVariables =
|
|
71641
|
+
let documentWithoutExtraVariables = graphql17.visit(
|
|
71715
71642
|
documentWithoutInternalDirectives,
|
|
71716
71643
|
{
|
|
71717
71644
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -71722,13 +71649,13 @@ function artifactGenerator(stats) {
|
|
|
71722
71649
|
}
|
|
71723
71650
|
}
|
|
71724
71651
|
);
|
|
71725
|
-
let rawString =
|
|
71652
|
+
let rawString = graphql17.print(documentWithoutExtraVariables);
|
|
71726
71653
|
let docKind = doc.kind;
|
|
71727
71654
|
const operations = document.definitions.filter(
|
|
71728
|
-
({ kind }) => kind ===
|
|
71655
|
+
({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
|
|
71729
71656
|
);
|
|
71730
71657
|
const fragments = document.definitions.filter(
|
|
71731
|
-
({ kind }) => kind ===
|
|
71658
|
+
({ kind }) => kind === graphql17.Kind.FRAGMENT_DEFINITION
|
|
71732
71659
|
);
|
|
71733
71660
|
let rootType = "";
|
|
71734
71661
|
let selectionSet;
|
|
@@ -71875,7 +71802,21 @@ function artifactGenerator(stats) {
|
|
|
71875
71802
|
artifact.pluginData[plugin2.name] = plugin2.artifactData({ config, document: doc }) ?? {};
|
|
71876
71803
|
}
|
|
71877
71804
|
if (inputs && inputs.length > 0) {
|
|
71878
|
-
|
|
71805
|
+
const runtimeScalars = inputs.reduce((prev, input) => {
|
|
71806
|
+
const runtimeScalarDirective = input.directives?.find(
|
|
71807
|
+
(directive2) => directive2.name.value === config.runtimeScalarDirective
|
|
71808
|
+
);
|
|
71809
|
+
if (!runtimeScalarDirective) {
|
|
71810
|
+
return prev;
|
|
71811
|
+
}
|
|
71812
|
+
return {
|
|
71813
|
+
...prev,
|
|
71814
|
+
[input.variable.name.value]: runtimeScalarDirective.arguments?.find(
|
|
71815
|
+
(arg) => arg.name.value === "type"
|
|
71816
|
+
)?.value?.value
|
|
71817
|
+
};
|
|
71818
|
+
}, {});
|
|
71819
|
+
artifact.input = inputObject(config, inputs, runtimeScalars);
|
|
71879
71820
|
}
|
|
71880
71821
|
if (artifact.kind === "HoudiniQuery") {
|
|
71881
71822
|
const cacheDirective = operations[0].directives?.find(
|
|
@@ -71914,9 +71855,9 @@ function artifactGenerator(stats) {
|
|
|
71914
71855
|
plugin2.artifactEnd({ config, document: doc });
|
|
71915
71856
|
}
|
|
71916
71857
|
const _houdiniHash = hashOriginal({ document: doc });
|
|
71917
|
-
const file =
|
|
71858
|
+
const file = AST5.program([
|
|
71918
71859
|
moduleExport(config, "default", serializeValue(artifact)),
|
|
71919
|
-
|
|
71860
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
71920
71861
|
]);
|
|
71921
71862
|
const artifactPath = config.artifactPath(document);
|
|
71922
71863
|
const countDocument = doc.generateStore;
|
|
@@ -71974,7 +71915,7 @@ function applyMask(config, target, mask) {
|
|
|
71974
71915
|
if (!targetType) {
|
|
71975
71916
|
continue;
|
|
71976
71917
|
}
|
|
71977
|
-
if (
|
|
71918
|
+
if (graphql17.isAbstractType(targetType)) {
|
|
71978
71919
|
for (const possible of config.schema.getPossibleTypes(targetType)) {
|
|
71979
71920
|
if (target.abstractFields?.fields[possible.name]) {
|
|
71980
71921
|
applyMask(
|
|
@@ -71997,8 +71938,8 @@ function applyMask(config, target, mask) {
|
|
|
71997
71938
|
}
|
|
71998
71939
|
|
|
71999
71940
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
72000
|
-
var
|
|
72001
|
-
var
|
|
71941
|
+
var recast6 = __toESM(require_main2(), 1);
|
|
71942
|
+
var AST6 = recast6.types.builders;
|
|
72002
71943
|
async function generateGraphqlReturnTypes(config, docs) {
|
|
72003
71944
|
const indexPath = path_exports.join(config.runtimeDirectory, "index.d.ts");
|
|
72004
71945
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
@@ -72033,18 +71974,18 @@ async function generateGraphqlReturnTypes(config, docs) {
|
|
|
72033
71974
|
continue;
|
|
72034
71975
|
}
|
|
72035
71976
|
for (const [queryString, returnValue] of Object.entries(overloaded_returns)) {
|
|
72036
|
-
const input =
|
|
72037
|
-
input.typeAnnotation =
|
|
72038
|
-
|
|
71977
|
+
const input = AST6.identifier("str");
|
|
71978
|
+
input.typeAnnotation = AST6.tsTypeAnnotation(
|
|
71979
|
+
AST6.tsLiteralType(AST6.stringLiteral(queryString))
|
|
72039
71980
|
);
|
|
72040
71981
|
script.body.splice(
|
|
72041
71982
|
i2,
|
|
72042
71983
|
0,
|
|
72043
|
-
|
|
72044
|
-
|
|
72045
|
-
|
|
71984
|
+
AST6.exportNamedDeclaration(
|
|
71985
|
+
AST6.tsDeclareFunction(
|
|
71986
|
+
AST6.identifier("graphql"),
|
|
72046
71987
|
[input],
|
|
72047
|
-
|
|
71988
|
+
AST6.tsTypeAnnotation(AST6.tsTypeReference(AST6.identifier(returnValue)))
|
|
72048
71989
|
)
|
|
72049
71990
|
)
|
|
72050
71991
|
);
|
|
@@ -72219,165 +72160,22 @@ function moduleStatments(config) {
|
|
|
72219
72160
|
var recast11 = __toESM(require_main2(), 1);
|
|
72220
72161
|
|
|
72221
72162
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
72222
|
-
var recast8 = __toESM(require_main2(), 1);
|
|
72223
|
-
import * as graphql19 from "graphql";
|
|
72224
|
-
|
|
72225
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
72226
72163
|
var recast7 = __toESM(require_main2(), 1);
|
|
72227
72164
|
import * as graphql18 from "graphql";
|
|
72228
|
-
|
|
72229
|
-
// src/codegen/generators/typescript/types.ts
|
|
72230
|
-
var recast6 = __toESM(require_main2(), 1);
|
|
72231
|
-
import * as graphql17 from "graphql";
|
|
72232
|
-
var AST6 = recast6.types.builders;
|
|
72233
|
-
function readonlyProperty(prop, enable = true) {
|
|
72234
|
-
if (enable) {
|
|
72235
|
-
prop.readonly = true;
|
|
72236
|
-
}
|
|
72237
|
-
return prop;
|
|
72238
|
-
}
|
|
72239
|
-
function nullableField(inner, input = false) {
|
|
72240
|
-
const members = [inner, AST6.tsNullKeyword()];
|
|
72241
|
-
if (input) {
|
|
72242
|
-
members.push(AST6.tsUndefinedKeyword());
|
|
72243
|
-
}
|
|
72244
|
-
return AST6.tsUnionType(members);
|
|
72245
|
-
}
|
|
72246
|
-
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
72247
|
-
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
72248
|
-
if (!field) {
|
|
72249
|
-
return AST6.tsNeverKeyword();
|
|
72250
|
-
}
|
|
72251
|
-
const component = config.componentFields[field.parent][field.field];
|
|
72252
|
-
const sourcePathRelative = path_exports.relative(
|
|
72253
|
-
path_exports.join(config.projectRoot, "src"),
|
|
72254
|
-
component.filepath
|
|
72255
|
-
);
|
|
72256
|
-
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
72257
|
-
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
72258
|
-
const localImport = ensureImports({
|
|
72259
|
-
config,
|
|
72260
|
-
body,
|
|
72261
|
-
import: "__component__" + component.fragment,
|
|
72262
|
-
sourceModule: path_exports.join(
|
|
72263
|
-
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
72264
|
-
"src",
|
|
72265
|
-
sourcePath
|
|
72266
|
-
)
|
|
72267
|
-
});
|
|
72268
|
-
const parameters = AST6.tsTypeReference(AST6.identifier("Parameters"));
|
|
72269
|
-
parameters.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
72270
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
72271
|
-
]);
|
|
72272
|
-
const indexed = AST6.tsIndexedAccessType(
|
|
72273
|
-
parameters,
|
|
72274
|
-
AST6.tsLiteralType(AST6.numericLiteral(0))
|
|
72275
|
-
);
|
|
72276
|
-
const omit = AST6.tsTypeReference(AST6.identifier("Omit"));
|
|
72277
|
-
omit.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
72278
|
-
indexed,
|
|
72279
|
-
AST6.tsLiteralType(AST6.stringLiteral(component.prop))
|
|
72280
|
-
]);
|
|
72281
|
-
const arg = AST6.identifier("props");
|
|
72282
|
-
arg.typeAnnotation = AST6.tsTypeAnnotation(omit);
|
|
72283
|
-
const returnType = AST6.tsTypeReference(AST6.identifier("ReturnType"));
|
|
72284
|
-
returnType.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
72285
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
72286
|
-
]);
|
|
72287
|
-
const fnType = AST6.tsFunctionType([arg]);
|
|
72288
|
-
fnType.typeAnnotation = AST6.tsTypeAnnotation(returnType);
|
|
72289
|
-
return fnType;
|
|
72290
|
-
}
|
|
72291
|
-
switch (target.name) {
|
|
72292
|
-
case "String": {
|
|
72293
|
-
return AST6.tsStringKeyword();
|
|
72294
|
-
}
|
|
72295
|
-
case "Int": {
|
|
72296
|
-
return AST6.tsNumberKeyword();
|
|
72297
|
-
}
|
|
72298
|
-
case "Float": {
|
|
72299
|
-
return AST6.tsNumberKeyword();
|
|
72300
|
-
}
|
|
72301
|
-
case "Boolean": {
|
|
72302
|
-
return AST6.tsBooleanKeyword();
|
|
72303
|
-
}
|
|
72304
|
-
case "ID": {
|
|
72305
|
-
return AST6.tsStringKeyword();
|
|
72306
|
-
}
|
|
72307
|
-
default: {
|
|
72308
|
-
if (graphql17.isNonNullType(target) && "ofType" in target) {
|
|
72309
|
-
return scalarPropertyValue(
|
|
72310
|
-
config,
|
|
72311
|
-
filepath,
|
|
72312
|
-
missingScalars,
|
|
72313
|
-
target.ofType,
|
|
72314
|
-
body,
|
|
72315
|
-
field
|
|
72316
|
-
);
|
|
72317
|
-
}
|
|
72318
|
-
if (config.scalars?.[target.name]) {
|
|
72319
|
-
return AST6.tsTypeReference(AST6.identifier(config.scalars?.[target.name].type));
|
|
72320
|
-
}
|
|
72321
|
-
if (target.name !== config.componentScalar) {
|
|
72322
|
-
missingScalars.add(target.name);
|
|
72323
|
-
}
|
|
72324
|
-
return AST6.tsAnyKeyword();
|
|
72325
|
-
}
|
|
72326
|
-
}
|
|
72327
|
-
}
|
|
72328
|
-
|
|
72329
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
72330
72165
|
var AST7 = recast7.types.builders;
|
|
72331
|
-
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
72332
|
-
const { type, wrappers } = unwrapType(config, definition.type);
|
|
72333
|
-
let result;
|
|
72334
|
-
if (graphql18.isScalarType(type)) {
|
|
72335
|
-
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
72336
|
-
} else if (graphql18.isEnumType(type)) {
|
|
72337
|
-
result = enumReference(config, body, type.name);
|
|
72338
|
-
} else {
|
|
72339
|
-
result = AST7.tsTypeReference(AST7.identifier(type.name));
|
|
72340
|
-
}
|
|
72341
|
-
for (const toWrap of wrappers) {
|
|
72342
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
72343
|
-
continue;
|
|
72344
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
72345
|
-
result = nullableField(result, true);
|
|
72346
|
-
} else if (toWrap === "List" /* List */) {
|
|
72347
|
-
result = AST7.tsArrayType(AST7.tsParenthesizedType(result));
|
|
72348
|
-
}
|
|
72349
|
-
}
|
|
72350
|
-
return result;
|
|
72351
|
-
}
|
|
72352
|
-
function enumReference(config, body, name) {
|
|
72353
|
-
ensureImports({
|
|
72354
|
-
config,
|
|
72355
|
-
body,
|
|
72356
|
-
import: ["ValueOf"],
|
|
72357
|
-
importKind: "type",
|
|
72358
|
-
sourceModule: "$houdini/runtime/lib/types"
|
|
72359
|
-
});
|
|
72360
|
-
return AST7.tsTypeReference(
|
|
72361
|
-
AST7.identifier("ValueOf"),
|
|
72362
|
-
AST7.tsTypeParameterInstantiation([AST7.tsTypeQuery(AST7.identifier(name))])
|
|
72363
|
-
);
|
|
72364
|
-
}
|
|
72365
|
-
|
|
72366
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
72367
|
-
var AST8 = recast8.types.builders;
|
|
72368
72166
|
function addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
72369
72167
|
const { type } = unwrapType(config, rootType);
|
|
72370
|
-
if (
|
|
72168
|
+
if (graphql18.isScalarType(type)) {
|
|
72371
72169
|
return;
|
|
72372
72170
|
}
|
|
72373
72171
|
if (visitedTypes.has(type.name)) {
|
|
72374
72172
|
return;
|
|
72375
72173
|
}
|
|
72376
|
-
if (
|
|
72174
|
+
if (graphql18.isUnionType(type)) {
|
|
72377
72175
|
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
72378
72176
|
}
|
|
72379
72177
|
visitedTypes.add(type.name);
|
|
72380
|
-
if (
|
|
72178
|
+
if (graphql18.isEnumType(type)) {
|
|
72381
72179
|
ensureImports({
|
|
72382
72180
|
config,
|
|
72383
72181
|
body,
|
|
@@ -72391,21 +72189,37 @@ function addReferencedInputTypes(config, filepath, body, visitedTypes, missingSc
|
|
|
72391
72189
|
for (const field of Object.values(type.getFields())) {
|
|
72392
72190
|
addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, field.type);
|
|
72393
72191
|
members.push(
|
|
72394
|
-
|
|
72395
|
-
|
|
72396
|
-
|
|
72192
|
+
AST7.tsPropertySignature(
|
|
72193
|
+
AST7.identifier(field.name),
|
|
72194
|
+
AST7.tsTypeAnnotation(
|
|
72397
72195
|
tsTypeReference(config, filepath, missingScalars, field, body)
|
|
72398
72196
|
),
|
|
72399
|
-
|
|
72197
|
+
graphql18.isNullableType(field.type)
|
|
72400
72198
|
)
|
|
72401
72199
|
);
|
|
72402
72200
|
}
|
|
72403
|
-
body.push(
|
|
72201
|
+
body.push(AST7.tsTypeAliasDeclaration(AST7.identifier(type.name), AST7.tsTypeLiteral(members)));
|
|
72404
72202
|
}
|
|
72405
72203
|
|
|
72406
72204
|
// src/codegen/generators/typescript/inlineType.ts
|
|
72407
72205
|
var recast9 = __toESM(require_main2(), 1);
|
|
72408
|
-
import * as
|
|
72206
|
+
import * as graphql19 from "graphql";
|
|
72207
|
+
|
|
72208
|
+
// src/codegen/generators/comments/jsdoc.ts
|
|
72209
|
+
var recast8 = __toESM(require_main2(), 1);
|
|
72210
|
+
var AST8 = recast8.types.builders;
|
|
72211
|
+
function jsdocComment(text, deprecated) {
|
|
72212
|
+
let commentContent = `*
|
|
72213
|
+
* ${text}
|
|
72214
|
+
`;
|
|
72215
|
+
if (deprecated) {
|
|
72216
|
+
commentContent = `${commentContent} * @deprecated ${deprecated}
|
|
72217
|
+
`;
|
|
72218
|
+
}
|
|
72219
|
+
return AST8.commentBlock(commentContent, true);
|
|
72220
|
+
}
|
|
72221
|
+
|
|
72222
|
+
// src/codegen/generators/typescript/inlineType.ts
|
|
72409
72223
|
var AST9 = recast9.types.builders;
|
|
72410
72224
|
var fragmentKey2 = " $fragments";
|
|
72411
72225
|
function inlineType({
|
|
@@ -72426,7 +72240,7 @@ function inlineType({
|
|
|
72426
72240
|
const { type, wrappers } = unwrapType(config, rootType);
|
|
72427
72241
|
let result;
|
|
72428
72242
|
let forceNullable = false;
|
|
72429
|
-
if (
|
|
72243
|
+
if (graphql19.isScalarType(type)) {
|
|
72430
72244
|
result = scalarPropertyValue(
|
|
72431
72245
|
config,
|
|
72432
72246
|
filepath,
|
|
@@ -72435,7 +72249,7 @@ function inlineType({
|
|
|
72435
72249
|
body,
|
|
72436
72250
|
field
|
|
72437
72251
|
);
|
|
72438
|
-
} else if (
|
|
72252
|
+
} else if (graphql19.isEnumType(type)) {
|
|
72439
72253
|
ensureImports({
|
|
72440
72254
|
config,
|
|
72441
72255
|
body,
|
|
@@ -72460,11 +72274,11 @@ function inlineType({
|
|
|
72460
72274
|
for (const selection of selections) {
|
|
72461
72275
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
72462
72276
|
const fragmentType = config.schema.getType(selection.typeCondition.name.value);
|
|
72463
|
-
if (!
|
|
72277
|
+
if (!graphql19.isInterfaceType(type) && !graphql19.isUnionType(type)) {
|
|
72464
72278
|
selectedFields.push(...selection.selectionSet.selections);
|
|
72465
72279
|
continue;
|
|
72466
72280
|
}
|
|
72467
|
-
if (!
|
|
72281
|
+
if (!graphql19.isInterfaceType(fragmentType) && !graphql19.isUnionType(fragmentType)) {
|
|
72468
72282
|
if (!inlineFragments[fragmentType.name]) {
|
|
72469
72283
|
inlineFragments[fragmentType.name] = [];
|
|
72470
72284
|
}
|
|
@@ -72556,6 +72370,11 @@ function inlineType({
|
|
|
72556
72370
|
if (allOptional) {
|
|
72557
72371
|
prop.optional = true;
|
|
72558
72372
|
}
|
|
72373
|
+
if (field2.description || field2.deprecationReason) {
|
|
72374
|
+
prop.comments = [
|
|
72375
|
+
jsdocComment(field2.description ?? "", field2.deprecationReason ?? void 0)
|
|
72376
|
+
];
|
|
72377
|
+
}
|
|
72559
72378
|
return prop;
|
|
72560
72379
|
})
|
|
72561
72380
|
]);
|
|
@@ -72607,7 +72426,7 @@ function inlineType({
|
|
|
72607
72426
|
}
|
|
72608
72427
|
}
|
|
72609
72428
|
}
|
|
72610
|
-
if (objectType.type === "TSTypeLiteral" && !
|
|
72429
|
+
if (objectType.type === "TSTypeLiteral" && !graphql19.isInterfaceType(fragmentRootType) && !graphql19.isUnionType(fragmentRootType)) {
|
|
72611
72430
|
const existingTypenameIndex = objectType.members.findIndex(
|
|
72612
72431
|
(member) => member.type === "TSPropertySignature" && member.key.type === "Identifier" && member.key.name === "__typename"
|
|
72613
72432
|
);
|
|
@@ -72632,11 +72451,11 @@ function inlineType({
|
|
|
72632
72451
|
];
|
|
72633
72452
|
}
|
|
72634
72453
|
let coveredTypenames;
|
|
72635
|
-
if (
|
|
72454
|
+
if (graphql19.isInterfaceType(fragmentRootType)) {
|
|
72636
72455
|
coveredTypenames = interfaceCoveredTypenames(fragmentRootType);
|
|
72637
|
-
} else if (
|
|
72456
|
+
} else if (graphql19.isUnionType(fragmentRootType)) {
|
|
72638
72457
|
coveredTypenames = fragmentRootType.getTypes().map((type2) => type2.name);
|
|
72639
|
-
} else if (
|
|
72458
|
+
} else if (graphql19.isObjectType(fragmentRootType)) {
|
|
72640
72459
|
coveredTypenames = [fragmentRootType.name];
|
|
72641
72460
|
} else {
|
|
72642
72461
|
throw Error("unreachable code");
|
|
@@ -72672,7 +72491,7 @@ function inlineType({
|
|
|
72672
72491
|
);
|
|
72673
72492
|
}
|
|
72674
72493
|
);
|
|
72675
|
-
const parentIsUnionOrInterface = !
|
|
72494
|
+
const parentIsUnionOrInterface = !graphql19.isInterfaceType(type) && !graphql19.isUnionType(type);
|
|
72676
72495
|
const possibleTypenames = parentIsUnionOrInterface ? [parent.name] : config.schema.getPossibleTypes(type).map((type2) => type2.name);
|
|
72677
72496
|
const coveredTypenames = new Set(
|
|
72678
72497
|
Object.values(inlineFragmentSelections).flatMap((sel) => sel.coveredTypenames)
|
|
@@ -72739,7 +72558,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
72739
72558
|
},
|
|
72740
72559
|
type: schema.getType("String")
|
|
72741
72560
|
};
|
|
72742
|
-
} else if (
|
|
72561
|
+
} else if (graphql19.isNonNullType(rootType) && "getFields" in rootType.ofType) {
|
|
72743
72562
|
fields = rootType.ofType.getFields();
|
|
72744
72563
|
} else {
|
|
72745
72564
|
fields = rootType.getFields();
|
|
@@ -72751,7 +72570,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
72751
72570
|
message: `Could not find type information for field ${rootType.toString()}.${selectionName} ${field}`
|
|
72752
72571
|
});
|
|
72753
72572
|
}
|
|
72754
|
-
const fieldType =
|
|
72573
|
+
const fieldType = graphql19.getNamedType(field.type);
|
|
72755
72574
|
if (!fieldType) {
|
|
72756
72575
|
throw new HoudiniError({
|
|
72757
72576
|
filepath,
|
|
@@ -72967,17 +72786,20 @@ export * from "${module}"
|
|
|
72967
72786
|
}
|
|
72968
72787
|
}
|
|
72969
72788
|
await fs_exports.writeFile(config.typeIndexPath, indexContent);
|
|
72970
|
-
|
|
72971
|
-
|
|
72972
|
-
|
|
72973
|
-
|
|
72789
|
+
const missingScalarNames = [...missingScalars].filter(
|
|
72790
|
+
(scalar) => !config.configFile.features?.runtimeScalars?.[scalar]
|
|
72791
|
+
);
|
|
72792
|
+
if (missingScalarNames.length > 0) {
|
|
72793
|
+
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
|
|
72794
|
+
...missingScalarNames
|
|
72795
|
+
].join(", ")}
|
|
72974
72796
|
Generated types will contain an any type in place of these values. To fix this, provide an equivalent
|
|
72975
72797
|
type in your config file:
|
|
72976
72798
|
|
|
72977
72799
|
{
|
|
72978
72800
|
scalars: {
|
|
72979
72801
|
${cyan2(`/* in your case, something like */`)}
|
|
72980
|
-
${[...
|
|
72802
|
+
${[...missingScalarNames].map(
|
|
72981
72803
|
(c2) => ` ${c2}: { ${green2(`// <- The GraphQL Scalar`)}
|
|
72982
72804
|
type: "${cyan2(`YourType_${c2}`)}" ${green2(`// <- The TypeScript type`)}
|
|
72983
72805
|
}`
|
|
@@ -73257,7 +73079,7 @@ async function generateFragmentTypeDefs(config, filepath, body, selections, defi
|
|
|
73257
73079
|
|
|
73258
73080
|
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
73259
73081
|
var recast12 = __toESM(require_main2(), 1);
|
|
73260
|
-
import * as
|
|
73082
|
+
import * as graphql20 from "graphql";
|
|
73261
73083
|
var AST12 = recast12.types.builders;
|
|
73262
73084
|
async function imperativeCacheTypef(config, docs) {
|
|
73263
73085
|
const returnType = (doc) => config.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
@@ -73308,7 +73130,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
73308
73130
|
const operationTypes = [config.schema.getMutationType(), config.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
73309
73131
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
73310
73132
|
const types16 = Object.values(config.schema.getTypeMap()).filter(
|
|
73311
|
-
(type) => !
|
|
73133
|
+
(type) => !graphql20.isAbstractType(type) && !graphql20.isScalarType(type) && !graphql20.isEnumType(type) && !graphql20.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
73312
73134
|
);
|
|
73313
73135
|
const fragmentMap = fragmentListMap(
|
|
73314
73136
|
config,
|
|
@@ -73325,7 +73147,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
73325
73147
|
}
|
|
73326
73148
|
let idFields = AST12.tsNeverKeyword();
|
|
73327
73149
|
const keys2 = keyFieldsForType(config.configFile, type.name);
|
|
73328
|
-
if (
|
|
73150
|
+
if (graphql20.isObjectType(type) && keys2.length > 0 && keys2.every((key) => type.getFields()[key])) {
|
|
73329
73151
|
idFields = AST12.tsTypeLiteral(
|
|
73330
73152
|
keys2.map((key) => {
|
|
73331
73153
|
const fieldType = type.getFields()[key];
|
|
@@ -73352,13 +73174,13 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
73352
73174
|
idFields = AST12.tsTypeLiteral([]);
|
|
73353
73175
|
}
|
|
73354
73176
|
let fields = AST12.tsTypeLiteral([]);
|
|
73355
|
-
if (
|
|
73177
|
+
if (graphql20.isObjectType(type)) {
|
|
73356
73178
|
fields = AST12.tsTypeLiteral(
|
|
73357
73179
|
Object.entries(type.getFields()).map(
|
|
73358
73180
|
([key, fieldType]) => {
|
|
73359
73181
|
const unwrapped = unwrapType(config, fieldType.type);
|
|
73360
73182
|
let typeOptions = AST12.tsUnionType([]);
|
|
73361
|
-
if (
|
|
73183
|
+
if (graphql20.isScalarType(unwrapped.type)) {
|
|
73362
73184
|
typeOptions.types.push(
|
|
73363
73185
|
scalarPropertyValue(
|
|
73364
73186
|
config,
|
|
@@ -73372,11 +73194,11 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
73372
73194
|
}
|
|
73373
73195
|
)
|
|
73374
73196
|
);
|
|
73375
|
-
} else if (
|
|
73197
|
+
} else if (graphql20.isEnumType(unwrapped.type)) {
|
|
73376
73198
|
typeOptions.types.push(
|
|
73377
73199
|
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
73378
73200
|
);
|
|
73379
|
-
} else if (!
|
|
73201
|
+
} else if (!graphql20.isAbstractType(unwrapped.type)) {
|
|
73380
73202
|
typeOptions.types.push(record(unwrapped.type.name));
|
|
73381
73203
|
} else {
|
|
73382
73204
|
typeOptions.types.push(
|
|
@@ -73472,7 +73294,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
73472
73294
|
const lists = [];
|
|
73473
73295
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
73474
73296
|
for (const doc of docs) {
|
|
73475
|
-
|
|
73297
|
+
graphql20.visit(doc.document, {
|
|
73476
73298
|
Directive(node, key, parent2, path3, ancestors) {
|
|
73477
73299
|
if (![config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
73478
73300
|
return;
|
|
@@ -73494,7 +73316,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
73494
73316
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
73495
73317
|
const { type: listType } = unwrapType(config, targetFieldDefinition.type);
|
|
73496
73318
|
const possibleTypes = [];
|
|
73497
|
-
if (
|
|
73319
|
+
if (graphql20.isAbstractType(listType)) {
|
|
73498
73320
|
possibleTypes.push(
|
|
73499
73321
|
...config.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
73500
73322
|
);
|
|
@@ -73656,7 +73478,7 @@ async function typescriptGenerator(config, docs) {
|
|
|
73656
73478
|
}
|
|
73657
73479
|
|
|
73658
73480
|
// src/codegen/generators/persistedQueries/index.ts
|
|
73659
|
-
import * as
|
|
73481
|
+
import * as graphql21 from "graphql";
|
|
73660
73482
|
async function persistOutputGenerator(config, docs) {
|
|
73661
73483
|
if (!config.persistedQueriesPath.endsWith(".json")) {
|
|
73662
73484
|
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
@@ -73666,8 +73488,8 @@ async function persistOutputGenerator(config, docs) {
|
|
|
73666
73488
|
if (!generateArtifact) {
|
|
73667
73489
|
return acc;
|
|
73668
73490
|
}
|
|
73669
|
-
let rawString =
|
|
73670
|
-
|
|
73491
|
+
let rawString = graphql21.print(
|
|
73492
|
+
graphql21.visit(document, {
|
|
73671
73493
|
Directive(node) {
|
|
73672
73494
|
if (config.isInternalDirective(node.name.value)) {
|
|
73673
73495
|
return null;
|
|
@@ -73676,7 +73498,7 @@ async function persistOutputGenerator(config, docs) {
|
|
|
73676
73498
|
})
|
|
73677
73499
|
);
|
|
73678
73500
|
const operations = document.definitions.filter(
|
|
73679
|
-
({ kind }) => kind ===
|
|
73501
|
+
({ kind }) => kind === graphql21.Kind.OPERATION_DEFINITION
|
|
73680
73502
|
);
|
|
73681
73503
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
73682
73504
|
if (artifact) {
|
|
@@ -73691,33 +73513,45 @@ async function persistOutputGenerator(config, docs) {
|
|
|
73691
73513
|
}
|
|
73692
73514
|
|
|
73693
73515
|
// src/codegen/generators/definitions/index.ts
|
|
73694
|
-
import * as
|
|
73516
|
+
import * as graphql23 from "graphql";
|
|
73695
73517
|
|
|
73696
73518
|
// src/codegen/generators/definitions/enums.ts
|
|
73697
73519
|
var recast13 = __toESM(require_main2(), 1);
|
|
73698
|
-
import * as
|
|
73520
|
+
import * as graphql22 from "graphql";
|
|
73699
73521
|
var AST13 = recast13.types.builders;
|
|
73700
73522
|
async function definitionsGenerator(config) {
|
|
73701
|
-
const enums =
|
|
73523
|
+
const enums = graphql22.parse(graphql22.printSchema(config.schema)).definitions.filter(
|
|
73702
73524
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
73703
73525
|
).filter((def) => !config.isInternalEnum(def));
|
|
73704
73526
|
const { code: runtimeDefinitions } = await printJS(
|
|
73705
73527
|
AST13.program(
|
|
73706
73528
|
enums.map((defn) => {
|
|
73707
73529
|
const name = defn.name.value;
|
|
73708
|
-
|
|
73530
|
+
const declaration = moduleExport(
|
|
73709
73531
|
config,
|
|
73710
73532
|
name,
|
|
73711
73533
|
AST13.objectExpression(
|
|
73712
73534
|
defn.values?.map((value) => {
|
|
73713
73535
|
const str = value.name.value;
|
|
73714
|
-
|
|
73536
|
+
const prop = AST13.objectProperty(
|
|
73715
73537
|
AST13.stringLiteral(str),
|
|
73716
73538
|
AST13.stringLiteral(str)
|
|
73717
73539
|
);
|
|
73540
|
+
const deprecationReason = value.directives?.find((d3) => d3.name.value === "deprecated")?.arguments?.find((a2) => a2.name.value === "reason")?.value?.value;
|
|
73541
|
+
if (value.description || deprecationReason)
|
|
73542
|
+
prop.comments = [
|
|
73543
|
+
jsdocComment(value.description?.value ?? "", deprecationReason)
|
|
73544
|
+
];
|
|
73545
|
+
return prop;
|
|
73718
73546
|
}) || []
|
|
73719
73547
|
)
|
|
73720
73548
|
);
|
|
73549
|
+
if (defn.description) {
|
|
73550
|
+
declaration.comments = [
|
|
73551
|
+
AST13.commentBlock(`* ${defn.description.value} `, true, false)
|
|
73552
|
+
];
|
|
73553
|
+
}
|
|
73554
|
+
return declaration;
|
|
73721
73555
|
})
|
|
73722
73556
|
)
|
|
73723
73557
|
);
|
|
@@ -73726,11 +73560,19 @@ type ValuesOf<T> = T[keyof T]
|
|
|
73726
73560
|
` + enums.sort((a2, b2) => a2.name.value.localeCompare(b2.name.value)).map((definition) => {
|
|
73727
73561
|
const name = definition.name.value;
|
|
73728
73562
|
const values = definition.values;
|
|
73729
|
-
|
|
73563
|
+
let jsdoc = "";
|
|
73564
|
+
if (definition.description) {
|
|
73565
|
+
jsdoc = `
|
|
73566
|
+
/** ${definition.description.value} */`;
|
|
73567
|
+
}
|
|
73568
|
+
return `${jsdoc}
|
|
73730
73569
|
export declare const ${name}: {
|
|
73731
|
-
${values?.map(
|
|
73570
|
+
${values?.map(
|
|
73571
|
+
(value) => (value.description ? ` /** ${value.description.value} */
|
|
73572
|
+
` : "") + ` readonly ${value.name.value}: "${value.name.value}";`
|
|
73573
|
+
).join("\n")}
|
|
73732
73574
|
}
|
|
73733
|
-
|
|
73575
|
+
${jsdoc}
|
|
73734
73576
|
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
73735
73577
|
`;
|
|
73736
73578
|
}).join("");
|
|
@@ -73750,7 +73592,7 @@ async function schemaGenerator(config) {
|
|
|
73750
73592
|
await Promise.all([
|
|
73751
73593
|
fs_exports.writeFile(
|
|
73752
73594
|
config.definitionsSchemaPath,
|
|
73753
|
-
config.localSchema ?
|
|
73595
|
+
config.localSchema ? graphql23.printSchema(config.schema) : config.newSchema
|
|
73754
73596
|
),
|
|
73755
73597
|
fs_exports.writeFile(config.definitionsDocumentsPath, config.newDocuments),
|
|
73756
73598
|
definitionsGenerator(config)
|
|
@@ -75455,7 +75297,7 @@ function mergeGraphQLTypes2(typeSource, config) {
|
|
|
75455
75297
|
}
|
|
75456
75298
|
|
|
75457
75299
|
// src/codegen/transforms/schema.ts
|
|
75458
|
-
import * as
|
|
75300
|
+
import * as graphql24 from "graphql";
|
|
75459
75301
|
async function graphqlExtensions(config, documents) {
|
|
75460
75302
|
let internalSchema = `
|
|
75461
75303
|
enum CachePolicy {
|
|
@@ -75559,7 +75401,7 @@ ${config.configFile.features?.componentFields ? `
|
|
|
75559
75401
|
"""
|
|
75560
75402
|
@${config.componentFieldDirective} marks an inline fragment as the selection for a component field
|
|
75561
75403
|
"""
|
|
75562
|
-
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
|
|
75404
|
+
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
|
|
75563
75405
|
|
|
75564
75406
|
` : ""}
|
|
75565
75407
|
|
|
@@ -75570,7 +75412,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
75570
75412
|
}
|
|
75571
75413
|
internalSchema += plugin2.schema({ config });
|
|
75572
75414
|
}
|
|
75573
|
-
|
|
75415
|
+
let extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
|
|
75574
75416
|
return `
|
|
75575
75417
|
extend type ${parent2} {
|
|
75576
75418
|
${Object.entries(fields).map(([fieldName, field]) => {
|
|
@@ -75578,29 +75420,30 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
75578
75420
|
const args = fragmentArguments(config, "", field.parent);
|
|
75579
75421
|
if (args.length > 0) {
|
|
75580
75422
|
argString = "(" + args.map((arg) => {
|
|
75581
|
-
const typeName =
|
|
75423
|
+
const typeName = graphql24.print(arg.type);
|
|
75582
75424
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
75583
75425
|
}).join("\n") + ")";
|
|
75584
75426
|
}
|
|
75585
|
-
return `${fieldName}${argString}: ${config.componentScalar}
|
|
75427
|
+
return `${fieldName}${argString}: ${config.componentScalar}! @componentField(field: "${fieldName}")`;
|
|
75586
75428
|
}).join("\n")}
|
|
75587
75429
|
}
|
|
75588
75430
|
`;
|
|
75589
75431
|
}).join("\n");
|
|
75590
|
-
config.
|
|
75432
|
+
extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
75433
|
+
config.newSchema = graphql24.print(mergeTypeDefs2([internalSchema, config.newSchema]));
|
|
75591
75434
|
config.schemaString += extensions;
|
|
75592
|
-
config.schema =
|
|
75593
|
-
|
|
75594
|
-
mergeTypeDefs2([
|
|
75435
|
+
config.schema = graphql24.buildSchema(
|
|
75436
|
+
graphql24.print(
|
|
75437
|
+
mergeTypeDefs2([graphql24.printSchema(config.schema), internalSchema, extensions])
|
|
75595
75438
|
)
|
|
75596
75439
|
);
|
|
75597
75440
|
}
|
|
75598
75441
|
|
|
75599
75442
|
// src/codegen/transforms/typename.ts
|
|
75600
|
-
import * as
|
|
75443
|
+
import * as graphql25 from "graphql";
|
|
75601
75444
|
async function addTypename(config, documents) {
|
|
75602
75445
|
for (const doc of documents) {
|
|
75603
|
-
doc.document =
|
|
75446
|
+
doc.document = graphql25.visit(doc.document, {
|
|
75604
75447
|
Field(node, key, parent2, path3, ancestors) {
|
|
75605
75448
|
if (!node.selectionSet) {
|
|
75606
75449
|
return;
|
|
@@ -75612,7 +75455,7 @@ async function addTypename(config, documents) {
|
|
|
75612
75455
|
);
|
|
75613
75456
|
const field = type.getFields()[node.name.value];
|
|
75614
75457
|
const fieldType = unwrapType(config, field.type).type;
|
|
75615
|
-
if (
|
|
75458
|
+
if (graphql25.isInterfaceType(fieldType) || graphql25.isUnionType(fieldType)) {
|
|
75616
75459
|
return {
|
|
75617
75460
|
...node,
|
|
75618
75461
|
selectionSet: {
|
|
@@ -75620,9 +75463,9 @@ async function addTypename(config, documents) {
|
|
|
75620
75463
|
selections: [
|
|
75621
75464
|
...node.selectionSet.selections,
|
|
75622
75465
|
{
|
|
75623
|
-
kind:
|
|
75466
|
+
kind: graphql25.Kind.FIELD,
|
|
75624
75467
|
name: {
|
|
75625
|
-
kind:
|
|
75468
|
+
kind: graphql25.Kind.NAME,
|
|
75626
75469
|
value: "__typename"
|
|
75627
75470
|
}
|
|
75628
75471
|
}
|
|
@@ -75639,9 +75482,9 @@ async function addTypename(config, documents) {
|
|
|
75639
75482
|
selections: [
|
|
75640
75483
|
...node.selectionSet.selections,
|
|
75641
75484
|
{
|
|
75642
|
-
kind:
|
|
75485
|
+
kind: graphql25.Kind.FIELD,
|
|
75643
75486
|
name: {
|
|
75644
|
-
kind:
|
|
75487
|
+
kind: graphql25.Kind.NAME,
|
|
75645
75488
|
value: "__typename"
|
|
75646
75489
|
}
|
|
75647
75490
|
}
|
|
@@ -75654,10 +75497,10 @@ async function addTypename(config, documents) {
|
|
|
75654
75497
|
}
|
|
75655
75498
|
|
|
75656
75499
|
// src/codegen/transforms/addID.ts
|
|
75657
|
-
import * as
|
|
75500
|
+
import * as graphql26 from "graphql";
|
|
75658
75501
|
async function addID(config, documents) {
|
|
75659
75502
|
for (const doc of documents) {
|
|
75660
|
-
doc.document =
|
|
75503
|
+
doc.document = graphql26.visit(doc.document, {
|
|
75661
75504
|
Field(node, key, parent2, path3, ancestors) {
|
|
75662
75505
|
if (!node.selectionSet) {
|
|
75663
75506
|
return;
|
|
@@ -75695,7 +75538,7 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
75695
75538
|
if (!node.selectionSet || node.selectionSet.selections.length == 0) {
|
|
75696
75539
|
return;
|
|
75697
75540
|
}
|
|
75698
|
-
if (!
|
|
75541
|
+
if (!graphql26.isObjectType(fieldType) && !graphql26.isInterfaceType(fieldType)) {
|
|
75699
75542
|
return;
|
|
75700
75543
|
}
|
|
75701
75544
|
const keyFields = config.keyFieldsForType(fieldType.name);
|
|
@@ -75710,9 +75553,9 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
75710
75553
|
continue;
|
|
75711
75554
|
}
|
|
75712
75555
|
selections.push({
|
|
75713
|
-
kind:
|
|
75556
|
+
kind: graphql26.Kind.FIELD,
|
|
75714
75557
|
name: {
|
|
75715
|
-
kind:
|
|
75558
|
+
kind: graphql26.Kind.NAME,
|
|
75716
75559
|
value: keyField
|
|
75717
75560
|
}
|
|
75718
75561
|
});
|
|
@@ -75727,13 +75570,13 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
75727
75570
|
}
|
|
75728
75571
|
|
|
75729
75572
|
// src/codegen/transforms/componentFields.ts
|
|
75730
|
-
import * as
|
|
75573
|
+
import * as graphql27 from "graphql";
|
|
75731
75574
|
async function componentFields(config, documents) {
|
|
75732
75575
|
for (const document of documents) {
|
|
75733
|
-
const typeInfo = new
|
|
75734
|
-
document.document =
|
|
75576
|
+
const typeInfo = new graphql27.TypeInfo(config.schema);
|
|
75577
|
+
document.document = graphql27.visit(
|
|
75735
75578
|
document.document,
|
|
75736
|
-
|
|
75579
|
+
graphql27.visitWithTypeInfo(typeInfo, {
|
|
75737
75580
|
Field(node) {
|
|
75738
75581
|
const parentType = typeInfo.getParentType();
|
|
75739
75582
|
if (!parentType) {
|
|
@@ -75781,6 +75624,48 @@ async function componentFields(config, documents) {
|
|
|
75781
75624
|
}
|
|
75782
75625
|
}
|
|
75783
75626
|
|
|
75627
|
+
// src/codegen/transforms/runtimeScalars.ts
|
|
75628
|
+
import * as graphql28 from "graphql";
|
|
75629
|
+
async function addTypename2(config, documents) {
|
|
75630
|
+
for (const doc of documents) {
|
|
75631
|
+
doc.document = graphql28.visit(doc.document, {
|
|
75632
|
+
VariableDefinition(node) {
|
|
75633
|
+
const { type, wrappers } = unwrapType(config, node.type);
|
|
75634
|
+
const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
|
|
75635
|
+
if (runtimeScalar) {
|
|
75636
|
+
return {
|
|
75637
|
+
...node,
|
|
75638
|
+
type: wrapType({
|
|
75639
|
+
type: config.schema.getType(runtimeScalar.type),
|
|
75640
|
+
wrappers
|
|
75641
|
+
}),
|
|
75642
|
+
directives: [
|
|
75643
|
+
...node.directives ?? [],
|
|
75644
|
+
{
|
|
75645
|
+
kind: "Directive",
|
|
75646
|
+
name: {
|
|
75647
|
+
kind: "Name",
|
|
75648
|
+
value: config.runtimeScalarDirective
|
|
75649
|
+
},
|
|
75650
|
+
arguments: [
|
|
75651
|
+
{
|
|
75652
|
+
kind: "Argument",
|
|
75653
|
+
name: { kind: "Name", value: "type" },
|
|
75654
|
+
value: {
|
|
75655
|
+
kind: "StringValue",
|
|
75656
|
+
value: type.name
|
|
75657
|
+
}
|
|
75658
|
+
}
|
|
75659
|
+
]
|
|
75660
|
+
}
|
|
75661
|
+
]
|
|
75662
|
+
};
|
|
75663
|
+
}
|
|
75664
|
+
}
|
|
75665
|
+
});
|
|
75666
|
+
}
|
|
75667
|
+
}
|
|
75668
|
+
|
|
75784
75669
|
// src/codegen/validators/typeCheck.ts
|
|
75785
75670
|
import * as graphql29 from "graphql";
|
|
75786
75671
|
async function typeCheck(config, docs) {
|
|
@@ -76782,10 +76667,22 @@ async function componentFields2(config, docs) {
|
|
|
76782
76667
|
}
|
|
76783
76668
|
const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
|
|
76784
76669
|
const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
|
|
76670
|
+
const existingField = fieldValue && config.componentFields[parent2]?.[fieldValue];
|
|
76785
76671
|
const parentType = config.schema.getType(parent2);
|
|
76786
|
-
|
|
76672
|
+
let conflict = false;
|
|
76673
|
+
if (existingField && existingField.filepath !== filepath) {
|
|
76674
|
+
conflict = true;
|
|
76675
|
+
} else if (parentType && fieldValue) {
|
|
76676
|
+
const fieldDef = graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
76677
|
+
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
76678
|
+
(dir) => dir.name.value === config.componentFieldDirective
|
|
76679
|
+
)) {
|
|
76680
|
+
conflict = true;
|
|
76681
|
+
}
|
|
76682
|
+
}
|
|
76683
|
+
if (conflict) {
|
|
76787
76684
|
errors.push({
|
|
76788
|
-
message: `Duplicate component field definition for ${parent2}.${fieldValue}
|
|
76685
|
+
message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
|
|
76789
76686
|
filepath
|
|
76790
76687
|
});
|
|
76791
76688
|
}
|
|
@@ -76855,6 +76752,7 @@ async function runPipeline2(config, docs) {
|
|
|
76855
76752
|
[
|
|
76856
76753
|
componentFields2,
|
|
76857
76754
|
graphqlExtensions,
|
|
76755
|
+
addTypename2,
|
|
76858
76756
|
...wrapHook(beforeValidate),
|
|
76859
76757
|
typeCheck,
|
|
76860
76758
|
uniqueDocumentNames,
|
|
@@ -77999,7 +77897,7 @@ export default app
|
|
|
77999
77897
|
async function svelteConfig(targetPath, typescript) {
|
|
78000
77898
|
const svelteConfigPath = path_exports.join(targetPath, "svelte.config.js");
|
|
78001
77899
|
const newContentTs = `import adapter from '@sveltejs/adapter-auto';
|
|
78002
|
-
import { vitePreprocess } from '@sveltejs/
|
|
77900
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
78003
77901
|
|
|
78004
77902
|
/** @type {import('@sveltejs/kit').Config} */
|
|
78005
77903
|
const config = {
|
|
@@ -78130,12 +78028,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
78130
78028
|
}
|
|
78131
78029
|
packageJSON2.devDependencies = {
|
|
78132
78030
|
...packageJSON2.devDependencies,
|
|
78133
|
-
houdini: "^1.2.
|
|
78031
|
+
houdini: "^1.2.45"
|
|
78134
78032
|
};
|
|
78135
78033
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
78136
78034
|
packageJSON2.devDependencies = {
|
|
78137
78035
|
...packageJSON2.devDependencies,
|
|
78138
|
-
"houdini-svelte": "^1.2.
|
|
78036
|
+
"houdini-svelte": "^1.2.45"
|
|
78139
78037
|
};
|
|
78140
78038
|
} else {
|
|
78141
78039
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|