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/test-esm/index.js
CHANGED
|
@@ -24851,7 +24851,7 @@ var require_path_visitor = __commonJS({
|
|
|
24851
24851
|
}
|
|
24852
24852
|
return target;
|
|
24853
24853
|
}
|
|
24854
|
-
PathVisitor.visit = function
|
|
24854
|
+
PathVisitor.visit = function visit19(node, methods) {
|
|
24855
24855
|
return PathVisitor.fromMethodsObject(methods).visit(node);
|
|
24856
24856
|
};
|
|
24857
24857
|
var PVp = PathVisitor.prototype;
|
|
@@ -25042,7 +25042,7 @@ var require_path_visitor = __commonJS({
|
|
|
25042
25042
|
this.needToCallTraverse = false;
|
|
25043
25043
|
return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
|
|
25044
25044
|
};
|
|
25045
|
-
sharedContextProtoMethods.visit = function
|
|
25045
|
+
sharedContextProtoMethods.visit = function visit19(path2, newVisitor) {
|
|
25046
25046
|
if (!(this instanceof this.Context)) {
|
|
25047
25047
|
throw new Error("");
|
|
25048
25048
|
}
|
|
@@ -26435,7 +26435,7 @@ var require_main = __commonJS({
|
|
|
26435
26435
|
var someField = _a.someField;
|
|
26436
26436
|
var Type = _a.Type;
|
|
26437
26437
|
var use = _a.use;
|
|
26438
|
-
var
|
|
26438
|
+
var visit19 = _a.visit;
|
|
26439
26439
|
exports.astNodesAreEquivalent = astNodesAreEquivalent;
|
|
26440
26440
|
exports.builders = builders;
|
|
26441
26441
|
exports.builtInTypes = builtInTypes;
|
|
@@ -26452,7 +26452,7 @@ var require_main = __commonJS({
|
|
|
26452
26452
|
exports.someField = someField;
|
|
26453
26453
|
exports.Type = Type;
|
|
26454
26454
|
exports.use = use;
|
|
26455
|
-
exports.visit =
|
|
26455
|
+
exports.visit = visit19;
|
|
26456
26456
|
Object.assign(namedTypes_1.namedTypes, n);
|
|
26457
26457
|
}
|
|
26458
26458
|
});
|
|
@@ -53972,47 +53972,6 @@ function deepMerge(...objects) {
|
|
|
53972
53972
|
return mergedObj;
|
|
53973
53973
|
}
|
|
53974
53974
|
|
|
53975
|
-
// src/runtime/lib/scalars.ts
|
|
53976
|
-
async function marshalSelection({
|
|
53977
|
-
selection,
|
|
53978
|
-
data
|
|
53979
|
-
}) {
|
|
53980
|
-
const config = getCurrentConfig();
|
|
53981
|
-
if (data === null || typeof data === "undefined") {
|
|
53982
|
-
return data;
|
|
53983
|
-
}
|
|
53984
|
-
if (Array.isArray(data)) {
|
|
53985
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
53986
|
-
}
|
|
53987
|
-
const targetSelection = getFieldsForType(selection, data["__typename"], false);
|
|
53988
|
-
return Object.fromEntries(
|
|
53989
|
-
await Promise.all(
|
|
53990
|
-
Object.entries(data).map(async ([fieldName, value]) => {
|
|
53991
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
53992
|
-
if (!type) {
|
|
53993
|
-
return [fieldName, value];
|
|
53994
|
-
}
|
|
53995
|
-
if (selection2) {
|
|
53996
|
-
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
53997
|
-
}
|
|
53998
|
-
if (config.scalars?.[type]) {
|
|
53999
|
-
const marshalFn = config.scalars[type].marshal;
|
|
54000
|
-
if (!marshalFn) {
|
|
54001
|
-
throw new Error(
|
|
54002
|
-
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
54003
|
-
);
|
|
54004
|
-
}
|
|
54005
|
-
if (Array.isArray(value)) {
|
|
54006
|
-
return [fieldName, value.map(marshalFn)];
|
|
54007
|
-
}
|
|
54008
|
-
return [fieldName, marshalFn(value)];
|
|
54009
|
-
}
|
|
54010
|
-
return [fieldName, value];
|
|
54011
|
-
})
|
|
54012
|
-
)
|
|
54013
|
-
);
|
|
54014
|
-
}
|
|
54015
|
-
|
|
54016
53975
|
// src/runtime/lib/types.ts
|
|
54017
53976
|
var CachePolicy = {
|
|
54018
53977
|
CacheOrNetwork: "CacheOrNetwork",
|
|
@@ -54040,11 +53999,6 @@ var RefetchUpdateMode = {
|
|
|
54040
53999
|
prepend: "prepend",
|
|
54041
54000
|
replace: "replace"
|
|
54042
54001
|
};
|
|
54043
|
-
var DataSource = {
|
|
54044
|
-
Cache: "cache",
|
|
54045
|
-
Network: "network",
|
|
54046
|
-
Ssr: "ssr"
|
|
54047
|
-
};
|
|
54048
54002
|
var fragmentKey = " $fragments";
|
|
54049
54003
|
var PendingValue = Symbol("houdini_loading");
|
|
54050
54004
|
|
|
@@ -56666,188 +56620,6 @@ var cache_default = new Cache();
|
|
|
56666
56620
|
// src/runtime/client/plugins/cache.ts
|
|
56667
56621
|
var serverSide = typeof globalThis.window === "undefined";
|
|
56668
56622
|
|
|
56669
|
-
// src/runtime/client/utils/documentPlugins.ts
|
|
56670
|
-
var documentPlugin = (kind, source) => {
|
|
56671
|
-
return () => {
|
|
56672
|
-
const sourceHandlers = source();
|
|
56673
|
-
const enterWrapper = (handler) => {
|
|
56674
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
56675
|
-
if (ctx.artifact.kind !== kind) {
|
|
56676
|
-
return handlers.next(ctx);
|
|
56677
|
-
}
|
|
56678
|
-
return handler(ctx, handlers);
|
|
56679
|
-
};
|
|
56680
|
-
};
|
|
56681
|
-
const exitWrapper = (handler) => {
|
|
56682
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
56683
|
-
if (ctx.artifact.kind !== kind) {
|
|
56684
|
-
return handlers.resolve(ctx);
|
|
56685
|
-
}
|
|
56686
|
-
return handler(ctx, handlers);
|
|
56687
|
-
};
|
|
56688
|
-
};
|
|
56689
|
-
return {
|
|
56690
|
-
start: enterWrapper(sourceHandlers.start),
|
|
56691
|
-
network: enterWrapper(sourceHandlers.network),
|
|
56692
|
-
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
56693
|
-
end: exitWrapper(sourceHandlers.end),
|
|
56694
|
-
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
56695
|
-
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
56696
|
-
};
|
|
56697
|
-
};
|
|
56698
|
-
};
|
|
56699
|
-
|
|
56700
|
-
// src/runtime/client/plugins/query.ts
|
|
56701
|
-
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
56702
|
-
let subscriptionSpec = null;
|
|
56703
|
-
let lastVariables = null;
|
|
56704
|
-
return {
|
|
56705
|
-
start(ctx, { next }) {
|
|
56706
|
-
ctx.variables = {
|
|
56707
|
-
...lastVariables,
|
|
56708
|
-
...ctx.variables
|
|
56709
|
-
};
|
|
56710
|
-
next(ctx);
|
|
56711
|
-
},
|
|
56712
|
-
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
56713
|
-
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56714
|
-
if (subscriptionSpec) {
|
|
56715
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56716
|
-
}
|
|
56717
|
-
lastVariables = { ...marshalVariables(ctx) };
|
|
56718
|
-
const variables = lastVariables;
|
|
56719
|
-
subscriptionSpec = {
|
|
56720
|
-
rootType: ctx.artifact.rootType,
|
|
56721
|
-
selection: ctx.artifact.selection,
|
|
56722
|
-
variables: () => variables,
|
|
56723
|
-
set: (newValue) => {
|
|
56724
|
-
resolve2(ctx, {
|
|
56725
|
-
data: newValue,
|
|
56726
|
-
errors: null,
|
|
56727
|
-
fetching: false,
|
|
56728
|
-
partial: false,
|
|
56729
|
-
stale: false,
|
|
56730
|
-
source: DataSource.Cache,
|
|
56731
|
-
variables: ctx.variables ?? {}
|
|
56732
|
-
});
|
|
56733
|
-
}
|
|
56734
|
-
};
|
|
56735
|
-
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
56736
|
-
}
|
|
56737
|
-
resolve2(ctx);
|
|
56738
|
-
},
|
|
56739
|
-
cleanup() {
|
|
56740
|
-
if (subscriptionSpec) {
|
|
56741
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56742
|
-
lastVariables = null;
|
|
56743
|
-
}
|
|
56744
|
-
}
|
|
56745
|
-
};
|
|
56746
|
-
});
|
|
56747
|
-
|
|
56748
|
-
// src/runtime/client/plugins/fragment.ts
|
|
56749
|
-
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
56750
|
-
let subscriptionSpec = null;
|
|
56751
|
-
let lastReference = null;
|
|
56752
|
-
return {
|
|
56753
|
-
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
56754
|
-
if (!ctx.stuff.parentID) {
|
|
56755
|
-
return next(ctx);
|
|
56756
|
-
}
|
|
56757
|
-
const currentReference = {
|
|
56758
|
-
parent: ctx.stuff.parentID,
|
|
56759
|
-
variables: marshalVariables(ctx)
|
|
56760
|
-
};
|
|
56761
|
-
if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
56762
|
-
if (subscriptionSpec) {
|
|
56763
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56764
|
-
}
|
|
56765
|
-
const variables = marshalVariables(ctx);
|
|
56766
|
-
subscriptionSpec = {
|
|
56767
|
-
rootType: ctx.artifact.rootType,
|
|
56768
|
-
selection: ctx.artifact.selection,
|
|
56769
|
-
variables: () => variables,
|
|
56770
|
-
parentID: ctx.stuff.parentID,
|
|
56771
|
-
set: (newValue) => {
|
|
56772
|
-
resolve2(ctx, {
|
|
56773
|
-
data: newValue,
|
|
56774
|
-
errors: null,
|
|
56775
|
-
fetching: false,
|
|
56776
|
-
partial: false,
|
|
56777
|
-
stale: false,
|
|
56778
|
-
source: DataSource.Cache,
|
|
56779
|
-
variables
|
|
56780
|
-
});
|
|
56781
|
-
}
|
|
56782
|
-
};
|
|
56783
|
-
cache_default.subscribe(subscriptionSpec, variables);
|
|
56784
|
-
lastReference = currentReference;
|
|
56785
|
-
}
|
|
56786
|
-
next(ctx);
|
|
56787
|
-
},
|
|
56788
|
-
cleanup() {
|
|
56789
|
-
if (subscriptionSpec) {
|
|
56790
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56791
|
-
}
|
|
56792
|
-
}
|
|
56793
|
-
};
|
|
56794
|
-
});
|
|
56795
|
-
|
|
56796
|
-
// src/runtime/client/plugins/mutation.ts
|
|
56797
|
-
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56798
|
-
return {
|
|
56799
|
-
async start(ctx, { next, marshalVariables }) {
|
|
56800
|
-
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
56801
|
-
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
56802
|
-
let toNotify = [];
|
|
56803
|
-
if (optimisticResponse) {
|
|
56804
|
-
toNotify = cache_default.write({
|
|
56805
|
-
selection: ctx.artifact.selection,
|
|
56806
|
-
data: await marshalSelection({
|
|
56807
|
-
selection: ctx.artifact.selection,
|
|
56808
|
-
data: optimisticResponse
|
|
56809
|
-
}),
|
|
56810
|
-
variables: marshalVariables(ctx),
|
|
56811
|
-
layer: layerOptimistic.id
|
|
56812
|
-
});
|
|
56813
|
-
}
|
|
56814
|
-
ctx.cacheParams = {
|
|
56815
|
-
...ctx.cacheParams,
|
|
56816
|
-
layer: layerOptimistic,
|
|
56817
|
-
notifySubscribers: toNotify,
|
|
56818
|
-
forceNotify: true
|
|
56819
|
-
};
|
|
56820
|
-
next(ctx);
|
|
56821
|
-
},
|
|
56822
|
-
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
56823
|
-
if (ctx.cacheParams?.layer) {
|
|
56824
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56825
|
-
}
|
|
56826
|
-
resolve2(ctx);
|
|
56827
|
-
},
|
|
56828
|
-
end(ctx, { resolve: resolve2, value }) {
|
|
56829
|
-
const hasErrors = value.errors && value.errors.length > 0;
|
|
56830
|
-
if (hasErrors) {
|
|
56831
|
-
if (ctx.cacheParams?.layer) {
|
|
56832
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56833
|
-
}
|
|
56834
|
-
}
|
|
56835
|
-
if (ctx.cacheParams?.layer) {
|
|
56836
|
-
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
56837
|
-
}
|
|
56838
|
-
resolve2(ctx);
|
|
56839
|
-
},
|
|
56840
|
-
catch(ctx, { error }) {
|
|
56841
|
-
if (ctx.cacheParams?.layer) {
|
|
56842
|
-
const { layer } = ctx.cacheParams;
|
|
56843
|
-
cache_default.clearLayer(layer.id);
|
|
56844
|
-
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
56845
|
-
}
|
|
56846
|
-
throw error;
|
|
56847
|
-
}
|
|
56848
|
-
};
|
|
56849
|
-
});
|
|
56850
|
-
|
|
56851
56623
|
// src/lib/types.ts
|
|
56852
56624
|
var LogLevel = {
|
|
56853
56625
|
Full: "full",
|
|
@@ -57284,6 +57056,9 @@ var Config = class {
|
|
|
57284
57056
|
get loadingDirective() {
|
|
57285
57057
|
return `loading`;
|
|
57286
57058
|
}
|
|
57059
|
+
get runtimeScalarDirective() {
|
|
57060
|
+
return "__houdini__runtimeScalar";
|
|
57061
|
+
}
|
|
57287
57062
|
get whenDirective() {
|
|
57288
57063
|
return "when";
|
|
57289
57064
|
}
|
|
@@ -57354,7 +57129,7 @@ var Config = class {
|
|
|
57354
57129
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
57355
57130
|
return list.concat(directive.name);
|
|
57356
57131
|
}, []) ?? [];
|
|
57357
|
-
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
57132
|
+
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name) || name === this.runtimeScalarDirective);
|
|
57358
57133
|
}
|
|
57359
57134
|
get componentFieldDirective() {
|
|
57360
57135
|
return "componentField";
|
|
@@ -57619,7 +57394,7 @@ function definitionFromAncestors(ancestors) {
|
|
|
57619
57394
|
}
|
|
57620
57395
|
return { parents, definition };
|
|
57621
57396
|
}
|
|
57622
|
-
function unwrapType(config, type, wrappers = []) {
|
|
57397
|
+
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
57623
57398
|
if (type.kind === "NonNullType") {
|
|
57624
57399
|
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
57625
57400
|
}
|
|
@@ -57635,9 +57410,14 @@ function unwrapType(config, type, wrappers = []) {
|
|
|
57635
57410
|
if (type instanceof graphql3.GraphQLList) {
|
|
57636
57411
|
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
57637
57412
|
}
|
|
57413
|
+
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
57414
|
+
type = config.schema.getType(
|
|
57415
|
+
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
57416
|
+
);
|
|
57417
|
+
}
|
|
57638
57418
|
const namedType = config.schema.getType(type.name.value || type.name);
|
|
57639
57419
|
if (!namedType) {
|
|
57640
|
-
throw new Error("
|
|
57420
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
57641
57421
|
}
|
|
57642
57422
|
return { type: namedType, wrappers };
|
|
57643
57423
|
}
|
|
@@ -57774,16 +57554,162 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
57774
57554
|
return allFilesNotInList;
|
|
57775
57555
|
}
|
|
57776
57556
|
|
|
57777
|
-
// src/lib/
|
|
57557
|
+
// src/lib/typescript.ts
|
|
57558
|
+
var recast2 = __toESM(require_main2(), 1);
|
|
57778
57559
|
import * as graphql4 from "graphql";
|
|
57560
|
+
var AST2 = recast2.types.builders;
|
|
57561
|
+
function unwrappedTsTypeReference(config, filepath, missingScalars, {
|
|
57562
|
+
type,
|
|
57563
|
+
wrappers
|
|
57564
|
+
}, body) {
|
|
57565
|
+
let result;
|
|
57566
|
+
if (graphql4.isScalarType(type)) {
|
|
57567
|
+
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
57568
|
+
} else if (graphql4.isEnumType(type)) {
|
|
57569
|
+
result = enumReference(config, body, type.name);
|
|
57570
|
+
} else {
|
|
57571
|
+
result = AST2.tsTypeReference(AST2.identifier(type.name));
|
|
57572
|
+
}
|
|
57573
|
+
for (const toWrap of wrappers) {
|
|
57574
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
57575
|
+
continue;
|
|
57576
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
57577
|
+
result = nullableField(result, true);
|
|
57578
|
+
} else if (toWrap === "List" /* List */) {
|
|
57579
|
+
result = AST2.tsArrayType(AST2.tsParenthesizedType(result));
|
|
57580
|
+
}
|
|
57581
|
+
}
|
|
57582
|
+
return result;
|
|
57583
|
+
}
|
|
57584
|
+
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
57585
|
+
const { type, wrappers } = unwrapType(config, definition.type);
|
|
57586
|
+
return unwrappedTsTypeReference(
|
|
57587
|
+
config,
|
|
57588
|
+
filepath,
|
|
57589
|
+
missingScalars,
|
|
57590
|
+
{ type, wrappers },
|
|
57591
|
+
body
|
|
57592
|
+
);
|
|
57593
|
+
}
|
|
57594
|
+
function enumReference(config, body, name) {
|
|
57595
|
+
ensureImports({
|
|
57596
|
+
config,
|
|
57597
|
+
body,
|
|
57598
|
+
import: ["ValueOf"],
|
|
57599
|
+
importKind: "type",
|
|
57600
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
57601
|
+
});
|
|
57602
|
+
return AST2.tsTypeReference(
|
|
57603
|
+
AST2.identifier("ValueOf"),
|
|
57604
|
+
AST2.tsTypeParameterInstantiation([AST2.tsTypeQuery(AST2.identifier(name))])
|
|
57605
|
+
);
|
|
57606
|
+
}
|
|
57607
|
+
function readonlyProperty(prop, enable = true) {
|
|
57608
|
+
if (enable) {
|
|
57609
|
+
prop.readonly = true;
|
|
57610
|
+
}
|
|
57611
|
+
return prop;
|
|
57612
|
+
}
|
|
57613
|
+
function nullableField(inner, input = false) {
|
|
57614
|
+
const members = [inner, AST2.tsNullKeyword()];
|
|
57615
|
+
if (input) {
|
|
57616
|
+
members.push(AST2.tsUndefinedKeyword());
|
|
57617
|
+
}
|
|
57618
|
+
return AST2.tsUnionType(members);
|
|
57619
|
+
}
|
|
57620
|
+
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
57621
|
+
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
57622
|
+
if (!field) {
|
|
57623
|
+
return AST2.tsNeverKeyword();
|
|
57624
|
+
}
|
|
57625
|
+
const component = config.componentFields[field.parent][field.field];
|
|
57626
|
+
const sourcePathRelative = path_exports.relative(
|
|
57627
|
+
path_exports.join(config.projectRoot, "src"),
|
|
57628
|
+
component.filepath
|
|
57629
|
+
);
|
|
57630
|
+
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
57631
|
+
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
57632
|
+
const localImport = ensureImports({
|
|
57633
|
+
config,
|
|
57634
|
+
body,
|
|
57635
|
+
import: "__component__" + component.fragment,
|
|
57636
|
+
sourceModule: path_exports.join(
|
|
57637
|
+
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
57638
|
+
"src",
|
|
57639
|
+
sourcePath
|
|
57640
|
+
)
|
|
57641
|
+
}) ?? "__component__" + component.fragment;
|
|
57642
|
+
const parameters = AST2.tsTypeReference(AST2.identifier("Parameters"));
|
|
57643
|
+
parameters.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
57644
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
57645
|
+
]);
|
|
57646
|
+
const indexed = AST2.tsIndexedAccessType(
|
|
57647
|
+
parameters,
|
|
57648
|
+
AST2.tsLiteralType(AST2.numericLiteral(0))
|
|
57649
|
+
);
|
|
57650
|
+
const omit = AST2.tsTypeReference(AST2.identifier("Omit"));
|
|
57651
|
+
omit.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
57652
|
+
indexed,
|
|
57653
|
+
AST2.tsLiteralType(AST2.stringLiteral(component.prop))
|
|
57654
|
+
]);
|
|
57655
|
+
const arg = AST2.identifier("props");
|
|
57656
|
+
arg.typeAnnotation = AST2.tsTypeAnnotation(omit);
|
|
57657
|
+
const returnType = AST2.tsTypeReference(AST2.identifier("ReturnType"));
|
|
57658
|
+
returnType.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
57659
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
57660
|
+
]);
|
|
57661
|
+
const fnType = AST2.tsFunctionType([arg]);
|
|
57662
|
+
fnType.typeAnnotation = AST2.tsTypeAnnotation(returnType);
|
|
57663
|
+
return fnType;
|
|
57664
|
+
}
|
|
57665
|
+
switch (target.name) {
|
|
57666
|
+
case "String": {
|
|
57667
|
+
return AST2.tsStringKeyword();
|
|
57668
|
+
}
|
|
57669
|
+
case "Int": {
|
|
57670
|
+
return AST2.tsNumberKeyword();
|
|
57671
|
+
}
|
|
57672
|
+
case "Float": {
|
|
57673
|
+
return AST2.tsNumberKeyword();
|
|
57674
|
+
}
|
|
57675
|
+
case "Boolean": {
|
|
57676
|
+
return AST2.tsBooleanKeyword();
|
|
57677
|
+
}
|
|
57678
|
+
case "ID": {
|
|
57679
|
+
return AST2.tsStringKeyword();
|
|
57680
|
+
}
|
|
57681
|
+
default: {
|
|
57682
|
+
if (graphql4.isNonNullType(target) && "ofType" in target) {
|
|
57683
|
+
return scalarPropertyValue(
|
|
57684
|
+
config,
|
|
57685
|
+
filepath,
|
|
57686
|
+
missingScalars,
|
|
57687
|
+
target.ofType,
|
|
57688
|
+
body,
|
|
57689
|
+
field
|
|
57690
|
+
);
|
|
57691
|
+
}
|
|
57692
|
+
if (config.scalars?.[target.name]) {
|
|
57693
|
+
return AST2.tsTypeReference(AST2.identifier(config.scalars?.[target.name].type));
|
|
57694
|
+
}
|
|
57695
|
+
if (target.name !== config.componentScalar) {
|
|
57696
|
+
missingScalars.add(target.name);
|
|
57697
|
+
}
|
|
57698
|
+
return AST2.tsAnyKeyword();
|
|
57699
|
+
}
|
|
57700
|
+
}
|
|
57701
|
+
}
|
|
57702
|
+
|
|
57703
|
+
// src/lib/walk.ts
|
|
57704
|
+
import * as graphql5 from "graphql";
|
|
57779
57705
|
|
|
57780
57706
|
// src/lib/router/manifest.ts
|
|
57781
57707
|
var t = __toESM(require_lib6(), 1);
|
|
57782
|
-
import * as
|
|
57708
|
+
import * as graphql6 from "graphql";
|
|
57783
57709
|
|
|
57784
57710
|
// src/codegen/generators/artifacts/index.ts
|
|
57785
|
-
var
|
|
57786
|
-
import * as
|
|
57711
|
+
var recast5 = __toESM(require_main2(), 1);
|
|
57712
|
+
import * as graphql17 from "graphql";
|
|
57787
57713
|
|
|
57788
57714
|
// src/codegen/utils/commonjs.ts
|
|
57789
57715
|
var cjsIndexFilePreamble = `"use strict";
|
|
@@ -58025,19 +57951,19 @@ var FieldCollection = class {
|
|
|
58025
57951
|
};
|
|
58026
57952
|
|
|
58027
57953
|
// src/codegen/utils/moduleExport.ts
|
|
58028
|
-
var
|
|
58029
|
-
var
|
|
57954
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
57955
|
+
var AST3 = recast3.types.builders;
|
|
58030
57956
|
function moduleExport(config, key, value) {
|
|
58031
57957
|
if (config.module === "commonjs") {
|
|
58032
|
-
let target =
|
|
57958
|
+
let target = AST3.memberExpression(AST3.identifier("module"), AST3.identifier("exports"));
|
|
58033
57959
|
if (key !== "default") {
|
|
58034
|
-
target =
|
|
57960
|
+
target = AST3.memberExpression(target, AST3.identifier(key));
|
|
58035
57961
|
}
|
|
58036
|
-
return
|
|
57962
|
+
return AST3.expressionStatement(AST3.assignmentExpression("=", target, value));
|
|
58037
57963
|
}
|
|
58038
|
-
return key === "default" ?
|
|
58039
|
-
|
|
58040
|
-
|
|
57964
|
+
return key === "default" ? AST3.exportDefaultDeclaration(value) : AST3.exportNamedDeclaration(
|
|
57965
|
+
AST3.variableDeclaration("const", [
|
|
57966
|
+
AST3.variableDeclarator(AST3.identifier(key), value)
|
|
58041
57967
|
])
|
|
58042
57968
|
);
|
|
58043
57969
|
}
|
|
@@ -58294,7 +58220,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
58294
58220
|
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));
|
|
58295
58221
|
|
|
58296
58222
|
// src/codegen/transforms/fragmentVariables.ts
|
|
58297
|
-
import * as
|
|
58223
|
+
import * as graphql8 from "graphql";
|
|
58298
58224
|
|
|
58299
58225
|
// src/codegen/utils/stripLoc.ts
|
|
58300
58226
|
function stripLoc(value) {
|
|
@@ -58315,7 +58241,7 @@ function stripLoc(value) {
|
|
|
58315
58241
|
}
|
|
58316
58242
|
|
|
58317
58243
|
// src/codegen/transforms/collectDefinitions.ts
|
|
58318
|
-
import * as
|
|
58244
|
+
import * as graphql7 from "graphql";
|
|
58319
58245
|
import { Kind as GraphqlKinds } from "graphql";
|
|
58320
58246
|
async function includeFragmentDefinitions(config, documents) {
|
|
58321
58247
|
const fragments = collectDefinitions(config, documents);
|
|
@@ -58365,10 +58291,10 @@ function collectDefinitions(config, docs) {
|
|
|
58365
58291
|
}
|
|
58366
58292
|
function findRequiredFragments(config, definition) {
|
|
58367
58293
|
const referencedFragments = [];
|
|
58368
|
-
const typeInfo = new
|
|
58369
|
-
definition.selectionSet =
|
|
58294
|
+
const typeInfo = new graphql7.TypeInfo(config.schema);
|
|
58295
|
+
definition.selectionSet = graphql7.visit(
|
|
58370
58296
|
definition,
|
|
58371
|
-
|
|
58297
|
+
graphql7.visitWithTypeInfo(typeInfo, {
|
|
58372
58298
|
FragmentSpread(node) {
|
|
58373
58299
|
referencedFragments.push(node.name.value);
|
|
58374
58300
|
}
|
|
@@ -58402,7 +58328,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
58402
58328
|
}
|
|
58403
58329
|
|
|
58404
58330
|
// src/codegen/transforms/fragmentVariables.ts
|
|
58405
|
-
var GraphqlKinds2 =
|
|
58331
|
+
var GraphqlKinds2 = graphql8.Kind;
|
|
58406
58332
|
async function fragmentVariables(config, documents) {
|
|
58407
58333
|
const fragments = collectDefinitions(config, documents);
|
|
58408
58334
|
const generatedFragments = {};
|
|
@@ -58425,7 +58351,7 @@ async function fragmentVariables(config, documents) {
|
|
|
58425
58351
|
});
|
|
58426
58352
|
}
|
|
58427
58353
|
const doc = {
|
|
58428
|
-
kind:
|
|
58354
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
58429
58355
|
definitions: Object.values(generatedFragments)
|
|
58430
58356
|
};
|
|
58431
58357
|
documents.push({
|
|
@@ -58496,7 +58422,7 @@ function inlineFragmentArgs({
|
|
|
58496
58422
|
return null;
|
|
58497
58423
|
};
|
|
58498
58424
|
const result = esm_default(
|
|
58499
|
-
|
|
58425
|
+
graphql8.visit(document, {
|
|
58500
58426
|
FragmentSpread(node) {
|
|
58501
58427
|
if (!fragmentDefinitions[node.name.value]) {
|
|
58502
58428
|
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
@@ -58582,7 +58508,7 @@ function inlineFragmentArgs({
|
|
|
58582
58508
|
);
|
|
58583
58509
|
if (newName) {
|
|
58584
58510
|
result.name = {
|
|
58585
|
-
kind:
|
|
58511
|
+
kind: graphql8.Kind.NAME,
|
|
58586
58512
|
value: newName
|
|
58587
58513
|
};
|
|
58588
58514
|
}
|
|
@@ -58749,8 +58675,8 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
58749
58675
|
}
|
|
58750
58676
|
|
|
58751
58677
|
// src/codegen/generators/artifacts/inputs.ts
|
|
58752
|
-
import * as
|
|
58753
|
-
function inputObject(config, inputs) {
|
|
58678
|
+
import * as graphql9 from "graphql";
|
|
58679
|
+
function inputObject(config, inputs, runtimeScalars) {
|
|
58754
58680
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
58755
58681
|
const inputObj = {
|
|
58756
58682
|
fields: inputs.reduce((fields, input) => {
|
|
@@ -58766,7 +58692,8 @@ function inputObject(config, inputs) {
|
|
|
58766
58692
|
...fields,
|
|
58767
58693
|
[input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
|
|
58768
58694
|
};
|
|
58769
|
-
}, {})
|
|
58695
|
+
}, {}),
|
|
58696
|
+
runtimeScalars
|
|
58770
58697
|
};
|
|
58771
58698
|
for (const input of inputs) {
|
|
58772
58699
|
walkInputs(config, visitedTypes, inputObj, input.type);
|
|
@@ -58778,10 +58705,10 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
58778
58705
|
if (visitedTypes.has(type.name)) {
|
|
58779
58706
|
return;
|
|
58780
58707
|
}
|
|
58781
|
-
if (
|
|
58708
|
+
if (graphql9.isEnumType(type) || graphql9.isScalarType(type)) {
|
|
58782
58709
|
return;
|
|
58783
58710
|
}
|
|
58784
|
-
if (
|
|
58711
|
+
if (graphql9.isUnionType(type)) {
|
|
58785
58712
|
return;
|
|
58786
58713
|
}
|
|
58787
58714
|
visitedTypes.add(type.name);
|
|
@@ -58799,50 +58726,50 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
58799
58726
|
}
|
|
58800
58727
|
|
|
58801
58728
|
// src/codegen/generators/artifacts/operations.ts
|
|
58802
|
-
import * as
|
|
58729
|
+
import * as graphql11 from "graphql";
|
|
58803
58730
|
|
|
58804
58731
|
// src/codegen/generators/artifacts/utils.ts
|
|
58805
|
-
var
|
|
58806
|
-
import * as
|
|
58807
|
-
var
|
|
58732
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
58733
|
+
import * as graphql10 from "graphql";
|
|
58734
|
+
var AST4 = recast4.types.builders;
|
|
58808
58735
|
function serializeValue(value) {
|
|
58809
58736
|
if (Array.isArray(value)) {
|
|
58810
|
-
return
|
|
58737
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
58811
58738
|
}
|
|
58812
58739
|
if (typeof value === "object" && value !== null) {
|
|
58813
|
-
return
|
|
58740
|
+
return AST4.objectExpression(
|
|
58814
58741
|
Object.entries(value).filter(([key, value2]) => typeof value2 !== "undefined").map(([key, val]) => {
|
|
58815
|
-
return
|
|
58742
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
58816
58743
|
})
|
|
58817
58744
|
);
|
|
58818
58745
|
}
|
|
58819
58746
|
if (typeof value === "string") {
|
|
58820
58747
|
if (value.indexOf("\n") !== -1) {
|
|
58821
|
-
return
|
|
58822
|
-
[
|
|
58748
|
+
return AST4.templateLiteral(
|
|
58749
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
58823
58750
|
[]
|
|
58824
58751
|
);
|
|
58825
58752
|
}
|
|
58826
|
-
return
|
|
58753
|
+
return AST4.stringLiteral(value);
|
|
58827
58754
|
}
|
|
58828
|
-
return
|
|
58755
|
+
return AST4.literal(value);
|
|
58829
58756
|
}
|
|
58830
58757
|
function convertValue(config, val) {
|
|
58831
58758
|
let value;
|
|
58832
58759
|
let kind;
|
|
58833
|
-
if (val.kind ===
|
|
58760
|
+
if (val.kind === graphql10.Kind.INT) {
|
|
58834
58761
|
value = parseInt(val.value, 10);
|
|
58835
58762
|
kind = "Int";
|
|
58836
|
-
} else if (val.kind ===
|
|
58763
|
+
} else if (val.kind === graphql10.Kind.FLOAT) {
|
|
58837
58764
|
value = parseFloat(val.value);
|
|
58838
58765
|
kind = "Float";
|
|
58839
|
-
} else if (val.kind ===
|
|
58766
|
+
} else if (val.kind === graphql10.Kind.BOOLEAN) {
|
|
58840
58767
|
value = val.value;
|
|
58841
58768
|
kind = "Boolean";
|
|
58842
|
-
} else if (val.kind ===
|
|
58769
|
+
} else if (val.kind === graphql10.Kind.VARIABLE) {
|
|
58843
58770
|
value = val.name.value;
|
|
58844
58771
|
kind = "Variable";
|
|
58845
|
-
} else if (val.kind ===
|
|
58772
|
+
} else if (val.kind === graphql10.Kind.STRING) {
|
|
58846
58773
|
value = val.value;
|
|
58847
58774
|
kind = "String";
|
|
58848
58775
|
}
|
|
@@ -58855,7 +58782,7 @@ function operationsByPath(config, filepath, definition, filterTypes) {
|
|
|
58855
58782
|
return {};
|
|
58856
58783
|
}
|
|
58857
58784
|
const pathOperations = {};
|
|
58858
|
-
|
|
58785
|
+
graphql11.visit(definition, {
|
|
58859
58786
|
FragmentSpread(node, _, __, ___, ancestors) {
|
|
58860
58787
|
if (!config.isListFragment(node.name.value)) {
|
|
58861
58788
|
return;
|
|
@@ -59014,19 +58941,19 @@ function ancestorKey(ancestors) {
|
|
|
59014
58941
|
}
|
|
59015
58942
|
|
|
59016
58943
|
// src/codegen/generators/artifacts/selection.ts
|
|
59017
|
-
import * as
|
|
58944
|
+
import * as graphql16 from "graphql";
|
|
59018
58945
|
|
|
59019
58946
|
// src/codegen/transforms/list.ts
|
|
59020
|
-
import * as
|
|
58947
|
+
import * as graphql14 from "graphql";
|
|
59021
58948
|
|
|
59022
58949
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
59023
|
-
import * as
|
|
58950
|
+
import * as graphql12 from "graphql";
|
|
59024
58951
|
var objectIdentificationSelection = (config, type) => {
|
|
59025
58952
|
return config.keyFieldsForType(type.name).map((key) => {
|
|
59026
58953
|
return {
|
|
59027
|
-
kind:
|
|
58954
|
+
kind: graphql12.Kind.FIELD,
|
|
59028
58955
|
name: {
|
|
59029
|
-
kind:
|
|
58956
|
+
kind: graphql12.Kind.NAME,
|
|
59030
58957
|
value: key
|
|
59031
58958
|
}
|
|
59032
58959
|
};
|
|
@@ -59034,7 +58961,7 @@ var objectIdentificationSelection = (config, type) => {
|
|
|
59034
58961
|
};
|
|
59035
58962
|
|
|
59036
58963
|
// src/codegen/transforms/paginate.ts
|
|
59037
|
-
import * as
|
|
58964
|
+
import * as graphql13 from "graphql";
|
|
59038
58965
|
async function paginate(config, documents) {
|
|
59039
58966
|
const newDocs = [];
|
|
59040
58967
|
for (const doc of documents) {
|
|
@@ -59067,7 +58994,7 @@ async function paginate(config, documents) {
|
|
|
59067
58994
|
};
|
|
59068
58995
|
let cursorType = "String";
|
|
59069
58996
|
let paginationPath = [];
|
|
59070
|
-
doc.document =
|
|
58997
|
+
doc.document = graphql13.visit(doc.document, {
|
|
59071
58998
|
Field(node, _, __, ___, ancestors) {
|
|
59072
58999
|
const paginateDirective = node.directives?.find(
|
|
59073
59000
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -59093,7 +59020,7 @@ async function paginate(config, documents) {
|
|
|
59093
59020
|
flags.offset.enabled = offsetPagination;
|
|
59094
59021
|
flags.limit.enabled = offsetPagination;
|
|
59095
59022
|
paginationPath = ancestors.filter(
|
|
59096
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
59023
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql13.Kind.FIELD
|
|
59097
59024
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
59098
59025
|
return {
|
|
59099
59026
|
...node,
|
|
@@ -59112,7 +59039,7 @@ async function paginate(config, documents) {
|
|
|
59112
59039
|
let fragment2 = "";
|
|
59113
59040
|
let paginateMode = config.defaultPaginateMode;
|
|
59114
59041
|
const requiredArgs = [];
|
|
59115
|
-
doc.document =
|
|
59042
|
+
doc.document = graphql13.visit(doc.document, {
|
|
59116
59043
|
OperationDefinition(node) {
|
|
59117
59044
|
if (node.operation !== "query") {
|
|
59118
59045
|
throw new HoudiniError({
|
|
@@ -59171,9 +59098,9 @@ async function paginate(config, documents) {
|
|
|
59171
59098
|
directives: [
|
|
59172
59099
|
...node.directives || [],
|
|
59173
59100
|
{
|
|
59174
|
-
kind:
|
|
59101
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
59175
59102
|
name: {
|
|
59176
|
-
kind:
|
|
59103
|
+
kind: graphql13.Kind.NAME,
|
|
59177
59104
|
value: config.argumentsDirective
|
|
59178
59105
|
}
|
|
59179
59106
|
}
|
|
@@ -59243,22 +59170,22 @@ async function paginate(config, documents) {
|
|
|
59243
59170
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
59244
59171
|
const fragmentSpreadSelection = [
|
|
59245
59172
|
{
|
|
59246
|
-
kind:
|
|
59173
|
+
kind: graphql13.Kind.FRAGMENT_SPREAD,
|
|
59247
59174
|
name: {
|
|
59248
|
-
kind:
|
|
59175
|
+
kind: graphql13.Kind.NAME,
|
|
59249
59176
|
value: fragmentName
|
|
59250
59177
|
},
|
|
59251
59178
|
directives: [
|
|
59252
59179
|
{
|
|
59253
|
-
kind:
|
|
59180
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
59254
59181
|
name: {
|
|
59255
|
-
kind:
|
|
59182
|
+
kind: graphql13.Kind.NAME,
|
|
59256
59183
|
value: config.withDirective
|
|
59257
59184
|
},
|
|
59258
59185
|
["arguments"]: requiredArgs.map((arg) => variableAsArgument(arg.name)).concat(paginationArgs.map(({ name }) => variableAsArgument(name)))
|
|
59259
59186
|
},
|
|
59260
59187
|
{
|
|
59261
|
-
kind:
|
|
59188
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
59262
59189
|
name: {
|
|
59263
59190
|
kind: "Name",
|
|
59264
59191
|
value: config.maskDisableDirective
|
|
@@ -59285,23 +59212,23 @@ async function paginate(config, documents) {
|
|
|
59285
59212
|
});
|
|
59286
59213
|
const typeConfig = config.typeConfig?.[fragment2];
|
|
59287
59214
|
const queryDoc = {
|
|
59288
|
-
kind:
|
|
59215
|
+
kind: graphql13.Kind.DOCUMENT,
|
|
59289
59216
|
definitions: [
|
|
59290
59217
|
{
|
|
59291
|
-
kind:
|
|
59218
|
+
kind: graphql13.Kind.OPERATION_DEFINITION,
|
|
59292
59219
|
name: {
|
|
59293
|
-
kind:
|
|
59220
|
+
kind: graphql13.Kind.NAME,
|
|
59294
59221
|
value: refetchQueryName
|
|
59295
59222
|
},
|
|
59296
59223
|
operation: "query",
|
|
59297
59224
|
variableDefinitions: requiredArgs.map(
|
|
59298
59225
|
(arg) => ({
|
|
59299
|
-
kind:
|
|
59226
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59300
59227
|
type: arg.type,
|
|
59301
59228
|
variable: {
|
|
59302
|
-
kind:
|
|
59229
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59303
59230
|
name: {
|
|
59304
|
-
kind:
|
|
59231
|
+
kind: graphql13.Kind.NAME,
|
|
59305
59232
|
value: arg.name
|
|
59306
59233
|
}
|
|
59307
59234
|
}
|
|
@@ -59309,18 +59236,18 @@ async function paginate(config, documents) {
|
|
|
59309
59236
|
).concat(
|
|
59310
59237
|
paginationArgs.map(
|
|
59311
59238
|
(arg) => ({
|
|
59312
|
-
kind:
|
|
59239
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59313
59240
|
type: {
|
|
59314
|
-
kind:
|
|
59241
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
59315
59242
|
name: {
|
|
59316
|
-
kind:
|
|
59243
|
+
kind: graphql13.Kind.NAME,
|
|
59317
59244
|
value: arg.type
|
|
59318
59245
|
}
|
|
59319
59246
|
},
|
|
59320
59247
|
variable: {
|
|
59321
|
-
kind:
|
|
59248
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59322
59249
|
name: {
|
|
59323
|
-
kind:
|
|
59250
|
+
kind: graphql13.Kind.NAME,
|
|
59324
59251
|
value: arg.name
|
|
59325
59252
|
}
|
|
59326
59253
|
},
|
|
@@ -59332,12 +59259,12 @@ async function paginate(config, documents) {
|
|
|
59332
59259
|
).concat(
|
|
59333
59260
|
!nodeQuery ? [] : keys2.map(
|
|
59334
59261
|
(key) => ({
|
|
59335
|
-
kind:
|
|
59262
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59336
59263
|
type: key.type,
|
|
59337
59264
|
variable: {
|
|
59338
|
-
kind:
|
|
59265
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59339
59266
|
name: {
|
|
59340
|
-
kind:
|
|
59267
|
+
kind: graphql13.Kind.NAME,
|
|
59341
59268
|
value: key.name
|
|
59342
59269
|
}
|
|
59343
59270
|
}
|
|
@@ -59346,42 +59273,42 @@ async function paginate(config, documents) {
|
|
|
59346
59273
|
)
|
|
59347
59274
|
),
|
|
59348
59275
|
selectionSet: {
|
|
59349
|
-
kind:
|
|
59276
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59350
59277
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
59351
59278
|
{
|
|
59352
|
-
kind:
|
|
59279
|
+
kind: graphql13.Kind.FIELD,
|
|
59353
59280
|
name: {
|
|
59354
|
-
kind:
|
|
59281
|
+
kind: graphql13.Kind.NAME,
|
|
59355
59282
|
value: typeConfig?.resolve?.queryField || "node"
|
|
59356
59283
|
},
|
|
59357
59284
|
["arguments"]: keys2.map((key) => ({
|
|
59358
|
-
kind:
|
|
59285
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59359
59286
|
name: {
|
|
59360
|
-
kind:
|
|
59287
|
+
kind: graphql13.Kind.NAME,
|
|
59361
59288
|
value: key.name
|
|
59362
59289
|
},
|
|
59363
59290
|
value: {
|
|
59364
|
-
kind:
|
|
59291
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59365
59292
|
name: {
|
|
59366
|
-
kind:
|
|
59293
|
+
kind: graphql13.Kind.NAME,
|
|
59367
59294
|
value: key.name
|
|
59368
59295
|
}
|
|
59369
59296
|
}
|
|
59370
59297
|
})),
|
|
59371
59298
|
selectionSet: {
|
|
59372
|
-
kind:
|
|
59299
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59373
59300
|
selections: [
|
|
59374
59301
|
{
|
|
59375
|
-
kind:
|
|
59302
|
+
kind: graphql13.Kind.FIELD,
|
|
59376
59303
|
name: {
|
|
59377
|
-
kind:
|
|
59304
|
+
kind: graphql13.Kind.NAME,
|
|
59378
59305
|
value: "__typename"
|
|
59379
59306
|
}
|
|
59380
59307
|
},
|
|
59381
59308
|
...(typeConfig?.keys || [config.defaultKeys[0]]).map((key) => ({
|
|
59382
|
-
kind:
|
|
59309
|
+
kind: graphql13.Kind.FIELD,
|
|
59383
59310
|
name: {
|
|
59384
|
-
kind:
|
|
59311
|
+
kind: graphql13.Kind.NAME,
|
|
59385
59312
|
value: key
|
|
59386
59313
|
}
|
|
59387
59314
|
})),
|
|
@@ -59438,15 +59365,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
59438
59365
|
}
|
|
59439
59366
|
function variableAsArgument(name, variable) {
|
|
59440
59367
|
return {
|
|
59441
|
-
kind:
|
|
59368
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59442
59369
|
name: {
|
|
59443
|
-
kind:
|
|
59370
|
+
kind: graphql13.Kind.NAME,
|
|
59444
59371
|
value: name
|
|
59445
59372
|
},
|
|
59446
59373
|
value: {
|
|
59447
|
-
kind:
|
|
59374
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59448
59375
|
name: {
|
|
59449
|
-
kind:
|
|
59376
|
+
kind: graphql13.Kind.NAME,
|
|
59450
59377
|
value: variable ?? name
|
|
59451
59378
|
}
|
|
59452
59379
|
}
|
|
@@ -59454,18 +59381,18 @@ function variableAsArgument(name, variable) {
|
|
|
59454
59381
|
}
|
|
59455
59382
|
function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
59456
59383
|
return {
|
|
59457
|
-
kind:
|
|
59384
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59458
59385
|
type: {
|
|
59459
|
-
kind:
|
|
59386
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
59460
59387
|
name: {
|
|
59461
|
-
kind:
|
|
59388
|
+
kind: graphql13.Kind.NAME,
|
|
59462
59389
|
value: type
|
|
59463
59390
|
}
|
|
59464
59391
|
},
|
|
59465
59392
|
variable: {
|
|
59466
|
-
kind:
|
|
59393
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59467
59394
|
name: {
|
|
59468
|
-
kind:
|
|
59395
|
+
kind: graphql13.Kind.NAME,
|
|
59469
59396
|
value: variableName ?? name
|
|
59470
59397
|
}
|
|
59471
59398
|
},
|
|
@@ -59477,9 +59404,9 @@ function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
|
59477
59404
|
}
|
|
59478
59405
|
function argumentNode(name, value) {
|
|
59479
59406
|
return {
|
|
59480
|
-
kind:
|
|
59407
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59481
59408
|
name: {
|
|
59482
|
-
kind:
|
|
59409
|
+
kind: graphql13.Kind.NAME,
|
|
59483
59410
|
value: name
|
|
59484
59411
|
},
|
|
59485
59412
|
value: objectNode(value)
|
|
@@ -59487,16 +59414,16 @@ function argumentNode(name, value) {
|
|
|
59487
59414
|
}
|
|
59488
59415
|
function objectNode([type, defaultValue]) {
|
|
59489
59416
|
const node = {
|
|
59490
|
-
kind:
|
|
59417
|
+
kind: graphql13.Kind.OBJECT,
|
|
59491
59418
|
fields: [
|
|
59492
59419
|
{
|
|
59493
|
-
kind:
|
|
59420
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
59494
59421
|
name: {
|
|
59495
|
-
kind:
|
|
59422
|
+
kind: graphql13.Kind.NAME,
|
|
59496
59423
|
value: "type"
|
|
59497
59424
|
},
|
|
59498
59425
|
value: {
|
|
59499
|
-
kind:
|
|
59426
|
+
kind: graphql13.Kind.STRING,
|
|
59500
59427
|
value: type
|
|
59501
59428
|
}
|
|
59502
59429
|
}
|
|
@@ -59504,8 +59431,8 @@ function objectNode([type, defaultValue]) {
|
|
|
59504
59431
|
};
|
|
59505
59432
|
if (defaultValue) {
|
|
59506
59433
|
node.fields.push({
|
|
59507
|
-
kind:
|
|
59508
|
-
name: { kind:
|
|
59434
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
59435
|
+
name: { kind: graphql13.Kind.NAME, value: "default" },
|
|
59509
59436
|
value: {
|
|
59510
59437
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
59511
59438
|
value: defaultValue.toString()
|
|
@@ -59516,34 +59443,34 @@ function objectNode([type, defaultValue]) {
|
|
|
59516
59443
|
}
|
|
59517
59444
|
var pageInfoSelection = [
|
|
59518
59445
|
{
|
|
59519
|
-
kind:
|
|
59446
|
+
kind: graphql13.Kind.FIELD,
|
|
59520
59447
|
name: {
|
|
59521
|
-
kind:
|
|
59448
|
+
kind: graphql13.Kind.NAME,
|
|
59522
59449
|
value: "edges"
|
|
59523
59450
|
},
|
|
59524
59451
|
selectionSet: {
|
|
59525
|
-
kind:
|
|
59452
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59526
59453
|
selections: [
|
|
59527
59454
|
{
|
|
59528
|
-
kind:
|
|
59455
|
+
kind: graphql13.Kind.FIELD,
|
|
59529
59456
|
name: {
|
|
59530
|
-
kind:
|
|
59457
|
+
kind: graphql13.Kind.NAME,
|
|
59531
59458
|
value: "cursor"
|
|
59532
59459
|
}
|
|
59533
59460
|
},
|
|
59534
59461
|
{
|
|
59535
|
-
kind:
|
|
59462
|
+
kind: graphql13.Kind.FIELD,
|
|
59536
59463
|
name: {
|
|
59537
|
-
kind:
|
|
59464
|
+
kind: graphql13.Kind.NAME,
|
|
59538
59465
|
value: "node"
|
|
59539
59466
|
},
|
|
59540
59467
|
selectionSet: {
|
|
59541
|
-
kind:
|
|
59468
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59542
59469
|
selections: [
|
|
59543
59470
|
{
|
|
59544
|
-
kind:
|
|
59471
|
+
kind: graphql13.Kind.FIELD,
|
|
59545
59472
|
name: {
|
|
59546
|
-
kind:
|
|
59473
|
+
kind: graphql13.Kind.NAME,
|
|
59547
59474
|
value: "__typename"
|
|
59548
59475
|
}
|
|
59549
59476
|
}
|
|
@@ -59554,39 +59481,39 @@ var pageInfoSelection = [
|
|
|
59554
59481
|
}
|
|
59555
59482
|
},
|
|
59556
59483
|
{
|
|
59557
|
-
kind:
|
|
59484
|
+
kind: graphql13.Kind.FIELD,
|
|
59558
59485
|
name: {
|
|
59559
|
-
kind:
|
|
59486
|
+
kind: graphql13.Kind.NAME,
|
|
59560
59487
|
value: "pageInfo"
|
|
59561
59488
|
},
|
|
59562
59489
|
selectionSet: {
|
|
59563
|
-
kind:
|
|
59490
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59564
59491
|
selections: [
|
|
59565
59492
|
{
|
|
59566
|
-
kind:
|
|
59493
|
+
kind: graphql13.Kind.FIELD,
|
|
59567
59494
|
name: {
|
|
59568
|
-
kind:
|
|
59495
|
+
kind: graphql13.Kind.NAME,
|
|
59569
59496
|
value: "hasPreviousPage"
|
|
59570
59497
|
}
|
|
59571
59498
|
},
|
|
59572
59499
|
{
|
|
59573
|
-
kind:
|
|
59500
|
+
kind: graphql13.Kind.FIELD,
|
|
59574
59501
|
name: {
|
|
59575
|
-
kind:
|
|
59502
|
+
kind: graphql13.Kind.NAME,
|
|
59576
59503
|
value: "hasNextPage"
|
|
59577
59504
|
}
|
|
59578
59505
|
},
|
|
59579
59506
|
{
|
|
59580
|
-
kind:
|
|
59507
|
+
kind: graphql13.Kind.FIELD,
|
|
59581
59508
|
name: {
|
|
59582
|
-
kind:
|
|
59509
|
+
kind: graphql13.Kind.NAME,
|
|
59583
59510
|
value: "startCursor"
|
|
59584
59511
|
}
|
|
59585
59512
|
},
|
|
59586
59513
|
{
|
|
59587
|
-
kind:
|
|
59514
|
+
kind: graphql13.Kind.FIELD,
|
|
59588
59515
|
name: {
|
|
59589
|
-
kind:
|
|
59516
|
+
kind: graphql13.Kind.NAME,
|
|
59590
59517
|
value: "endCursor"
|
|
59591
59518
|
}
|
|
59592
59519
|
}
|
|
@@ -59600,17 +59527,17 @@ async function addListFragments(config, documents) {
|
|
|
59600
59527
|
const lists = {};
|
|
59601
59528
|
const errors = [];
|
|
59602
59529
|
for (const doc of documents) {
|
|
59603
|
-
doc.document =
|
|
59530
|
+
doc.document = graphql14.visit(doc.document, {
|
|
59604
59531
|
Directive(node, key, parent2, path2, ancestors) {
|
|
59605
59532
|
if ([config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
59606
59533
|
const nameArg = node.arguments?.find(
|
|
59607
59534
|
(arg) => arg.name.value === config.listOrPaginateNameArg
|
|
59608
59535
|
);
|
|
59609
59536
|
let error = {
|
|
59610
|
-
...new
|
|
59537
|
+
...new graphql14.GraphQLError(
|
|
59611
59538
|
"",
|
|
59612
59539
|
node,
|
|
59613
|
-
new
|
|
59540
|
+
new graphql14.Source(""),
|
|
59614
59541
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
59615
59542
|
path2
|
|
59616
59543
|
),
|
|
@@ -59662,7 +59589,7 @@ async function addListFragments(config, documents) {
|
|
|
59662
59589
|
{
|
|
59663
59590
|
kind: "Argument",
|
|
59664
59591
|
name: {
|
|
59665
|
-
kind:
|
|
59592
|
+
kind: graphql14.Kind.NAME,
|
|
59666
59593
|
value: "connection"
|
|
59667
59594
|
},
|
|
59668
59595
|
value: {
|
|
@@ -59712,7 +59639,7 @@ async function addListFragments(config, documents) {
|
|
|
59712
59639
|
const validDeletes = [
|
|
59713
59640
|
...new Set(
|
|
59714
59641
|
Object.values(lists).map(({ type }) => {
|
|
59715
|
-
if (!(type instanceof
|
|
59642
|
+
if (!(type instanceof graphql14.GraphQLObjectType)) {
|
|
59716
59643
|
return "";
|
|
59717
59644
|
}
|
|
59718
59645
|
if (config.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -59726,7 +59653,7 @@ async function addListFragments(config, documents) {
|
|
|
59726
59653
|
return;
|
|
59727
59654
|
}
|
|
59728
59655
|
const generatedDoc = {
|
|
59729
|
-
kind:
|
|
59656
|
+
kind: graphql14.Kind.DOCUMENT,
|
|
59730
59657
|
definitions: Object.entries(lists).flatMap(
|
|
59731
59658
|
([name, { selection, type }]) => {
|
|
59732
59659
|
const schemaType = config.schema.getType(type.name);
|
|
@@ -59734,7 +59661,7 @@ async function addListFragments(config, documents) {
|
|
|
59734
59661
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
59735
59662
|
}
|
|
59736
59663
|
const fragmentSelection = {
|
|
59737
|
-
kind:
|
|
59664
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
59738
59665
|
selections: [...selection.selections]
|
|
59739
59666
|
};
|
|
59740
59667
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -59749,14 +59676,14 @@ async function addListFragments(config, documents) {
|
|
|
59749
59676
|
{
|
|
59750
59677
|
name: {
|
|
59751
59678
|
value: config.listInsertFragment(name),
|
|
59752
|
-
kind:
|
|
59679
|
+
kind: graphql14.Kind.NAME
|
|
59753
59680
|
},
|
|
59754
|
-
kind:
|
|
59681
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59755
59682
|
selectionSet: fragmentSelection,
|
|
59756
59683
|
typeCondition: {
|
|
59757
|
-
kind:
|
|
59684
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59758
59685
|
name: {
|
|
59759
|
-
kind:
|
|
59686
|
+
kind: graphql14.Kind.NAME,
|
|
59760
59687
|
value: type.name
|
|
59761
59688
|
}
|
|
59762
59689
|
}
|
|
@@ -59764,32 +59691,32 @@ async function addListFragments(config, documents) {
|
|
|
59764
59691
|
{
|
|
59765
59692
|
name: {
|
|
59766
59693
|
value: config.listToggleFragment(name),
|
|
59767
|
-
kind:
|
|
59694
|
+
kind: graphql14.Kind.NAME
|
|
59768
59695
|
},
|
|
59769
|
-
kind:
|
|
59696
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59770
59697
|
selectionSet: fragmentSelection,
|
|
59771
59698
|
typeCondition: {
|
|
59772
|
-
kind:
|
|
59699
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59773
59700
|
name: {
|
|
59774
|
-
kind:
|
|
59701
|
+
kind: graphql14.Kind.NAME,
|
|
59775
59702
|
value: type.name
|
|
59776
59703
|
}
|
|
59777
59704
|
}
|
|
59778
59705
|
},
|
|
59779
59706
|
{
|
|
59780
|
-
kind:
|
|
59707
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59781
59708
|
name: {
|
|
59782
59709
|
value: config.listRemoveFragment(name),
|
|
59783
|
-
kind:
|
|
59710
|
+
kind: graphql14.Kind.NAME
|
|
59784
59711
|
},
|
|
59785
59712
|
selectionSet: {
|
|
59786
|
-
kind:
|
|
59713
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
59787
59714
|
selections: [...objectIdentificationSelection(config, type)]
|
|
59788
59715
|
},
|
|
59789
59716
|
typeCondition: {
|
|
59790
|
-
kind:
|
|
59717
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59791
59718
|
name: {
|
|
59792
|
-
kind:
|
|
59719
|
+
kind: graphql14.Kind.NAME,
|
|
59793
59720
|
value: type.name
|
|
59794
59721
|
}
|
|
59795
59722
|
}
|
|
@@ -59798,14 +59725,14 @@ async function addListFragments(config, documents) {
|
|
|
59798
59725
|
}
|
|
59799
59726
|
).concat(
|
|
59800
59727
|
...validDeletes.map((typeName) => ({
|
|
59801
|
-
kind:
|
|
59728
|
+
kind: graphql14.Kind.DIRECTIVE_DEFINITION,
|
|
59802
59729
|
name: {
|
|
59803
|
-
kind:
|
|
59730
|
+
kind: graphql14.Kind.NAME,
|
|
59804
59731
|
value: config.listDeleteDirective(typeName)
|
|
59805
59732
|
},
|
|
59806
59733
|
locations: [
|
|
59807
59734
|
{
|
|
59808
|
-
kind:
|
|
59735
|
+
kind: graphql14.Kind.NAME,
|
|
59809
59736
|
value: "FIELD"
|
|
59810
59737
|
}
|
|
59811
59738
|
],
|
|
@@ -59813,8 +59740,8 @@ async function addListFragments(config, documents) {
|
|
|
59813
59740
|
}))
|
|
59814
59741
|
)
|
|
59815
59742
|
};
|
|
59816
|
-
config.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
59817
|
-
config.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
59743
|
+
config.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
59744
|
+
config.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
59818
59745
|
documents.push({
|
|
59819
59746
|
name: "generated::lists",
|
|
59820
59747
|
kind: ArtifactKind.Fragment,
|
|
@@ -59900,11 +59827,11 @@ var nodeNotDefinedMessage = (config) => `Looks like you are trying to use the ${
|
|
|
59900
59827
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
59901
59828
|
|
|
59902
59829
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
59903
|
-
import * as
|
|
59830
|
+
import * as graphql15 from "graphql";
|
|
59904
59831
|
function fieldKey(config, field) {
|
|
59905
59832
|
const attributeName = field.alias?.value || field.name.value;
|
|
59906
|
-
const printed =
|
|
59907
|
-
const secondParse =
|
|
59833
|
+
const printed = graphql15.print(field);
|
|
59834
|
+
const secondParse = graphql15.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
59908
59835
|
let paginateMode = config.defaultPaginateMode;
|
|
59909
59836
|
const paginatedDirective = field.directives?.find(
|
|
59910
59837
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -60027,13 +59954,13 @@ function prepareSelection({
|
|
|
60027
59954
|
} else if ("getFields" in type) {
|
|
60028
59955
|
let typeRef = type.getFields()[field.name.value].type;
|
|
60029
59956
|
fieldType = getRootType(typeRef);
|
|
60030
|
-
nullable = !
|
|
60031
|
-
} else if (
|
|
59957
|
+
nullable = !graphql16.isNonNullType(typeRef);
|
|
59958
|
+
} else if (graphql16.isAbstractType(type)) {
|
|
60032
59959
|
for (const possible of config.schema.getPossibleTypes(type)) {
|
|
60033
|
-
if (
|
|
59960
|
+
if (graphql16.isObjectType(possible)) {
|
|
60034
59961
|
if (possible.getFields()[field.name.value]) {
|
|
60035
59962
|
fieldType = possible.getFields()[field.name.value].type;
|
|
60036
|
-
nullable = !
|
|
59963
|
+
nullable = !graphql16.isNonNullType(fieldType);
|
|
60037
59964
|
break;
|
|
60038
59965
|
}
|
|
60039
59966
|
}
|
|
@@ -60170,7 +60097,7 @@ function prepareSelection({
|
|
|
60170
60097
|
kind: "value"
|
|
60171
60098
|
} : { kind: "continue" };
|
|
60172
60099
|
const parentType = config.schema.getType(rootType);
|
|
60173
|
-
if (
|
|
60100
|
+
if (graphql16.isObjectType(parentType) || graphql16.isInterfaceType(parentType)) {
|
|
60174
60101
|
const fieldType2 = parentType.getFields()[field.name.value]?.type;
|
|
60175
60102
|
if (fieldType2) {
|
|
60176
60103
|
const listCount = unwrapType(config, fieldType2).wrappers.filter(
|
|
@@ -60193,7 +60120,7 @@ function prepareSelection({
|
|
|
60193
60120
|
}
|
|
60194
60121
|
fieldObj.loading = loadingValue;
|
|
60195
60122
|
}
|
|
60196
|
-
if (
|
|
60123
|
+
if (graphql16.isInterfaceType(fieldType) || graphql16.isUnionType(fieldType)) {
|
|
60197
60124
|
fieldObj.abstract = true;
|
|
60198
60125
|
if (Object.values(fieldObj.selection?.abstractFields?.fields ?? {}).some(
|
|
60199
60126
|
(fields) => Object.values(fields ?? {}).some((field2) => field2.required)
|
|
@@ -60275,7 +60202,7 @@ function mergeSelection({
|
|
|
60275
60202
|
typeSelection,
|
|
60276
60203
|
abstractSelection.fields[typeName] ?? {}
|
|
60277
60204
|
);
|
|
60278
|
-
if (
|
|
60205
|
+
if (graphql16.isAbstractType(gqlType)) {
|
|
60279
60206
|
for (const possible of config.schema.getPossibleTypes(gqlType)) {
|
|
60280
60207
|
if (!possibleSelectionTypes[typeName]) {
|
|
60281
60208
|
possibleSelectionTypes[typeName] = [];
|
|
@@ -60310,7 +60237,7 @@ function mergeSelection({
|
|
|
60310
60237
|
}
|
|
60311
60238
|
}
|
|
60312
60239
|
const parentType = config.schema.getType(rootType);
|
|
60313
|
-
const possibleParents =
|
|
60240
|
+
const possibleParents = graphql16.isAbstractType(parentType) ? config.schema.getPossibleTypes(parentType)?.map((t2) => t2.name) : [parentType.name];
|
|
60314
60241
|
for (const key of Object.keys(abstractSelection.typeMap)) {
|
|
60315
60242
|
if (!possibleParents.includes(key) && rootType !== key || abstractSelection.fields[key]) {
|
|
60316
60243
|
delete abstractSelection.typeMap[key];
|
|
@@ -60367,12 +60294,12 @@ function mergeSelection({
|
|
|
60367
60294
|
}
|
|
60368
60295
|
|
|
60369
60296
|
// src/codegen/generators/artifacts/index.ts
|
|
60370
|
-
var
|
|
60297
|
+
var AST5 = recast5.types.builders;
|
|
60371
60298
|
function artifactGenerator(stats) {
|
|
60372
60299
|
return async function(config, docs) {
|
|
60373
60300
|
const filterTypes = {};
|
|
60374
60301
|
for (const doc of docs) {
|
|
60375
|
-
|
|
60302
|
+
graphql17.visit(doc.document, {
|
|
60376
60303
|
Directive(node, _, __, ___, ancestors) {
|
|
60377
60304
|
if (node.name.value !== config.listDirective) {
|
|
60378
60305
|
return;
|
|
@@ -60432,7 +60359,7 @@ function artifactGenerator(stats) {
|
|
|
60432
60359
|
return;
|
|
60433
60360
|
}
|
|
60434
60361
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
60435
|
-
let documentWithoutInternalDirectives =
|
|
60362
|
+
let documentWithoutInternalDirectives = graphql17.visit(document, {
|
|
60436
60363
|
Directive(node) {
|
|
60437
60364
|
if (config.isInternalDirective(node.name.value)) {
|
|
60438
60365
|
return null;
|
|
@@ -60445,7 +60372,7 @@ function artifactGenerator(stats) {
|
|
|
60445
60372
|
}
|
|
60446
60373
|
}
|
|
60447
60374
|
});
|
|
60448
|
-
let documentWithoutExtraVariables =
|
|
60375
|
+
let documentWithoutExtraVariables = graphql17.visit(
|
|
60449
60376
|
documentWithoutInternalDirectives,
|
|
60450
60377
|
{
|
|
60451
60378
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -60456,13 +60383,13 @@ function artifactGenerator(stats) {
|
|
|
60456
60383
|
}
|
|
60457
60384
|
}
|
|
60458
60385
|
);
|
|
60459
|
-
let rawString =
|
|
60386
|
+
let rawString = graphql17.print(documentWithoutExtraVariables);
|
|
60460
60387
|
let docKind = doc.kind;
|
|
60461
60388
|
const operations = document.definitions.filter(
|
|
60462
|
-
({ kind }) => kind ===
|
|
60389
|
+
({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
|
|
60463
60390
|
);
|
|
60464
60391
|
const fragments = document.definitions.filter(
|
|
60465
|
-
({ kind }) => kind ===
|
|
60392
|
+
({ kind }) => kind === graphql17.Kind.FRAGMENT_DEFINITION
|
|
60466
60393
|
);
|
|
60467
60394
|
let rootType = "";
|
|
60468
60395
|
let selectionSet;
|
|
@@ -60609,7 +60536,21 @@ function artifactGenerator(stats) {
|
|
|
60609
60536
|
artifact.pluginData[plugin2.name] = plugin2.artifactData({ config, document: doc }) ?? {};
|
|
60610
60537
|
}
|
|
60611
60538
|
if (inputs && inputs.length > 0) {
|
|
60612
|
-
|
|
60539
|
+
const runtimeScalars = inputs.reduce((prev, input) => {
|
|
60540
|
+
const runtimeScalarDirective = input.directives?.find(
|
|
60541
|
+
(directive2) => directive2.name.value === config.runtimeScalarDirective
|
|
60542
|
+
);
|
|
60543
|
+
if (!runtimeScalarDirective) {
|
|
60544
|
+
return prev;
|
|
60545
|
+
}
|
|
60546
|
+
return {
|
|
60547
|
+
...prev,
|
|
60548
|
+
[input.variable.name.value]: runtimeScalarDirective.arguments?.find(
|
|
60549
|
+
(arg) => arg.name.value === "type"
|
|
60550
|
+
)?.value?.value
|
|
60551
|
+
};
|
|
60552
|
+
}, {});
|
|
60553
|
+
artifact.input = inputObject(config, inputs, runtimeScalars);
|
|
60613
60554
|
}
|
|
60614
60555
|
if (artifact.kind === "HoudiniQuery") {
|
|
60615
60556
|
const cacheDirective = operations[0].directives?.find(
|
|
@@ -60648,9 +60589,9 @@ function artifactGenerator(stats) {
|
|
|
60648
60589
|
plugin2.artifactEnd({ config, document: doc });
|
|
60649
60590
|
}
|
|
60650
60591
|
const _houdiniHash = hashOriginal({ document: doc });
|
|
60651
|
-
const file =
|
|
60592
|
+
const file = AST5.program([
|
|
60652
60593
|
moduleExport(config, "default", serializeValue(artifact)),
|
|
60653
|
-
|
|
60594
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
60654
60595
|
]);
|
|
60655
60596
|
const artifactPath = config.artifactPath(document);
|
|
60656
60597
|
const countDocument = doc.generateStore;
|
|
@@ -60708,7 +60649,7 @@ function applyMask(config, target, mask) {
|
|
|
60708
60649
|
if (!targetType) {
|
|
60709
60650
|
continue;
|
|
60710
60651
|
}
|
|
60711
|
-
if (
|
|
60652
|
+
if (graphql17.isAbstractType(targetType)) {
|
|
60712
60653
|
for (const possible of config.schema.getPossibleTypes(targetType)) {
|
|
60713
60654
|
if (target.abstractFields?.fields[possible.name]) {
|
|
60714
60655
|
applyMask(
|
|
@@ -60731,8 +60672,8 @@ function applyMask(config, target, mask) {
|
|
|
60731
60672
|
}
|
|
60732
60673
|
|
|
60733
60674
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
60734
|
-
var
|
|
60735
|
-
var
|
|
60675
|
+
var recast6 = __toESM(require_main2(), 1);
|
|
60676
|
+
var AST6 = recast6.types.builders;
|
|
60736
60677
|
async function generateGraphqlReturnTypes(config, docs) {
|
|
60737
60678
|
const indexPath = path_exports.join(config.runtimeDirectory, "index.d.ts");
|
|
60738
60679
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
@@ -60767,18 +60708,18 @@ async function generateGraphqlReturnTypes(config, docs) {
|
|
|
60767
60708
|
continue;
|
|
60768
60709
|
}
|
|
60769
60710
|
for (const [queryString, returnValue] of Object.entries(overloaded_returns)) {
|
|
60770
|
-
const input =
|
|
60771
|
-
input.typeAnnotation =
|
|
60772
|
-
|
|
60711
|
+
const input = AST6.identifier("str");
|
|
60712
|
+
input.typeAnnotation = AST6.tsTypeAnnotation(
|
|
60713
|
+
AST6.tsLiteralType(AST6.stringLiteral(queryString))
|
|
60773
60714
|
);
|
|
60774
60715
|
script.body.splice(
|
|
60775
60716
|
i,
|
|
60776
60717
|
0,
|
|
60777
|
-
|
|
60778
|
-
|
|
60779
|
-
|
|
60718
|
+
AST6.exportNamedDeclaration(
|
|
60719
|
+
AST6.tsDeclareFunction(
|
|
60720
|
+
AST6.identifier("graphql"),
|
|
60780
60721
|
[input],
|
|
60781
|
-
|
|
60722
|
+
AST6.tsTypeAnnotation(AST6.tsTypeReference(AST6.identifier(returnValue)))
|
|
60782
60723
|
)
|
|
60783
60724
|
)
|
|
60784
60725
|
);
|
|
@@ -60953,165 +60894,22 @@ function moduleStatments(config) {
|
|
|
60953
60894
|
var recast11 = __toESM(require_main2(), 1);
|
|
60954
60895
|
|
|
60955
60896
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
60956
|
-
var recast8 = __toESM(require_main2(), 1);
|
|
60957
|
-
import * as graphql19 from "graphql";
|
|
60958
|
-
|
|
60959
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
60960
60897
|
var recast7 = __toESM(require_main2(), 1);
|
|
60961
60898
|
import * as graphql18 from "graphql";
|
|
60962
|
-
|
|
60963
|
-
// src/codegen/generators/typescript/types.ts
|
|
60964
|
-
var recast6 = __toESM(require_main2(), 1);
|
|
60965
|
-
import * as graphql17 from "graphql";
|
|
60966
|
-
var AST6 = recast6.types.builders;
|
|
60967
|
-
function readonlyProperty(prop, enable = true) {
|
|
60968
|
-
if (enable) {
|
|
60969
|
-
prop.readonly = true;
|
|
60970
|
-
}
|
|
60971
|
-
return prop;
|
|
60972
|
-
}
|
|
60973
|
-
function nullableField(inner, input = false) {
|
|
60974
|
-
const members = [inner, AST6.tsNullKeyword()];
|
|
60975
|
-
if (input) {
|
|
60976
|
-
members.push(AST6.tsUndefinedKeyword());
|
|
60977
|
-
}
|
|
60978
|
-
return AST6.tsUnionType(members);
|
|
60979
|
-
}
|
|
60980
|
-
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
60981
|
-
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
60982
|
-
if (!field) {
|
|
60983
|
-
return AST6.tsNeverKeyword();
|
|
60984
|
-
}
|
|
60985
|
-
const component = config.componentFields[field.parent][field.field];
|
|
60986
|
-
const sourcePathRelative = path_exports.relative(
|
|
60987
|
-
path_exports.join(config.projectRoot, "src"),
|
|
60988
|
-
component.filepath
|
|
60989
|
-
);
|
|
60990
|
-
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
60991
|
-
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
60992
|
-
const localImport = ensureImports({
|
|
60993
|
-
config,
|
|
60994
|
-
body,
|
|
60995
|
-
import: "__component__" + component.fragment,
|
|
60996
|
-
sourceModule: path_exports.join(
|
|
60997
|
-
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
60998
|
-
"src",
|
|
60999
|
-
sourcePath
|
|
61000
|
-
)
|
|
61001
|
-
});
|
|
61002
|
-
const parameters = AST6.tsTypeReference(AST6.identifier("Parameters"));
|
|
61003
|
-
parameters.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
61004
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
61005
|
-
]);
|
|
61006
|
-
const indexed = AST6.tsIndexedAccessType(
|
|
61007
|
-
parameters,
|
|
61008
|
-
AST6.tsLiteralType(AST6.numericLiteral(0))
|
|
61009
|
-
);
|
|
61010
|
-
const omit = AST6.tsTypeReference(AST6.identifier("Omit"));
|
|
61011
|
-
omit.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
61012
|
-
indexed,
|
|
61013
|
-
AST6.tsLiteralType(AST6.stringLiteral(component.prop))
|
|
61014
|
-
]);
|
|
61015
|
-
const arg = AST6.identifier("props");
|
|
61016
|
-
arg.typeAnnotation = AST6.tsTypeAnnotation(omit);
|
|
61017
|
-
const returnType = AST6.tsTypeReference(AST6.identifier("ReturnType"));
|
|
61018
|
-
returnType.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
61019
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
61020
|
-
]);
|
|
61021
|
-
const fnType = AST6.tsFunctionType([arg]);
|
|
61022
|
-
fnType.typeAnnotation = AST6.tsTypeAnnotation(returnType);
|
|
61023
|
-
return fnType;
|
|
61024
|
-
}
|
|
61025
|
-
switch (target.name) {
|
|
61026
|
-
case "String": {
|
|
61027
|
-
return AST6.tsStringKeyword();
|
|
61028
|
-
}
|
|
61029
|
-
case "Int": {
|
|
61030
|
-
return AST6.tsNumberKeyword();
|
|
61031
|
-
}
|
|
61032
|
-
case "Float": {
|
|
61033
|
-
return AST6.tsNumberKeyword();
|
|
61034
|
-
}
|
|
61035
|
-
case "Boolean": {
|
|
61036
|
-
return AST6.tsBooleanKeyword();
|
|
61037
|
-
}
|
|
61038
|
-
case "ID": {
|
|
61039
|
-
return AST6.tsStringKeyword();
|
|
61040
|
-
}
|
|
61041
|
-
default: {
|
|
61042
|
-
if (graphql17.isNonNullType(target) && "ofType" in target) {
|
|
61043
|
-
return scalarPropertyValue(
|
|
61044
|
-
config,
|
|
61045
|
-
filepath,
|
|
61046
|
-
missingScalars,
|
|
61047
|
-
target.ofType,
|
|
61048
|
-
body,
|
|
61049
|
-
field
|
|
61050
|
-
);
|
|
61051
|
-
}
|
|
61052
|
-
if (config.scalars?.[target.name]) {
|
|
61053
|
-
return AST6.tsTypeReference(AST6.identifier(config.scalars?.[target.name].type));
|
|
61054
|
-
}
|
|
61055
|
-
if (target.name !== config.componentScalar) {
|
|
61056
|
-
missingScalars.add(target.name);
|
|
61057
|
-
}
|
|
61058
|
-
return AST6.tsAnyKeyword();
|
|
61059
|
-
}
|
|
61060
|
-
}
|
|
61061
|
-
}
|
|
61062
|
-
|
|
61063
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
61064
60899
|
var AST7 = recast7.types.builders;
|
|
61065
|
-
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
61066
|
-
const { type, wrappers } = unwrapType(config, definition.type);
|
|
61067
|
-
let result;
|
|
61068
|
-
if (graphql18.isScalarType(type)) {
|
|
61069
|
-
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
61070
|
-
} else if (graphql18.isEnumType(type)) {
|
|
61071
|
-
result = enumReference(config, body, type.name);
|
|
61072
|
-
} else {
|
|
61073
|
-
result = AST7.tsTypeReference(AST7.identifier(type.name));
|
|
61074
|
-
}
|
|
61075
|
-
for (const toWrap of wrappers) {
|
|
61076
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
61077
|
-
continue;
|
|
61078
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
61079
|
-
result = nullableField(result, true);
|
|
61080
|
-
} else if (toWrap === "List" /* List */) {
|
|
61081
|
-
result = AST7.tsArrayType(AST7.tsParenthesizedType(result));
|
|
61082
|
-
}
|
|
61083
|
-
}
|
|
61084
|
-
return result;
|
|
61085
|
-
}
|
|
61086
|
-
function enumReference(config, body, name) {
|
|
61087
|
-
ensureImports({
|
|
61088
|
-
config,
|
|
61089
|
-
body,
|
|
61090
|
-
import: ["ValueOf"],
|
|
61091
|
-
importKind: "type",
|
|
61092
|
-
sourceModule: "$houdini/runtime/lib/types"
|
|
61093
|
-
});
|
|
61094
|
-
return AST7.tsTypeReference(
|
|
61095
|
-
AST7.identifier("ValueOf"),
|
|
61096
|
-
AST7.tsTypeParameterInstantiation([AST7.tsTypeQuery(AST7.identifier(name))])
|
|
61097
|
-
);
|
|
61098
|
-
}
|
|
61099
|
-
|
|
61100
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
61101
|
-
var AST8 = recast8.types.builders;
|
|
61102
60900
|
function addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
61103
60901
|
const { type } = unwrapType(config, rootType);
|
|
61104
|
-
if (
|
|
60902
|
+
if (graphql18.isScalarType(type)) {
|
|
61105
60903
|
return;
|
|
61106
60904
|
}
|
|
61107
60905
|
if (visitedTypes.has(type.name)) {
|
|
61108
60906
|
return;
|
|
61109
60907
|
}
|
|
61110
|
-
if (
|
|
60908
|
+
if (graphql18.isUnionType(type)) {
|
|
61111
60909
|
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
61112
60910
|
}
|
|
61113
60911
|
visitedTypes.add(type.name);
|
|
61114
|
-
if (
|
|
60912
|
+
if (graphql18.isEnumType(type)) {
|
|
61115
60913
|
ensureImports({
|
|
61116
60914
|
config,
|
|
61117
60915
|
body,
|
|
@@ -61125,21 +60923,37 @@ function addReferencedInputTypes(config, filepath, body, visitedTypes, missingSc
|
|
|
61125
60923
|
for (const field of Object.values(type.getFields())) {
|
|
61126
60924
|
addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, field.type);
|
|
61127
60925
|
members.push(
|
|
61128
|
-
|
|
61129
|
-
|
|
61130
|
-
|
|
60926
|
+
AST7.tsPropertySignature(
|
|
60927
|
+
AST7.identifier(field.name),
|
|
60928
|
+
AST7.tsTypeAnnotation(
|
|
61131
60929
|
tsTypeReference(config, filepath, missingScalars, field, body)
|
|
61132
60930
|
),
|
|
61133
|
-
|
|
60931
|
+
graphql18.isNullableType(field.type)
|
|
61134
60932
|
)
|
|
61135
60933
|
);
|
|
61136
60934
|
}
|
|
61137
|
-
body.push(
|
|
60935
|
+
body.push(AST7.tsTypeAliasDeclaration(AST7.identifier(type.name), AST7.tsTypeLiteral(members)));
|
|
61138
60936
|
}
|
|
61139
60937
|
|
|
61140
60938
|
// src/codegen/generators/typescript/inlineType.ts
|
|
61141
60939
|
var recast9 = __toESM(require_main2(), 1);
|
|
61142
|
-
import * as
|
|
60940
|
+
import * as graphql19 from "graphql";
|
|
60941
|
+
|
|
60942
|
+
// src/codegen/generators/comments/jsdoc.ts
|
|
60943
|
+
var recast8 = __toESM(require_main2(), 1);
|
|
60944
|
+
var AST8 = recast8.types.builders;
|
|
60945
|
+
function jsdocComment(text, deprecated) {
|
|
60946
|
+
let commentContent = `*
|
|
60947
|
+
* ${text}
|
|
60948
|
+
`;
|
|
60949
|
+
if (deprecated) {
|
|
60950
|
+
commentContent = `${commentContent} * @deprecated ${deprecated}
|
|
60951
|
+
`;
|
|
60952
|
+
}
|
|
60953
|
+
return AST8.commentBlock(commentContent, true);
|
|
60954
|
+
}
|
|
60955
|
+
|
|
60956
|
+
// src/codegen/generators/typescript/inlineType.ts
|
|
61143
60957
|
var AST9 = recast9.types.builders;
|
|
61144
60958
|
var fragmentKey2 = " $fragments";
|
|
61145
60959
|
function inlineType({
|
|
@@ -61160,7 +60974,7 @@ function inlineType({
|
|
|
61160
60974
|
const { type, wrappers } = unwrapType(config, rootType);
|
|
61161
60975
|
let result;
|
|
61162
60976
|
let forceNullable = false;
|
|
61163
|
-
if (
|
|
60977
|
+
if (graphql19.isScalarType(type)) {
|
|
61164
60978
|
result = scalarPropertyValue(
|
|
61165
60979
|
config,
|
|
61166
60980
|
filepath,
|
|
@@ -61169,7 +60983,7 @@ function inlineType({
|
|
|
61169
60983
|
body,
|
|
61170
60984
|
field
|
|
61171
60985
|
);
|
|
61172
|
-
} else if (
|
|
60986
|
+
} else if (graphql19.isEnumType(type)) {
|
|
61173
60987
|
ensureImports({
|
|
61174
60988
|
config,
|
|
61175
60989
|
body,
|
|
@@ -61194,11 +61008,11 @@ function inlineType({
|
|
|
61194
61008
|
for (const selection of selections) {
|
|
61195
61009
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
61196
61010
|
const fragmentType = config.schema.getType(selection.typeCondition.name.value);
|
|
61197
|
-
if (!
|
|
61011
|
+
if (!graphql19.isInterfaceType(type) && !graphql19.isUnionType(type)) {
|
|
61198
61012
|
selectedFields.push(...selection.selectionSet.selections);
|
|
61199
61013
|
continue;
|
|
61200
61014
|
}
|
|
61201
|
-
if (!
|
|
61015
|
+
if (!graphql19.isInterfaceType(fragmentType) && !graphql19.isUnionType(fragmentType)) {
|
|
61202
61016
|
if (!inlineFragments[fragmentType.name]) {
|
|
61203
61017
|
inlineFragments[fragmentType.name] = [];
|
|
61204
61018
|
}
|
|
@@ -61290,6 +61104,11 @@ function inlineType({
|
|
|
61290
61104
|
if (allOptional) {
|
|
61291
61105
|
prop.optional = true;
|
|
61292
61106
|
}
|
|
61107
|
+
if (field2.description || field2.deprecationReason) {
|
|
61108
|
+
prop.comments = [
|
|
61109
|
+
jsdocComment(field2.description ?? "", field2.deprecationReason ?? void 0)
|
|
61110
|
+
];
|
|
61111
|
+
}
|
|
61293
61112
|
return prop;
|
|
61294
61113
|
})
|
|
61295
61114
|
]);
|
|
@@ -61341,7 +61160,7 @@ function inlineType({
|
|
|
61341
61160
|
}
|
|
61342
61161
|
}
|
|
61343
61162
|
}
|
|
61344
|
-
if (objectType.type === "TSTypeLiteral" && !
|
|
61163
|
+
if (objectType.type === "TSTypeLiteral" && !graphql19.isInterfaceType(fragmentRootType) && !graphql19.isUnionType(fragmentRootType)) {
|
|
61345
61164
|
const existingTypenameIndex = objectType.members.findIndex(
|
|
61346
61165
|
(member) => member.type === "TSPropertySignature" && member.key.type === "Identifier" && member.key.name === "__typename"
|
|
61347
61166
|
);
|
|
@@ -61366,11 +61185,11 @@ function inlineType({
|
|
|
61366
61185
|
];
|
|
61367
61186
|
}
|
|
61368
61187
|
let coveredTypenames;
|
|
61369
|
-
if (
|
|
61188
|
+
if (graphql19.isInterfaceType(fragmentRootType)) {
|
|
61370
61189
|
coveredTypenames = interfaceCoveredTypenames(fragmentRootType);
|
|
61371
|
-
} else if (
|
|
61190
|
+
} else if (graphql19.isUnionType(fragmentRootType)) {
|
|
61372
61191
|
coveredTypenames = fragmentRootType.getTypes().map((type2) => type2.name);
|
|
61373
|
-
} else if (
|
|
61192
|
+
} else if (graphql19.isObjectType(fragmentRootType)) {
|
|
61374
61193
|
coveredTypenames = [fragmentRootType.name];
|
|
61375
61194
|
} else {
|
|
61376
61195
|
throw Error("unreachable code");
|
|
@@ -61406,7 +61225,7 @@ function inlineType({
|
|
|
61406
61225
|
);
|
|
61407
61226
|
}
|
|
61408
61227
|
);
|
|
61409
|
-
const parentIsUnionOrInterface = !
|
|
61228
|
+
const parentIsUnionOrInterface = !graphql19.isInterfaceType(type) && !graphql19.isUnionType(type);
|
|
61410
61229
|
const possibleTypenames = parentIsUnionOrInterface ? [parent.name] : config.schema.getPossibleTypes(type).map((type2) => type2.name);
|
|
61411
61230
|
const coveredTypenames = new Set(
|
|
61412
61231
|
Object.values(inlineFragmentSelections).flatMap((sel) => sel.coveredTypenames)
|
|
@@ -61473,7 +61292,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
61473
61292
|
},
|
|
61474
61293
|
type: schema.getType("String")
|
|
61475
61294
|
};
|
|
61476
|
-
} else if (
|
|
61295
|
+
} else if (graphql19.isNonNullType(rootType) && "getFields" in rootType.ofType) {
|
|
61477
61296
|
fields = rootType.ofType.getFields();
|
|
61478
61297
|
} else {
|
|
61479
61298
|
fields = rootType.getFields();
|
|
@@ -61485,7 +61304,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
61485
61304
|
message: `Could not find type information for field ${rootType.toString()}.${selectionName} ${field}`
|
|
61486
61305
|
});
|
|
61487
61306
|
}
|
|
61488
|
-
const fieldType =
|
|
61307
|
+
const fieldType = graphql19.getNamedType(field.type);
|
|
61489
61308
|
if (!fieldType) {
|
|
61490
61309
|
throw new HoudiniError({
|
|
61491
61310
|
filepath,
|
|
@@ -61701,17 +61520,20 @@ export * from "${module}"
|
|
|
61701
61520
|
}
|
|
61702
61521
|
}
|
|
61703
61522
|
await fs_exports.writeFile(config.typeIndexPath, indexContent);
|
|
61704
|
-
|
|
61705
|
-
|
|
61706
|
-
|
|
61707
|
-
|
|
61523
|
+
const missingScalarNames = [...missingScalars].filter(
|
|
61524
|
+
(scalar) => !config.configFile.features?.runtimeScalars?.[scalar]
|
|
61525
|
+
);
|
|
61526
|
+
if (missingScalarNames.length > 0) {
|
|
61527
|
+
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
|
|
61528
|
+
...missingScalarNames
|
|
61529
|
+
].join(", ")}
|
|
61708
61530
|
Generated types will contain an any type in place of these values. To fix this, provide an equivalent
|
|
61709
61531
|
type in your config file:
|
|
61710
61532
|
|
|
61711
61533
|
{
|
|
61712
61534
|
scalars: {
|
|
61713
61535
|
${cyan2(`/* in your case, something like */`)}
|
|
61714
|
-
${[...
|
|
61536
|
+
${[...missingScalarNames].map(
|
|
61715
61537
|
(c) => ` ${c}: { ${green2(`// <- The GraphQL Scalar`)}
|
|
61716
61538
|
type: "${cyan2(`YourType_${c}`)}" ${green2(`// <- The TypeScript type`)}
|
|
61717
61539
|
}`
|
|
@@ -61991,7 +61813,7 @@ async function generateFragmentTypeDefs(config, filepath, body, selections, defi
|
|
|
61991
61813
|
|
|
61992
61814
|
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
61993
61815
|
var recast12 = __toESM(require_main2(), 1);
|
|
61994
|
-
import * as
|
|
61816
|
+
import * as graphql20 from "graphql";
|
|
61995
61817
|
var AST12 = recast12.types.builders;
|
|
61996
61818
|
async function imperativeCacheTypef(config, docs) {
|
|
61997
61819
|
const returnType = (doc) => config.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
@@ -62042,7 +61864,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
62042
61864
|
const operationTypes = [config.schema.getMutationType(), config.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
62043
61865
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
62044
61866
|
const types14 = Object.values(config.schema.getTypeMap()).filter(
|
|
62045
|
-
(type) => !
|
|
61867
|
+
(type) => !graphql20.isAbstractType(type) && !graphql20.isScalarType(type) && !graphql20.isEnumType(type) && !graphql20.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
62046
61868
|
);
|
|
62047
61869
|
const fragmentMap = fragmentListMap(
|
|
62048
61870
|
config,
|
|
@@ -62059,7 +61881,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
62059
61881
|
}
|
|
62060
61882
|
let idFields = AST12.tsNeverKeyword();
|
|
62061
61883
|
const keys2 = keyFieldsForType(config.configFile, type.name);
|
|
62062
|
-
if (
|
|
61884
|
+
if (graphql20.isObjectType(type) && keys2.length > 0 && keys2.every((key) => type.getFields()[key])) {
|
|
62063
61885
|
idFields = AST12.tsTypeLiteral(
|
|
62064
61886
|
keys2.map((key) => {
|
|
62065
61887
|
const fieldType = type.getFields()[key];
|
|
@@ -62086,13 +61908,13 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
62086
61908
|
idFields = AST12.tsTypeLiteral([]);
|
|
62087
61909
|
}
|
|
62088
61910
|
let fields = AST12.tsTypeLiteral([]);
|
|
62089
|
-
if (
|
|
61911
|
+
if (graphql20.isObjectType(type)) {
|
|
62090
61912
|
fields = AST12.tsTypeLiteral(
|
|
62091
61913
|
Object.entries(type.getFields()).map(
|
|
62092
61914
|
([key, fieldType]) => {
|
|
62093
61915
|
const unwrapped = unwrapType(config, fieldType.type);
|
|
62094
61916
|
let typeOptions = AST12.tsUnionType([]);
|
|
62095
|
-
if (
|
|
61917
|
+
if (graphql20.isScalarType(unwrapped.type)) {
|
|
62096
61918
|
typeOptions.types.push(
|
|
62097
61919
|
scalarPropertyValue(
|
|
62098
61920
|
config,
|
|
@@ -62106,11 +61928,11 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
62106
61928
|
}
|
|
62107
61929
|
)
|
|
62108
61930
|
);
|
|
62109
|
-
} else if (
|
|
61931
|
+
} else if (graphql20.isEnumType(unwrapped.type)) {
|
|
62110
61932
|
typeOptions.types.push(
|
|
62111
61933
|
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
62112
61934
|
);
|
|
62113
|
-
} else if (!
|
|
61935
|
+
} else if (!graphql20.isAbstractType(unwrapped.type)) {
|
|
62114
61936
|
typeOptions.types.push(record(unwrapped.type.name));
|
|
62115
61937
|
} else {
|
|
62116
61938
|
typeOptions.types.push(
|
|
@@ -62206,7 +62028,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
62206
62028
|
const lists = [];
|
|
62207
62029
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
62208
62030
|
for (const doc of docs) {
|
|
62209
|
-
|
|
62031
|
+
graphql20.visit(doc.document, {
|
|
62210
62032
|
Directive(node, key, parent2, path2, ancestors) {
|
|
62211
62033
|
if (![config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
62212
62034
|
return;
|
|
@@ -62228,7 +62050,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
62228
62050
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
62229
62051
|
const { type: listType } = unwrapType(config, targetFieldDefinition.type);
|
|
62230
62052
|
const possibleTypes = [];
|
|
62231
|
-
if (
|
|
62053
|
+
if (graphql20.isAbstractType(listType)) {
|
|
62232
62054
|
possibleTypes.push(
|
|
62233
62055
|
...config.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
62234
62056
|
);
|
|
@@ -62390,7 +62212,7 @@ async function typescriptGenerator(config, docs) {
|
|
|
62390
62212
|
}
|
|
62391
62213
|
|
|
62392
62214
|
// src/codegen/generators/persistedQueries/index.ts
|
|
62393
|
-
import * as
|
|
62215
|
+
import * as graphql21 from "graphql";
|
|
62394
62216
|
async function persistOutputGenerator(config, docs) {
|
|
62395
62217
|
if (!config.persistedQueriesPath.endsWith(".json")) {
|
|
62396
62218
|
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
@@ -62400,8 +62222,8 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62400
62222
|
if (!generateArtifact) {
|
|
62401
62223
|
return acc;
|
|
62402
62224
|
}
|
|
62403
|
-
let rawString =
|
|
62404
|
-
|
|
62225
|
+
let rawString = graphql21.print(
|
|
62226
|
+
graphql21.visit(document, {
|
|
62405
62227
|
Directive(node) {
|
|
62406
62228
|
if (config.isInternalDirective(node.name.value)) {
|
|
62407
62229
|
return null;
|
|
@@ -62410,7 +62232,7 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62410
62232
|
})
|
|
62411
62233
|
);
|
|
62412
62234
|
const operations = document.definitions.filter(
|
|
62413
|
-
({ kind }) => kind ===
|
|
62235
|
+
({ kind }) => kind === graphql21.Kind.OPERATION_DEFINITION
|
|
62414
62236
|
);
|
|
62415
62237
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
62416
62238
|
if (artifact) {
|
|
@@ -62425,33 +62247,45 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62425
62247
|
}
|
|
62426
62248
|
|
|
62427
62249
|
// src/codegen/generators/definitions/index.ts
|
|
62428
|
-
import * as
|
|
62250
|
+
import * as graphql23 from "graphql";
|
|
62429
62251
|
|
|
62430
62252
|
// src/codegen/generators/definitions/enums.ts
|
|
62431
62253
|
var recast13 = __toESM(require_main2(), 1);
|
|
62432
|
-
import * as
|
|
62254
|
+
import * as graphql22 from "graphql";
|
|
62433
62255
|
var AST13 = recast13.types.builders;
|
|
62434
62256
|
async function definitionsGenerator(config) {
|
|
62435
|
-
const enums =
|
|
62257
|
+
const enums = graphql22.parse(graphql22.printSchema(config.schema)).definitions.filter(
|
|
62436
62258
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
62437
62259
|
).filter((def) => !config.isInternalEnum(def));
|
|
62438
62260
|
const { code: runtimeDefinitions } = await printJS(
|
|
62439
62261
|
AST13.program(
|
|
62440
62262
|
enums.map((defn) => {
|
|
62441
62263
|
const name = defn.name.value;
|
|
62442
|
-
|
|
62264
|
+
const declaration = moduleExport(
|
|
62443
62265
|
config,
|
|
62444
62266
|
name,
|
|
62445
62267
|
AST13.objectExpression(
|
|
62446
62268
|
defn.values?.map((value) => {
|
|
62447
62269
|
const str = value.name.value;
|
|
62448
|
-
|
|
62270
|
+
const prop = AST13.objectProperty(
|
|
62449
62271
|
AST13.stringLiteral(str),
|
|
62450
62272
|
AST13.stringLiteral(str)
|
|
62451
62273
|
);
|
|
62274
|
+
const deprecationReason = value.directives?.find((d) => d.name.value === "deprecated")?.arguments?.find((a) => a.name.value === "reason")?.value?.value;
|
|
62275
|
+
if (value.description || deprecationReason)
|
|
62276
|
+
prop.comments = [
|
|
62277
|
+
jsdocComment(value.description?.value ?? "", deprecationReason)
|
|
62278
|
+
];
|
|
62279
|
+
return prop;
|
|
62452
62280
|
}) || []
|
|
62453
62281
|
)
|
|
62454
62282
|
);
|
|
62283
|
+
if (defn.description) {
|
|
62284
|
+
declaration.comments = [
|
|
62285
|
+
AST13.commentBlock(`* ${defn.description.value} `, true, false)
|
|
62286
|
+
];
|
|
62287
|
+
}
|
|
62288
|
+
return declaration;
|
|
62455
62289
|
})
|
|
62456
62290
|
)
|
|
62457
62291
|
);
|
|
@@ -62460,11 +62294,19 @@ type ValuesOf<T> = T[keyof T]
|
|
|
62460
62294
|
` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
|
|
62461
62295
|
const name = definition.name.value;
|
|
62462
62296
|
const values = definition.values;
|
|
62463
|
-
|
|
62297
|
+
let jsdoc = "";
|
|
62298
|
+
if (definition.description) {
|
|
62299
|
+
jsdoc = `
|
|
62300
|
+
/** ${definition.description.value} */`;
|
|
62301
|
+
}
|
|
62302
|
+
return `${jsdoc}
|
|
62464
62303
|
export declare const ${name}: {
|
|
62465
|
-
${values?.map(
|
|
62304
|
+
${values?.map(
|
|
62305
|
+
(value) => (value.description ? ` /** ${value.description.value} */
|
|
62306
|
+
` : "") + ` readonly ${value.name.value}: "${value.name.value}";`
|
|
62307
|
+
).join("\n")}
|
|
62466
62308
|
}
|
|
62467
|
-
|
|
62309
|
+
${jsdoc}
|
|
62468
62310
|
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
62469
62311
|
`;
|
|
62470
62312
|
}).join("");
|
|
@@ -62484,7 +62326,7 @@ async function schemaGenerator(config) {
|
|
|
62484
62326
|
await Promise.all([
|
|
62485
62327
|
fs_exports.writeFile(
|
|
62486
62328
|
config.definitionsSchemaPath,
|
|
62487
|
-
config.localSchema ?
|
|
62329
|
+
config.localSchema ? graphql23.printSchema(config.schema) : config.newSchema
|
|
62488
62330
|
),
|
|
62489
62331
|
fs_exports.writeFile(config.definitionsDocumentsPath, config.newDocuments),
|
|
62490
62332
|
definitionsGenerator(config)
|
|
@@ -64189,7 +64031,7 @@ function mergeGraphQLTypes(typeSource, config) {
|
|
|
64189
64031
|
}
|
|
64190
64032
|
|
|
64191
64033
|
// src/codegen/transforms/schema.ts
|
|
64192
|
-
import * as
|
|
64034
|
+
import * as graphql24 from "graphql";
|
|
64193
64035
|
async function graphqlExtensions(config, documents) {
|
|
64194
64036
|
let internalSchema = `
|
|
64195
64037
|
enum CachePolicy {
|
|
@@ -64293,7 +64135,7 @@ ${config.configFile.features?.componentFields ? `
|
|
|
64293
64135
|
"""
|
|
64294
64136
|
@${config.componentFieldDirective} marks an inline fragment as the selection for a component field
|
|
64295
64137
|
"""
|
|
64296
|
-
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
|
|
64138
|
+
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
|
|
64297
64139
|
|
|
64298
64140
|
` : ""}
|
|
64299
64141
|
|
|
@@ -64304,7 +64146,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
64304
64146
|
}
|
|
64305
64147
|
internalSchema += plugin2.schema({ config });
|
|
64306
64148
|
}
|
|
64307
|
-
|
|
64149
|
+
let extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
|
|
64308
64150
|
return `
|
|
64309
64151
|
extend type ${parent2} {
|
|
64310
64152
|
${Object.entries(fields).map(([fieldName, field]) => {
|
|
@@ -64312,29 +64154,30 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
64312
64154
|
const args = fragmentArguments(config, "", field.parent);
|
|
64313
64155
|
if (args.length > 0) {
|
|
64314
64156
|
argString = "(" + args.map((arg) => {
|
|
64315
|
-
const typeName =
|
|
64157
|
+
const typeName = graphql24.print(arg.type);
|
|
64316
64158
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
64317
64159
|
}).join("\n") + ")";
|
|
64318
64160
|
}
|
|
64319
|
-
return `${fieldName}${argString}: ${config.componentScalar}
|
|
64161
|
+
return `${fieldName}${argString}: ${config.componentScalar}! @componentField(field: "${fieldName}")`;
|
|
64320
64162
|
}).join("\n")}
|
|
64321
64163
|
}
|
|
64322
64164
|
`;
|
|
64323
64165
|
}).join("\n");
|
|
64324
|
-
config.
|
|
64166
|
+
extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
64167
|
+
config.newSchema = graphql24.print(mergeTypeDefs([internalSchema, config.newSchema]));
|
|
64325
64168
|
config.schemaString += extensions;
|
|
64326
|
-
config.schema =
|
|
64327
|
-
|
|
64328
|
-
mergeTypeDefs([
|
|
64169
|
+
config.schema = graphql24.buildSchema(
|
|
64170
|
+
graphql24.print(
|
|
64171
|
+
mergeTypeDefs([graphql24.printSchema(config.schema), internalSchema, extensions])
|
|
64329
64172
|
)
|
|
64330
64173
|
);
|
|
64331
64174
|
}
|
|
64332
64175
|
|
|
64333
64176
|
// src/codegen/transforms/typename.ts
|
|
64334
|
-
import * as
|
|
64177
|
+
import * as graphql25 from "graphql";
|
|
64335
64178
|
async function addTypename(config, documents) {
|
|
64336
64179
|
for (const doc of documents) {
|
|
64337
|
-
doc.document =
|
|
64180
|
+
doc.document = graphql25.visit(doc.document, {
|
|
64338
64181
|
Field(node, key, parent2, path2, ancestors) {
|
|
64339
64182
|
if (!node.selectionSet) {
|
|
64340
64183
|
return;
|
|
@@ -64346,7 +64189,7 @@ async function addTypename(config, documents) {
|
|
|
64346
64189
|
);
|
|
64347
64190
|
const field = type.getFields()[node.name.value];
|
|
64348
64191
|
const fieldType = unwrapType(config, field.type).type;
|
|
64349
|
-
if (
|
|
64192
|
+
if (graphql25.isInterfaceType(fieldType) || graphql25.isUnionType(fieldType)) {
|
|
64350
64193
|
return {
|
|
64351
64194
|
...node,
|
|
64352
64195
|
selectionSet: {
|
|
@@ -64354,9 +64197,9 @@ async function addTypename(config, documents) {
|
|
|
64354
64197
|
selections: [
|
|
64355
64198
|
...node.selectionSet.selections,
|
|
64356
64199
|
{
|
|
64357
|
-
kind:
|
|
64200
|
+
kind: graphql25.Kind.FIELD,
|
|
64358
64201
|
name: {
|
|
64359
|
-
kind:
|
|
64202
|
+
kind: graphql25.Kind.NAME,
|
|
64360
64203
|
value: "__typename"
|
|
64361
64204
|
}
|
|
64362
64205
|
}
|
|
@@ -64373,9 +64216,9 @@ async function addTypename(config, documents) {
|
|
|
64373
64216
|
selections: [
|
|
64374
64217
|
...node.selectionSet.selections,
|
|
64375
64218
|
{
|
|
64376
|
-
kind:
|
|
64219
|
+
kind: graphql25.Kind.FIELD,
|
|
64377
64220
|
name: {
|
|
64378
|
-
kind:
|
|
64221
|
+
kind: graphql25.Kind.NAME,
|
|
64379
64222
|
value: "__typename"
|
|
64380
64223
|
}
|
|
64381
64224
|
}
|
|
@@ -64388,10 +64231,10 @@ async function addTypename(config, documents) {
|
|
|
64388
64231
|
}
|
|
64389
64232
|
|
|
64390
64233
|
// src/codegen/transforms/addID.ts
|
|
64391
|
-
import * as
|
|
64234
|
+
import * as graphql26 from "graphql";
|
|
64392
64235
|
async function addID(config, documents) {
|
|
64393
64236
|
for (const doc of documents) {
|
|
64394
|
-
doc.document =
|
|
64237
|
+
doc.document = graphql26.visit(doc.document, {
|
|
64395
64238
|
Field(node, key, parent2, path2, ancestors) {
|
|
64396
64239
|
if (!node.selectionSet) {
|
|
64397
64240
|
return;
|
|
@@ -64429,7 +64272,7 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64429
64272
|
if (!node.selectionSet || node.selectionSet.selections.length == 0) {
|
|
64430
64273
|
return;
|
|
64431
64274
|
}
|
|
64432
|
-
if (!
|
|
64275
|
+
if (!graphql26.isObjectType(fieldType) && !graphql26.isInterfaceType(fieldType)) {
|
|
64433
64276
|
return;
|
|
64434
64277
|
}
|
|
64435
64278
|
const keyFields = config.keyFieldsForType(fieldType.name);
|
|
@@ -64444,9 +64287,9 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64444
64287
|
continue;
|
|
64445
64288
|
}
|
|
64446
64289
|
selections.push({
|
|
64447
|
-
kind:
|
|
64290
|
+
kind: graphql26.Kind.FIELD,
|
|
64448
64291
|
name: {
|
|
64449
|
-
kind:
|
|
64292
|
+
kind: graphql26.Kind.NAME,
|
|
64450
64293
|
value: keyField
|
|
64451
64294
|
}
|
|
64452
64295
|
});
|
|
@@ -64461,13 +64304,13 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64461
64304
|
}
|
|
64462
64305
|
|
|
64463
64306
|
// src/codegen/transforms/componentFields.ts
|
|
64464
|
-
import * as
|
|
64307
|
+
import * as graphql27 from "graphql";
|
|
64465
64308
|
async function componentFields(config, documents) {
|
|
64466
64309
|
for (const document of documents) {
|
|
64467
|
-
const typeInfo = new
|
|
64468
|
-
document.document =
|
|
64310
|
+
const typeInfo = new graphql27.TypeInfo(config.schema);
|
|
64311
|
+
document.document = graphql27.visit(
|
|
64469
64312
|
document.document,
|
|
64470
|
-
|
|
64313
|
+
graphql27.visitWithTypeInfo(typeInfo, {
|
|
64471
64314
|
Field(node) {
|
|
64472
64315
|
const parentType = typeInfo.getParentType();
|
|
64473
64316
|
if (!parentType) {
|
|
@@ -64515,6 +64358,48 @@ async function componentFields(config, documents) {
|
|
|
64515
64358
|
}
|
|
64516
64359
|
}
|
|
64517
64360
|
|
|
64361
|
+
// src/codegen/transforms/runtimeScalars.ts
|
|
64362
|
+
import * as graphql28 from "graphql";
|
|
64363
|
+
async function addTypename2(config, documents) {
|
|
64364
|
+
for (const doc of documents) {
|
|
64365
|
+
doc.document = graphql28.visit(doc.document, {
|
|
64366
|
+
VariableDefinition(node) {
|
|
64367
|
+
const { type, wrappers } = unwrapType(config, node.type);
|
|
64368
|
+
const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
|
|
64369
|
+
if (runtimeScalar) {
|
|
64370
|
+
return {
|
|
64371
|
+
...node,
|
|
64372
|
+
type: wrapType({
|
|
64373
|
+
type: config.schema.getType(runtimeScalar.type),
|
|
64374
|
+
wrappers
|
|
64375
|
+
}),
|
|
64376
|
+
directives: [
|
|
64377
|
+
...node.directives ?? [],
|
|
64378
|
+
{
|
|
64379
|
+
kind: "Directive",
|
|
64380
|
+
name: {
|
|
64381
|
+
kind: "Name",
|
|
64382
|
+
value: config.runtimeScalarDirective
|
|
64383
|
+
},
|
|
64384
|
+
arguments: [
|
|
64385
|
+
{
|
|
64386
|
+
kind: "Argument",
|
|
64387
|
+
name: { kind: "Name", value: "type" },
|
|
64388
|
+
value: {
|
|
64389
|
+
kind: "StringValue",
|
|
64390
|
+
value: type.name
|
|
64391
|
+
}
|
|
64392
|
+
}
|
|
64393
|
+
]
|
|
64394
|
+
}
|
|
64395
|
+
]
|
|
64396
|
+
};
|
|
64397
|
+
}
|
|
64398
|
+
}
|
|
64399
|
+
});
|
|
64400
|
+
}
|
|
64401
|
+
}
|
|
64402
|
+
|
|
64518
64403
|
// src/codegen/validators/typeCheck.ts
|
|
64519
64404
|
import * as graphql29 from "graphql";
|
|
64520
64405
|
async function typeCheck(config, docs) {
|
|
@@ -65516,10 +65401,22 @@ async function componentFields2(config, docs) {
|
|
|
65516
65401
|
}
|
|
65517
65402
|
const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
|
|
65518
65403
|
const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
|
|
65404
|
+
const existingField = fieldValue && config.componentFields[parent2]?.[fieldValue];
|
|
65519
65405
|
const parentType = config.schema.getType(parent2);
|
|
65520
|
-
|
|
65406
|
+
let conflict = false;
|
|
65407
|
+
if (existingField && existingField.filepath !== filepath) {
|
|
65408
|
+
conflict = true;
|
|
65409
|
+
} else if (parentType && fieldValue) {
|
|
65410
|
+
const fieldDef = graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
65411
|
+
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
65412
|
+
(dir) => dir.name.value === config.componentFieldDirective
|
|
65413
|
+
)) {
|
|
65414
|
+
conflict = true;
|
|
65415
|
+
}
|
|
65416
|
+
}
|
|
65417
|
+
if (conflict) {
|
|
65521
65418
|
errors.push({
|
|
65522
|
-
message: `Duplicate component field definition for ${parent2}.${fieldValue}
|
|
65419
|
+
message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
|
|
65523
65420
|
filepath
|
|
65524
65421
|
});
|
|
65525
65422
|
}
|
|
@@ -65585,6 +65482,7 @@ async function runPipeline2(config, docs) {
|
|
|
65585
65482
|
[
|
|
65586
65483
|
componentFields2,
|
|
65587
65484
|
graphqlExtensions,
|
|
65485
|
+
addTypename2,
|
|
65588
65486
|
...wrapHook(beforeValidate),
|
|
65589
65487
|
typeCheck,
|
|
65590
65488
|
uniqueDocumentNames,
|
|
@@ -65718,7 +65616,7 @@ function testConfigFile({ plugins, ...config } = {}) {
|
|
|
65718
65616
|
id: ID!
|
|
65719
65617
|
name(arg: Int): String!
|
|
65720
65618
|
birthday: DateTime!
|
|
65721
|
-
firstName: String!
|
|
65619
|
+
firstName: String! @deprecated(reason: "Use name instead")
|
|
65722
65620
|
friends: [User!]!
|
|
65723
65621
|
friendsByCursor(first: Int, after: String, last: Int, before: String, filter: String): UserConnection!
|
|
65724
65622
|
friendsByCursorSnapshot(snapshot: String!, first: Int, after: String, last: Int, before: String): UserConnection!
|
|
@@ -65748,13 +65646,22 @@ function testConfigFile({ plugins, ...config } = {}) {
|
|
|
65748
65646
|
believers(first: Int, after: String): GhostConnection
|
|
65749
65647
|
}
|
|
65750
65648
|
|
|
65649
|
+
"""
|
|
65650
|
+
Cat's documentation
|
|
65651
|
+
"""
|
|
65751
65652
|
type Cat implements Friend & Node {
|
|
65752
65653
|
id: ID!
|
|
65654
|
+
"""
|
|
65655
|
+
The name of the cat
|
|
65656
|
+
"""
|
|
65753
65657
|
name: String!
|
|
65754
65658
|
owner: User!
|
|
65755
65659
|
}
|
|
65756
65660
|
|
|
65757
65661
|
type Query {
|
|
65662
|
+
"""
|
|
65663
|
+
Get a user.
|
|
65664
|
+
"""
|
|
65758
65665
|
user: User!
|
|
65759
65666
|
entity: Entity!
|
|
65760
65667
|
version: Int!
|
|
@@ -65936,11 +65843,19 @@ function testConfigFile({ plugins, ...config } = {}) {
|
|
|
65936
65843
|
id: ID!
|
|
65937
65844
|
}
|
|
65938
65845
|
|
|
65846
|
+
"""
|
|
65847
|
+
Documentation of testenum1
|
|
65848
|
+
"""
|
|
65939
65849
|
enum TestEnum1 {
|
|
65850
|
+
"Documentation of Value1"
|
|
65940
65851
|
Value1
|
|
65852
|
+
"Documentation of Value2"
|
|
65941
65853
|
Value2
|
|
65942
65854
|
}
|
|
65943
65855
|
|
|
65856
|
+
"""
|
|
65857
|
+
Documentation of testenum2
|
|
65858
|
+
"""
|
|
65944
65859
|
enum TestEnum2 {
|
|
65945
65860
|
Value3
|
|
65946
65861
|
Value2
|
|
@@ -65986,9 +65901,15 @@ function testConfigFile({ plugins, ...config } = {}) {
|
|
|
65986
65901
|
...plugins
|
|
65987
65902
|
},
|
|
65988
65903
|
features: {
|
|
65989
|
-
componentFields: true
|
|
65904
|
+
componentFields: true,
|
|
65905
|
+
imperativeCache: true,
|
|
65906
|
+
runtimeScalars: {
|
|
65907
|
+
ViewerIDFromSession: {
|
|
65908
|
+
type: "ID",
|
|
65909
|
+
resolve: ({ session }) => session.token
|
|
65910
|
+
}
|
|
65911
|
+
}
|
|
65990
65912
|
},
|
|
65991
|
-
acceptImperativeInstability: true,
|
|
65992
65913
|
...config
|
|
65993
65914
|
};
|
|
65994
65915
|
}
|
|
@@ -66006,7 +65927,7 @@ function pipelineTest(config, documents, shouldPass, testBody) {
|
|
|
66006
65927
|
await runPipeline2(config, docs);
|
|
66007
65928
|
} catch (e) {
|
|
66008
65929
|
if (shouldPass) {
|
|
66009
|
-
throw "pipeline failed when it should have passed. " + e;
|
|
65930
|
+
throw new Error("pipeline failed when it should have passed. " + e);
|
|
66010
65931
|
}
|
|
66011
65932
|
error = e;
|
|
66012
65933
|
}
|