houdini 1.2.44 → 1.2.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +651 -844
- package/build/cmd-esm/index.js +501 -694
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen-cjs/index.js +649 -842
- package/build/codegen-esm/index.js +499 -692
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/typescript.d.ts +19 -0
- package/build/lib-cjs/index.js +667 -464
- package/build/lib-esm/index.js +661 -464
- package/build/runtime/client/index.d.ts +7 -1
- package/build/runtime/client/plugins/fragment.d.ts +2 -2
- package/build/runtime/client/plugins/mutation.d.ts +2 -1
- package/build/runtime/client/plugins/query.d.ts +2 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +13 -2
- package/build/runtime/router/types.d.ts +3 -1
- package/build/runtime-cjs/client/index.d.ts +7 -1
- package/build/runtime-cjs/client/index.js +26 -11
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/fragment.js +4 -11
- package/build/runtime-cjs/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-cjs/client/plugins/mutation.js +8 -15
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/query.js +4 -11
- package/build/runtime-cjs/lib/scalars.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.js +4 -0
- package/build/runtime-cjs/lib/types.d.ts +13 -2
- package/build/runtime-cjs/router/types.d.ts +3 -1
- package/build/runtime-esm/client/index.d.ts +7 -1
- package/build/runtime-esm/client/index.js +26 -11
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-esm/client/plugins/fragment.js +1 -2
- package/build/runtime-esm/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-esm/client/plugins/mutation.js +1 -2
- package/build/runtime-esm/client/plugins/query.d.ts +2 -2
- package/build/runtime-esm/client/plugins/query.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.js +6 -0
- package/build/runtime-esm/lib/types.d.ts +13 -2
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +664 -840
- package/build/test-esm/index.js +514 -690
- package/build/vite-cjs/index.js +761 -852
- package/build/vite-esm/index.js +611 -702
- package/package.json +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +0 -8
- package/build/codegen/generators/typescript/types.d.ts +0 -10
|
@@ -53824,7 +53824,7 @@ var require_lib6 = __commonJS({
|
|
|
53824
53824
|
});
|
|
53825
53825
|
|
|
53826
53826
|
// src/codegen/index.ts
|
|
53827
|
-
import * as
|
|
53827
|
+
import * as graphql32 from "graphql";
|
|
53828
53828
|
|
|
53829
53829
|
// src/lib/pipeline.ts
|
|
53830
53830
|
async function runPipeline(config, pipeline, target) {
|
|
@@ -53965,47 +53965,6 @@ function deepMerge(...objects) {
|
|
|
53965
53965
|
return mergedObj;
|
|
53966
53966
|
}
|
|
53967
53967
|
|
|
53968
|
-
// src/runtime/lib/scalars.ts
|
|
53969
|
-
async function marshalSelection({
|
|
53970
|
-
selection,
|
|
53971
|
-
data
|
|
53972
|
-
}) {
|
|
53973
|
-
const config = getCurrentConfig();
|
|
53974
|
-
if (data === null || typeof data === "undefined") {
|
|
53975
|
-
return data;
|
|
53976
|
-
}
|
|
53977
|
-
if (Array.isArray(data)) {
|
|
53978
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
53979
|
-
}
|
|
53980
|
-
const targetSelection = getFieldsForType(selection, data["__typename"], false);
|
|
53981
|
-
return Object.fromEntries(
|
|
53982
|
-
await Promise.all(
|
|
53983
|
-
Object.entries(data).map(async ([fieldName, value]) => {
|
|
53984
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
53985
|
-
if (!type) {
|
|
53986
|
-
return [fieldName, value];
|
|
53987
|
-
}
|
|
53988
|
-
if (selection2) {
|
|
53989
|
-
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
53990
|
-
}
|
|
53991
|
-
if (config.scalars?.[type]) {
|
|
53992
|
-
const marshalFn = config.scalars[type].marshal;
|
|
53993
|
-
if (!marshalFn) {
|
|
53994
|
-
throw new Error(
|
|
53995
|
-
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
53996
|
-
);
|
|
53997
|
-
}
|
|
53998
|
-
if (Array.isArray(value)) {
|
|
53999
|
-
return [fieldName, value.map(marshalFn)];
|
|
54000
|
-
}
|
|
54001
|
-
return [fieldName, marshalFn(value)];
|
|
54002
|
-
}
|
|
54003
|
-
return [fieldName, value];
|
|
54004
|
-
})
|
|
54005
|
-
)
|
|
54006
|
-
);
|
|
54007
|
-
}
|
|
54008
|
-
|
|
54009
53968
|
// src/runtime/lib/types.ts
|
|
54010
53969
|
var CachePolicy = {
|
|
54011
53970
|
CacheOrNetwork: "CacheOrNetwork",
|
|
@@ -54033,11 +53992,6 @@ var RefetchUpdateMode = {
|
|
|
54033
53992
|
prepend: "prepend",
|
|
54034
53993
|
replace: "replace"
|
|
54035
53994
|
};
|
|
54036
|
-
var DataSource = {
|
|
54037
|
-
Cache: "cache",
|
|
54038
|
-
Network: "network",
|
|
54039
|
-
Ssr: "ssr"
|
|
54040
|
-
};
|
|
54041
53995
|
var fragmentKey = " $fragments";
|
|
54042
53996
|
var PendingValue = Symbol("houdini_loading");
|
|
54043
53997
|
|
|
@@ -56659,202 +56613,6 @@ var cache_default = new Cache();
|
|
|
56659
56613
|
// src/runtime/client/plugins/cache.ts
|
|
56660
56614
|
var serverSide = typeof globalThis.window === "undefined";
|
|
56661
56615
|
|
|
56662
|
-
// src/runtime/client/utils/documentPlugins.ts
|
|
56663
|
-
var documentPlugin = (kind, source) => {
|
|
56664
|
-
return () => {
|
|
56665
|
-
const sourceHandlers = source();
|
|
56666
|
-
const enterWrapper = (handler) => {
|
|
56667
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
56668
|
-
if (ctx.artifact.kind !== kind) {
|
|
56669
|
-
return handlers.next(ctx);
|
|
56670
|
-
}
|
|
56671
|
-
return handler(ctx, handlers);
|
|
56672
|
-
};
|
|
56673
|
-
};
|
|
56674
|
-
const exitWrapper = (handler) => {
|
|
56675
|
-
return !handler ? void 0 : (ctx, handlers) => {
|
|
56676
|
-
if (ctx.artifact.kind !== kind) {
|
|
56677
|
-
return handlers.resolve(ctx);
|
|
56678
|
-
}
|
|
56679
|
-
return handler(ctx, handlers);
|
|
56680
|
-
};
|
|
56681
|
-
};
|
|
56682
|
-
return {
|
|
56683
|
-
start: enterWrapper(sourceHandlers.start),
|
|
56684
|
-
network: enterWrapper(sourceHandlers.network),
|
|
56685
|
-
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
56686
|
-
end: exitWrapper(sourceHandlers.end),
|
|
56687
|
-
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
56688
|
-
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
56689
|
-
};
|
|
56690
|
-
};
|
|
56691
|
-
};
|
|
56692
|
-
|
|
56693
|
-
// src/runtime/client/plugins/query.ts
|
|
56694
|
-
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
56695
|
-
let subscriptionSpec = null;
|
|
56696
|
-
let lastVariables = null;
|
|
56697
|
-
return {
|
|
56698
|
-
start(ctx, { next }) {
|
|
56699
|
-
const runtimeScalarPayload = {
|
|
56700
|
-
session: ctx.session
|
|
56701
|
-
};
|
|
56702
|
-
ctx.variables = {
|
|
56703
|
-
...lastVariables,
|
|
56704
|
-
...Object.fromEntries(
|
|
56705
|
-
Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
|
|
56706
|
-
([field, type]) => {
|
|
56707
|
-
const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
|
|
56708
|
-
if (!runtimeScalar) {
|
|
56709
|
-
return [field, type];
|
|
56710
|
-
}
|
|
56711
|
-
return [field, runtimeScalar.resolve(runtimeScalarPayload)];
|
|
56712
|
-
}
|
|
56713
|
-
)
|
|
56714
|
-
),
|
|
56715
|
-
...ctx.variables
|
|
56716
|
-
};
|
|
56717
|
-
next(ctx);
|
|
56718
|
-
},
|
|
56719
|
-
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
56720
|
-
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56721
|
-
if (subscriptionSpec) {
|
|
56722
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56723
|
-
}
|
|
56724
|
-
lastVariables = { ...marshalVariables(ctx) };
|
|
56725
|
-
const variables = lastVariables;
|
|
56726
|
-
subscriptionSpec = {
|
|
56727
|
-
rootType: ctx.artifact.rootType,
|
|
56728
|
-
selection: ctx.artifact.selection,
|
|
56729
|
-
variables: () => variables,
|
|
56730
|
-
set: (newValue) => {
|
|
56731
|
-
resolve2(ctx, {
|
|
56732
|
-
data: newValue,
|
|
56733
|
-
errors: null,
|
|
56734
|
-
fetching: false,
|
|
56735
|
-
partial: false,
|
|
56736
|
-
stale: false,
|
|
56737
|
-
source: DataSource.Cache,
|
|
56738
|
-
variables: ctx.variables ?? {}
|
|
56739
|
-
});
|
|
56740
|
-
}
|
|
56741
|
-
};
|
|
56742
|
-
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
56743
|
-
}
|
|
56744
|
-
resolve2(ctx);
|
|
56745
|
-
},
|
|
56746
|
-
cleanup() {
|
|
56747
|
-
if (subscriptionSpec) {
|
|
56748
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56749
|
-
lastVariables = null;
|
|
56750
|
-
}
|
|
56751
|
-
}
|
|
56752
|
-
};
|
|
56753
|
-
});
|
|
56754
|
-
|
|
56755
|
-
// src/runtime/client/plugins/fragment.ts
|
|
56756
|
-
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
56757
|
-
let subscriptionSpec = null;
|
|
56758
|
-
let lastReference = null;
|
|
56759
|
-
return {
|
|
56760
|
-
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
56761
|
-
if (!ctx.stuff.parentID) {
|
|
56762
|
-
return next(ctx);
|
|
56763
|
-
}
|
|
56764
|
-
const currentReference = {
|
|
56765
|
-
parent: ctx.stuff.parentID,
|
|
56766
|
-
variables: marshalVariables(ctx)
|
|
56767
|
-
};
|
|
56768
|
-
if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
56769
|
-
if (subscriptionSpec) {
|
|
56770
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56771
|
-
}
|
|
56772
|
-
const variables = marshalVariables(ctx);
|
|
56773
|
-
subscriptionSpec = {
|
|
56774
|
-
rootType: ctx.artifact.rootType,
|
|
56775
|
-
selection: ctx.artifact.selection,
|
|
56776
|
-
variables: () => variables,
|
|
56777
|
-
parentID: ctx.stuff.parentID,
|
|
56778
|
-
set: (newValue) => {
|
|
56779
|
-
resolve2(ctx, {
|
|
56780
|
-
data: newValue,
|
|
56781
|
-
errors: null,
|
|
56782
|
-
fetching: false,
|
|
56783
|
-
partial: false,
|
|
56784
|
-
stale: false,
|
|
56785
|
-
source: DataSource.Cache,
|
|
56786
|
-
variables
|
|
56787
|
-
});
|
|
56788
|
-
}
|
|
56789
|
-
};
|
|
56790
|
-
cache_default.subscribe(subscriptionSpec, variables);
|
|
56791
|
-
lastReference = currentReference;
|
|
56792
|
-
}
|
|
56793
|
-
next(ctx);
|
|
56794
|
-
},
|
|
56795
|
-
cleanup() {
|
|
56796
|
-
if (subscriptionSpec) {
|
|
56797
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56798
|
-
}
|
|
56799
|
-
}
|
|
56800
|
-
};
|
|
56801
|
-
});
|
|
56802
|
-
|
|
56803
|
-
// src/runtime/client/plugins/mutation.ts
|
|
56804
|
-
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56805
|
-
return {
|
|
56806
|
-
async start(ctx, { next, marshalVariables }) {
|
|
56807
|
-
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
56808
|
-
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
56809
|
-
let toNotify = [];
|
|
56810
|
-
if (optimisticResponse) {
|
|
56811
|
-
toNotify = cache_default.write({
|
|
56812
|
-
selection: ctx.artifact.selection,
|
|
56813
|
-
data: await marshalSelection({
|
|
56814
|
-
selection: ctx.artifact.selection,
|
|
56815
|
-
data: optimisticResponse
|
|
56816
|
-
}),
|
|
56817
|
-
variables: marshalVariables(ctx),
|
|
56818
|
-
layer: layerOptimistic.id
|
|
56819
|
-
});
|
|
56820
|
-
}
|
|
56821
|
-
ctx.cacheParams = {
|
|
56822
|
-
...ctx.cacheParams,
|
|
56823
|
-
layer: layerOptimistic,
|
|
56824
|
-
notifySubscribers: toNotify,
|
|
56825
|
-
forceNotify: true
|
|
56826
|
-
};
|
|
56827
|
-
next(ctx);
|
|
56828
|
-
},
|
|
56829
|
-
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
56830
|
-
if (ctx.cacheParams?.layer) {
|
|
56831
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56832
|
-
}
|
|
56833
|
-
resolve2(ctx);
|
|
56834
|
-
},
|
|
56835
|
-
end(ctx, { resolve: resolve2, value }) {
|
|
56836
|
-
const hasErrors = value.errors && value.errors.length > 0;
|
|
56837
|
-
if (hasErrors) {
|
|
56838
|
-
if (ctx.cacheParams?.layer) {
|
|
56839
|
-
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56840
|
-
}
|
|
56841
|
-
}
|
|
56842
|
-
if (ctx.cacheParams?.layer) {
|
|
56843
|
-
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
56844
|
-
}
|
|
56845
|
-
resolve2(ctx);
|
|
56846
|
-
},
|
|
56847
|
-
catch(ctx, { error }) {
|
|
56848
|
-
if (ctx.cacheParams?.layer) {
|
|
56849
|
-
const { layer } = ctx.cacheParams;
|
|
56850
|
-
cache_default.clearLayer(layer.id);
|
|
56851
|
-
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
56852
|
-
}
|
|
56853
|
-
throw error;
|
|
56854
|
-
}
|
|
56855
|
-
};
|
|
56856
|
-
});
|
|
56857
|
-
|
|
56858
56616
|
// src/lib/types.ts
|
|
56859
56617
|
var LogLevel = {
|
|
56860
56618
|
Full: "full",
|
|
@@ -56972,7 +56730,7 @@ function definitionFromAncestors(ancestors) {
|
|
|
56972
56730
|
}
|
|
56973
56731
|
return { parents, definition };
|
|
56974
56732
|
}
|
|
56975
|
-
function unwrapType(config, type, wrappers = []) {
|
|
56733
|
+
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
56976
56734
|
if (type.kind === "NonNullType") {
|
|
56977
56735
|
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
56978
56736
|
}
|
|
@@ -56988,6 +56746,11 @@ function unwrapType(config, type, wrappers = []) {
|
|
|
56988
56746
|
if (type instanceof graphql3.GraphQLList) {
|
|
56989
56747
|
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
56990
56748
|
}
|
|
56749
|
+
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
56750
|
+
type = config.schema.getType(
|
|
56751
|
+
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
56752
|
+
);
|
|
56753
|
+
}
|
|
56991
56754
|
const namedType = config.schema.getType(type.name.value || type.name);
|
|
56992
56755
|
if (!namedType) {
|
|
56993
56756
|
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
@@ -57127,6 +56890,152 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
57127
56890
|
return allFilesNotInList;
|
|
57128
56891
|
}
|
|
57129
56892
|
|
|
56893
|
+
// src/lib/typescript.ts
|
|
56894
|
+
var recast2 = __toESM(require_main2(), 1);
|
|
56895
|
+
import * as graphql4 from "graphql";
|
|
56896
|
+
var AST2 = recast2.types.builders;
|
|
56897
|
+
function unwrappedTsTypeReference(config, filepath, missingScalars, {
|
|
56898
|
+
type,
|
|
56899
|
+
wrappers
|
|
56900
|
+
}, body) {
|
|
56901
|
+
let result;
|
|
56902
|
+
if (graphql4.isScalarType(type)) {
|
|
56903
|
+
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
56904
|
+
} else if (graphql4.isEnumType(type)) {
|
|
56905
|
+
result = enumReference(config, body, type.name);
|
|
56906
|
+
} else {
|
|
56907
|
+
result = AST2.tsTypeReference(AST2.identifier(type.name));
|
|
56908
|
+
}
|
|
56909
|
+
for (const toWrap of wrappers) {
|
|
56910
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
56911
|
+
continue;
|
|
56912
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
56913
|
+
result = nullableField(result, true);
|
|
56914
|
+
} else if (toWrap === "List" /* List */) {
|
|
56915
|
+
result = AST2.tsArrayType(AST2.tsParenthesizedType(result));
|
|
56916
|
+
}
|
|
56917
|
+
}
|
|
56918
|
+
return result;
|
|
56919
|
+
}
|
|
56920
|
+
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
56921
|
+
const { type, wrappers } = unwrapType(config, definition.type);
|
|
56922
|
+
return unwrappedTsTypeReference(
|
|
56923
|
+
config,
|
|
56924
|
+
filepath,
|
|
56925
|
+
missingScalars,
|
|
56926
|
+
{ type, wrappers },
|
|
56927
|
+
body
|
|
56928
|
+
);
|
|
56929
|
+
}
|
|
56930
|
+
function enumReference(config, body, name) {
|
|
56931
|
+
ensureImports({
|
|
56932
|
+
config,
|
|
56933
|
+
body,
|
|
56934
|
+
import: ["ValueOf"],
|
|
56935
|
+
importKind: "type",
|
|
56936
|
+
sourceModule: "$houdini/runtime/lib/types"
|
|
56937
|
+
});
|
|
56938
|
+
return AST2.tsTypeReference(
|
|
56939
|
+
AST2.identifier("ValueOf"),
|
|
56940
|
+
AST2.tsTypeParameterInstantiation([AST2.tsTypeQuery(AST2.identifier(name))])
|
|
56941
|
+
);
|
|
56942
|
+
}
|
|
56943
|
+
function readonlyProperty(prop, enable = true) {
|
|
56944
|
+
if (enable) {
|
|
56945
|
+
prop.readonly = true;
|
|
56946
|
+
}
|
|
56947
|
+
return prop;
|
|
56948
|
+
}
|
|
56949
|
+
function nullableField(inner, input = false) {
|
|
56950
|
+
const members = [inner, AST2.tsNullKeyword()];
|
|
56951
|
+
if (input) {
|
|
56952
|
+
members.push(AST2.tsUndefinedKeyword());
|
|
56953
|
+
}
|
|
56954
|
+
return AST2.tsUnionType(members);
|
|
56955
|
+
}
|
|
56956
|
+
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
56957
|
+
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
56958
|
+
if (!field) {
|
|
56959
|
+
return AST2.tsNeverKeyword();
|
|
56960
|
+
}
|
|
56961
|
+
const component = config.componentFields[field.parent][field.field];
|
|
56962
|
+
const sourcePathRelative = path_exports.relative(
|
|
56963
|
+
path_exports.join(config.projectRoot, "src"),
|
|
56964
|
+
component.filepath
|
|
56965
|
+
);
|
|
56966
|
+
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
56967
|
+
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
56968
|
+
const localImport = ensureImports({
|
|
56969
|
+
config,
|
|
56970
|
+
body,
|
|
56971
|
+
import: "__component__" + component.fragment,
|
|
56972
|
+
sourceModule: path_exports.join(
|
|
56973
|
+
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
56974
|
+
"src",
|
|
56975
|
+
sourcePath
|
|
56976
|
+
)
|
|
56977
|
+
}) ?? "__component__" + component.fragment;
|
|
56978
|
+
const parameters = AST2.tsTypeReference(AST2.identifier("Parameters"));
|
|
56979
|
+
parameters.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
56980
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
56981
|
+
]);
|
|
56982
|
+
const indexed = AST2.tsIndexedAccessType(
|
|
56983
|
+
parameters,
|
|
56984
|
+
AST2.tsLiteralType(AST2.numericLiteral(0))
|
|
56985
|
+
);
|
|
56986
|
+
const omit = AST2.tsTypeReference(AST2.identifier("Omit"));
|
|
56987
|
+
omit.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
56988
|
+
indexed,
|
|
56989
|
+
AST2.tsLiteralType(AST2.stringLiteral(component.prop))
|
|
56990
|
+
]);
|
|
56991
|
+
const arg = AST2.identifier("props");
|
|
56992
|
+
arg.typeAnnotation = AST2.tsTypeAnnotation(omit);
|
|
56993
|
+
const returnType = AST2.tsTypeReference(AST2.identifier("ReturnType"));
|
|
56994
|
+
returnType.typeParameters = AST2.tsTypeParameterInstantiation([
|
|
56995
|
+
AST2.tsTypeQuery(AST2.identifier(localImport))
|
|
56996
|
+
]);
|
|
56997
|
+
const fnType = AST2.tsFunctionType([arg]);
|
|
56998
|
+
fnType.typeAnnotation = AST2.tsTypeAnnotation(returnType);
|
|
56999
|
+
return fnType;
|
|
57000
|
+
}
|
|
57001
|
+
switch (target.name) {
|
|
57002
|
+
case "String": {
|
|
57003
|
+
return AST2.tsStringKeyword();
|
|
57004
|
+
}
|
|
57005
|
+
case "Int": {
|
|
57006
|
+
return AST2.tsNumberKeyword();
|
|
57007
|
+
}
|
|
57008
|
+
case "Float": {
|
|
57009
|
+
return AST2.tsNumberKeyword();
|
|
57010
|
+
}
|
|
57011
|
+
case "Boolean": {
|
|
57012
|
+
return AST2.tsBooleanKeyword();
|
|
57013
|
+
}
|
|
57014
|
+
case "ID": {
|
|
57015
|
+
return AST2.tsStringKeyword();
|
|
57016
|
+
}
|
|
57017
|
+
default: {
|
|
57018
|
+
if (graphql4.isNonNullType(target) && "ofType" in target) {
|
|
57019
|
+
return scalarPropertyValue(
|
|
57020
|
+
config,
|
|
57021
|
+
filepath,
|
|
57022
|
+
missingScalars,
|
|
57023
|
+
target.ofType,
|
|
57024
|
+
body,
|
|
57025
|
+
field
|
|
57026
|
+
);
|
|
57027
|
+
}
|
|
57028
|
+
if (config.scalars?.[target.name]) {
|
|
57029
|
+
return AST2.tsTypeReference(AST2.identifier(config.scalars?.[target.name].type));
|
|
57030
|
+
}
|
|
57031
|
+
if (target.name !== config.componentScalar) {
|
|
57032
|
+
missingScalars.add(target.name);
|
|
57033
|
+
}
|
|
57034
|
+
return AST2.tsAnyKeyword();
|
|
57035
|
+
}
|
|
57036
|
+
}
|
|
57037
|
+
}
|
|
57038
|
+
|
|
57130
57039
|
// ../../node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
|
|
57131
57040
|
var WalkerBase = class {
|
|
57132
57041
|
constructor() {
|
|
@@ -57240,7 +57149,7 @@ async function asyncWalk(ast, { enter, leave }) {
|
|
|
57240
57149
|
}
|
|
57241
57150
|
|
|
57242
57151
|
// src/lib/walk.ts
|
|
57243
|
-
import * as
|
|
57152
|
+
import * as graphql5 from "graphql";
|
|
57244
57153
|
async function find_graphql(config, parsedScript, walker) {
|
|
57245
57154
|
await asyncWalk(parsedScript, {
|
|
57246
57155
|
async enter(node, parent2) {
|
|
@@ -57295,7 +57204,7 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
57295
57204
|
} else if (!documentString) {
|
|
57296
57205
|
return;
|
|
57297
57206
|
}
|
|
57298
|
-
const parsedTag =
|
|
57207
|
+
const parsedTag = graphql5.parse(documentString);
|
|
57299
57208
|
if (walker.where && !walker.where(parsedTag, { node, parent: parent2 })) {
|
|
57300
57209
|
return;
|
|
57301
57210
|
}
|
|
@@ -57427,7 +57336,7 @@ function extractAnonymousQuery(config, raw, expr, propName) {
|
|
|
57427
57336
|
};
|
|
57428
57337
|
return defs.concat([
|
|
57429
57338
|
{
|
|
57430
|
-
raw:
|
|
57339
|
+
raw: graphql5.print(parsed),
|
|
57431
57340
|
parsed
|
|
57432
57341
|
}
|
|
57433
57342
|
]);
|
|
@@ -57442,11 +57351,11 @@ function extractAnonymousQuery(config, raw, expr, propName) {
|
|
|
57442
57351
|
|
|
57443
57352
|
// src/lib/router/manifest.ts
|
|
57444
57353
|
var t = __toESM(require_lib6(), 1);
|
|
57445
|
-
import * as
|
|
57354
|
+
import * as graphql6 from "graphql";
|
|
57446
57355
|
|
|
57447
57356
|
// src/codegen/generators/artifacts/index.ts
|
|
57448
|
-
var
|
|
57449
|
-
import * as
|
|
57357
|
+
var recast5 = __toESM(require_main2(), 1);
|
|
57358
|
+
import * as graphql17 from "graphql";
|
|
57450
57359
|
|
|
57451
57360
|
// src/codegen/utils/commonjs.ts
|
|
57452
57361
|
var cjsIndexFilePreamble = `"use strict";
|
|
@@ -57688,19 +57597,19 @@ var FieldCollection = class {
|
|
|
57688
57597
|
};
|
|
57689
57598
|
|
|
57690
57599
|
// src/codegen/utils/moduleExport.ts
|
|
57691
|
-
var
|
|
57692
|
-
var
|
|
57600
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
57601
|
+
var AST3 = recast3.types.builders;
|
|
57693
57602
|
function moduleExport(config, key, value) {
|
|
57694
57603
|
if (config.module === "commonjs") {
|
|
57695
|
-
let target =
|
|
57604
|
+
let target = AST3.memberExpression(AST3.identifier("module"), AST3.identifier("exports"));
|
|
57696
57605
|
if (key !== "default") {
|
|
57697
|
-
target =
|
|
57606
|
+
target = AST3.memberExpression(target, AST3.identifier(key));
|
|
57698
57607
|
}
|
|
57699
|
-
return
|
|
57608
|
+
return AST3.expressionStatement(AST3.assignmentExpression("=", target, value));
|
|
57700
57609
|
}
|
|
57701
|
-
return key === "default" ?
|
|
57702
|
-
|
|
57703
|
-
|
|
57610
|
+
return key === "default" ? AST3.exportDefaultDeclaration(value) : AST3.exportNamedDeclaration(
|
|
57611
|
+
AST3.variableDeclaration("const", [
|
|
57612
|
+
AST3.variableDeclarator(AST3.identifier(key), value)
|
|
57704
57613
|
])
|
|
57705
57614
|
);
|
|
57706
57615
|
}
|
|
@@ -57957,7 +57866,7 @@ var serialize = (value, { json, lossy } = {}) => {
|
|
|
57957
57866
|
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));
|
|
57958
57867
|
|
|
57959
57868
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57960
|
-
import * as
|
|
57869
|
+
import * as graphql8 from "graphql";
|
|
57961
57870
|
|
|
57962
57871
|
// src/codegen/utils/stripLoc.ts
|
|
57963
57872
|
function stripLoc(value) {
|
|
@@ -57978,7 +57887,7 @@ function stripLoc(value) {
|
|
|
57978
57887
|
}
|
|
57979
57888
|
|
|
57980
57889
|
// src/codegen/transforms/collectDefinitions.ts
|
|
57981
|
-
import * as
|
|
57890
|
+
import * as graphql7 from "graphql";
|
|
57982
57891
|
import { Kind as GraphqlKinds } from "graphql";
|
|
57983
57892
|
async function includeFragmentDefinitions(config, documents) {
|
|
57984
57893
|
const fragments = collectDefinitions(config, documents);
|
|
@@ -58028,10 +57937,10 @@ function collectDefinitions(config, docs) {
|
|
|
58028
57937
|
}
|
|
58029
57938
|
function findRequiredFragments(config, definition) {
|
|
58030
57939
|
const referencedFragments = [];
|
|
58031
|
-
const typeInfo = new
|
|
58032
|
-
definition.selectionSet =
|
|
57940
|
+
const typeInfo = new graphql7.TypeInfo(config.schema);
|
|
57941
|
+
definition.selectionSet = graphql7.visit(
|
|
58033
57942
|
definition,
|
|
58034
|
-
|
|
57943
|
+
graphql7.visitWithTypeInfo(typeInfo, {
|
|
58035
57944
|
FragmentSpread(node) {
|
|
58036
57945
|
referencedFragments.push(node.name.value);
|
|
58037
57946
|
}
|
|
@@ -58065,7 +57974,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
58065
57974
|
}
|
|
58066
57975
|
|
|
58067
57976
|
// src/codegen/transforms/fragmentVariables.ts
|
|
58068
|
-
var GraphqlKinds2 =
|
|
57977
|
+
var GraphqlKinds2 = graphql8.Kind;
|
|
58069
57978
|
async function fragmentVariables(config, documents) {
|
|
58070
57979
|
const fragments = collectDefinitions(config, documents);
|
|
58071
57980
|
const generatedFragments = {};
|
|
@@ -58088,7 +57997,7 @@ async function fragmentVariables(config, documents) {
|
|
|
58088
57997
|
});
|
|
58089
57998
|
}
|
|
58090
57999
|
const doc = {
|
|
58091
|
-
kind:
|
|
58000
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
58092
58001
|
definitions: Object.values(generatedFragments)
|
|
58093
58002
|
};
|
|
58094
58003
|
documents.push({
|
|
@@ -58159,7 +58068,7 @@ function inlineFragmentArgs({
|
|
|
58159
58068
|
return null;
|
|
58160
58069
|
};
|
|
58161
58070
|
const result = esm_default(
|
|
58162
|
-
|
|
58071
|
+
graphql8.visit(document, {
|
|
58163
58072
|
FragmentSpread(node) {
|
|
58164
58073
|
if (!fragmentDefinitions[node.name.value]) {
|
|
58165
58074
|
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
@@ -58245,7 +58154,7 @@ function inlineFragmentArgs({
|
|
|
58245
58154
|
);
|
|
58246
58155
|
if (newName) {
|
|
58247
58156
|
result.name = {
|
|
58248
|
-
kind:
|
|
58157
|
+
kind: graphql8.Kind.NAME,
|
|
58249
58158
|
value: newName
|
|
58250
58159
|
};
|
|
58251
58160
|
}
|
|
@@ -58412,7 +58321,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
58412
58321
|
}
|
|
58413
58322
|
|
|
58414
58323
|
// src/codegen/generators/artifacts/inputs.ts
|
|
58415
|
-
import * as
|
|
58324
|
+
import * as graphql9 from "graphql";
|
|
58416
58325
|
function inputObject(config, inputs, runtimeScalars) {
|
|
58417
58326
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
58418
58327
|
const inputObj = {
|
|
@@ -58442,10 +58351,10 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
58442
58351
|
if (visitedTypes.has(type.name)) {
|
|
58443
58352
|
return;
|
|
58444
58353
|
}
|
|
58445
|
-
if (
|
|
58354
|
+
if (graphql9.isEnumType(type) || graphql9.isScalarType(type)) {
|
|
58446
58355
|
return;
|
|
58447
58356
|
}
|
|
58448
|
-
if (
|
|
58357
|
+
if (graphql9.isUnionType(type)) {
|
|
58449
58358
|
return;
|
|
58450
58359
|
}
|
|
58451
58360
|
visitedTypes.add(type.name);
|
|
@@ -58463,50 +58372,50 @@ function walkInputs(config, visitedTypes, inputObj, rootType) {
|
|
|
58463
58372
|
}
|
|
58464
58373
|
|
|
58465
58374
|
// src/codegen/generators/artifacts/operations.ts
|
|
58466
|
-
import * as
|
|
58375
|
+
import * as graphql11 from "graphql";
|
|
58467
58376
|
|
|
58468
58377
|
// src/codegen/generators/artifacts/utils.ts
|
|
58469
|
-
var
|
|
58470
|
-
import * as
|
|
58471
|
-
var
|
|
58378
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
58379
|
+
import * as graphql10 from "graphql";
|
|
58380
|
+
var AST4 = recast4.types.builders;
|
|
58472
58381
|
function serializeValue(value) {
|
|
58473
58382
|
if (Array.isArray(value)) {
|
|
58474
|
-
return
|
|
58383
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
58475
58384
|
}
|
|
58476
58385
|
if (typeof value === "object" && value !== null) {
|
|
58477
|
-
return
|
|
58386
|
+
return AST4.objectExpression(
|
|
58478
58387
|
Object.entries(value).filter(([key, value2]) => typeof value2 !== "undefined").map(([key, val]) => {
|
|
58479
|
-
return
|
|
58388
|
+
return AST4.objectProperty(AST4.stringLiteral(key), serializeValue(val));
|
|
58480
58389
|
})
|
|
58481
58390
|
);
|
|
58482
58391
|
}
|
|
58483
58392
|
if (typeof value === "string") {
|
|
58484
58393
|
if (value.indexOf("\n") !== -1) {
|
|
58485
|
-
return
|
|
58486
|
-
[
|
|
58394
|
+
return AST4.templateLiteral(
|
|
58395
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
58487
58396
|
[]
|
|
58488
58397
|
);
|
|
58489
58398
|
}
|
|
58490
|
-
return
|
|
58399
|
+
return AST4.stringLiteral(value);
|
|
58491
58400
|
}
|
|
58492
|
-
return
|
|
58401
|
+
return AST4.literal(value);
|
|
58493
58402
|
}
|
|
58494
58403
|
function convertValue(config, val) {
|
|
58495
58404
|
let value;
|
|
58496
58405
|
let kind;
|
|
58497
|
-
if (val.kind ===
|
|
58406
|
+
if (val.kind === graphql10.Kind.INT) {
|
|
58498
58407
|
value = parseInt(val.value, 10);
|
|
58499
58408
|
kind = "Int";
|
|
58500
|
-
} else if (val.kind ===
|
|
58409
|
+
} else if (val.kind === graphql10.Kind.FLOAT) {
|
|
58501
58410
|
value = parseFloat(val.value);
|
|
58502
58411
|
kind = "Float";
|
|
58503
|
-
} else if (val.kind ===
|
|
58412
|
+
} else if (val.kind === graphql10.Kind.BOOLEAN) {
|
|
58504
58413
|
value = val.value;
|
|
58505
58414
|
kind = "Boolean";
|
|
58506
|
-
} else if (val.kind ===
|
|
58415
|
+
} else if (val.kind === graphql10.Kind.VARIABLE) {
|
|
58507
58416
|
value = val.name.value;
|
|
58508
58417
|
kind = "Variable";
|
|
58509
|
-
} else if (val.kind ===
|
|
58418
|
+
} else if (val.kind === graphql10.Kind.STRING) {
|
|
58510
58419
|
value = val.value;
|
|
58511
58420
|
kind = "String";
|
|
58512
58421
|
}
|
|
@@ -58519,7 +58428,7 @@ function operationsByPath(config, filepath, definition, filterTypes) {
|
|
|
58519
58428
|
return {};
|
|
58520
58429
|
}
|
|
58521
58430
|
const pathOperations = {};
|
|
58522
|
-
|
|
58431
|
+
graphql11.visit(definition, {
|
|
58523
58432
|
FragmentSpread(node, _, __, ___, ancestors) {
|
|
58524
58433
|
if (!config.isListFragment(node.name.value)) {
|
|
58525
58434
|
return;
|
|
@@ -58678,19 +58587,19 @@ function ancestorKey(ancestors) {
|
|
|
58678
58587
|
}
|
|
58679
58588
|
|
|
58680
58589
|
// src/codegen/generators/artifacts/selection.ts
|
|
58681
|
-
import * as
|
|
58590
|
+
import * as graphql16 from "graphql";
|
|
58682
58591
|
|
|
58683
58592
|
// src/codegen/transforms/list.ts
|
|
58684
|
-
import * as
|
|
58593
|
+
import * as graphql14 from "graphql";
|
|
58685
58594
|
|
|
58686
58595
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
58687
|
-
import * as
|
|
58596
|
+
import * as graphql12 from "graphql";
|
|
58688
58597
|
var objectIdentificationSelection = (config, type) => {
|
|
58689
58598
|
return config.keyFieldsForType(type.name).map((key) => {
|
|
58690
58599
|
return {
|
|
58691
|
-
kind:
|
|
58600
|
+
kind: graphql12.Kind.FIELD,
|
|
58692
58601
|
name: {
|
|
58693
|
-
kind:
|
|
58602
|
+
kind: graphql12.Kind.NAME,
|
|
58694
58603
|
value: key
|
|
58695
58604
|
}
|
|
58696
58605
|
};
|
|
@@ -58698,7 +58607,7 @@ var objectIdentificationSelection = (config, type) => {
|
|
|
58698
58607
|
};
|
|
58699
58608
|
|
|
58700
58609
|
// src/codegen/transforms/paginate.ts
|
|
58701
|
-
import * as
|
|
58610
|
+
import * as graphql13 from "graphql";
|
|
58702
58611
|
async function paginate(config, documents) {
|
|
58703
58612
|
const newDocs = [];
|
|
58704
58613
|
for (const doc of documents) {
|
|
@@ -58731,7 +58640,7 @@ async function paginate(config, documents) {
|
|
|
58731
58640
|
};
|
|
58732
58641
|
let cursorType = "String";
|
|
58733
58642
|
let paginationPath = [];
|
|
58734
|
-
doc.document =
|
|
58643
|
+
doc.document = graphql13.visit(doc.document, {
|
|
58735
58644
|
Field(node, _, __, ___, ancestors) {
|
|
58736
58645
|
const paginateDirective = node.directives?.find(
|
|
58737
58646
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -58757,7 +58666,7 @@ async function paginate(config, documents) {
|
|
|
58757
58666
|
flags.offset.enabled = offsetPagination;
|
|
58758
58667
|
flags.limit.enabled = offsetPagination;
|
|
58759
58668
|
paginationPath = ancestors.filter(
|
|
58760
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
58669
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql13.Kind.FIELD
|
|
58761
58670
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
58762
58671
|
return {
|
|
58763
58672
|
...node,
|
|
@@ -58776,7 +58685,7 @@ async function paginate(config, documents) {
|
|
|
58776
58685
|
let fragment2 = "";
|
|
58777
58686
|
let paginateMode = config.defaultPaginateMode;
|
|
58778
58687
|
const requiredArgs = [];
|
|
58779
|
-
doc.document =
|
|
58688
|
+
doc.document = graphql13.visit(doc.document, {
|
|
58780
58689
|
OperationDefinition(node) {
|
|
58781
58690
|
if (node.operation !== "query") {
|
|
58782
58691
|
throw new HoudiniError({
|
|
@@ -58835,9 +58744,9 @@ async function paginate(config, documents) {
|
|
|
58835
58744
|
directives: [
|
|
58836
58745
|
...node.directives || [],
|
|
58837
58746
|
{
|
|
58838
|
-
kind:
|
|
58747
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
58839
58748
|
name: {
|
|
58840
|
-
kind:
|
|
58749
|
+
kind: graphql13.Kind.NAME,
|
|
58841
58750
|
value: config.argumentsDirective
|
|
58842
58751
|
}
|
|
58843
58752
|
}
|
|
@@ -58907,22 +58816,22 @@ async function paginate(config, documents) {
|
|
|
58907
58816
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
58908
58817
|
const fragmentSpreadSelection = [
|
|
58909
58818
|
{
|
|
58910
|
-
kind:
|
|
58819
|
+
kind: graphql13.Kind.FRAGMENT_SPREAD,
|
|
58911
58820
|
name: {
|
|
58912
|
-
kind:
|
|
58821
|
+
kind: graphql13.Kind.NAME,
|
|
58913
58822
|
value: fragmentName
|
|
58914
58823
|
},
|
|
58915
58824
|
directives: [
|
|
58916
58825
|
{
|
|
58917
|
-
kind:
|
|
58826
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
58918
58827
|
name: {
|
|
58919
|
-
kind:
|
|
58828
|
+
kind: graphql13.Kind.NAME,
|
|
58920
58829
|
value: config.withDirective
|
|
58921
58830
|
},
|
|
58922
58831
|
["arguments"]: requiredArgs.map((arg) => variableAsArgument(arg.name)).concat(paginationArgs.map(({ name }) => variableAsArgument(name)))
|
|
58923
58832
|
},
|
|
58924
58833
|
{
|
|
58925
|
-
kind:
|
|
58834
|
+
kind: graphql13.Kind.DIRECTIVE,
|
|
58926
58835
|
name: {
|
|
58927
58836
|
kind: "Name",
|
|
58928
58837
|
value: config.maskDisableDirective
|
|
@@ -58949,23 +58858,23 @@ async function paginate(config, documents) {
|
|
|
58949
58858
|
});
|
|
58950
58859
|
const typeConfig = config.typeConfig?.[fragment2];
|
|
58951
58860
|
const queryDoc = {
|
|
58952
|
-
kind:
|
|
58861
|
+
kind: graphql13.Kind.DOCUMENT,
|
|
58953
58862
|
definitions: [
|
|
58954
58863
|
{
|
|
58955
|
-
kind:
|
|
58864
|
+
kind: graphql13.Kind.OPERATION_DEFINITION,
|
|
58956
58865
|
name: {
|
|
58957
|
-
kind:
|
|
58866
|
+
kind: graphql13.Kind.NAME,
|
|
58958
58867
|
value: refetchQueryName
|
|
58959
58868
|
},
|
|
58960
58869
|
operation: "query",
|
|
58961
58870
|
variableDefinitions: requiredArgs.map(
|
|
58962
58871
|
(arg) => ({
|
|
58963
|
-
kind:
|
|
58872
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
58964
58873
|
type: arg.type,
|
|
58965
58874
|
variable: {
|
|
58966
|
-
kind:
|
|
58875
|
+
kind: graphql13.Kind.VARIABLE,
|
|
58967
58876
|
name: {
|
|
58968
|
-
kind:
|
|
58877
|
+
kind: graphql13.Kind.NAME,
|
|
58969
58878
|
value: arg.name
|
|
58970
58879
|
}
|
|
58971
58880
|
}
|
|
@@ -58973,18 +58882,18 @@ async function paginate(config, documents) {
|
|
|
58973
58882
|
).concat(
|
|
58974
58883
|
paginationArgs.map(
|
|
58975
58884
|
(arg) => ({
|
|
58976
|
-
kind:
|
|
58885
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
58977
58886
|
type: {
|
|
58978
|
-
kind:
|
|
58887
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
58979
58888
|
name: {
|
|
58980
|
-
kind:
|
|
58889
|
+
kind: graphql13.Kind.NAME,
|
|
58981
58890
|
value: arg.type
|
|
58982
58891
|
}
|
|
58983
58892
|
},
|
|
58984
58893
|
variable: {
|
|
58985
|
-
kind:
|
|
58894
|
+
kind: graphql13.Kind.VARIABLE,
|
|
58986
58895
|
name: {
|
|
58987
|
-
kind:
|
|
58896
|
+
kind: graphql13.Kind.NAME,
|
|
58988
58897
|
value: arg.name
|
|
58989
58898
|
}
|
|
58990
58899
|
},
|
|
@@ -58996,12 +58905,12 @@ async function paginate(config, documents) {
|
|
|
58996
58905
|
).concat(
|
|
58997
58906
|
!nodeQuery ? [] : keys2.map(
|
|
58998
58907
|
(key) => ({
|
|
58999
|
-
kind:
|
|
58908
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59000
58909
|
type: key.type,
|
|
59001
58910
|
variable: {
|
|
59002
|
-
kind:
|
|
58911
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59003
58912
|
name: {
|
|
59004
|
-
kind:
|
|
58913
|
+
kind: graphql13.Kind.NAME,
|
|
59005
58914
|
value: key.name
|
|
59006
58915
|
}
|
|
59007
58916
|
}
|
|
@@ -59010,42 +58919,42 @@ async function paginate(config, documents) {
|
|
|
59010
58919
|
)
|
|
59011
58920
|
),
|
|
59012
58921
|
selectionSet: {
|
|
59013
|
-
kind:
|
|
58922
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59014
58923
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
59015
58924
|
{
|
|
59016
|
-
kind:
|
|
58925
|
+
kind: graphql13.Kind.FIELD,
|
|
59017
58926
|
name: {
|
|
59018
|
-
kind:
|
|
58927
|
+
kind: graphql13.Kind.NAME,
|
|
59019
58928
|
value: typeConfig?.resolve?.queryField || "node"
|
|
59020
58929
|
},
|
|
59021
58930
|
["arguments"]: keys2.map((key) => ({
|
|
59022
|
-
kind:
|
|
58931
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59023
58932
|
name: {
|
|
59024
|
-
kind:
|
|
58933
|
+
kind: graphql13.Kind.NAME,
|
|
59025
58934
|
value: key.name
|
|
59026
58935
|
},
|
|
59027
58936
|
value: {
|
|
59028
|
-
kind:
|
|
58937
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59029
58938
|
name: {
|
|
59030
|
-
kind:
|
|
58939
|
+
kind: graphql13.Kind.NAME,
|
|
59031
58940
|
value: key.name
|
|
59032
58941
|
}
|
|
59033
58942
|
}
|
|
59034
58943
|
})),
|
|
59035
58944
|
selectionSet: {
|
|
59036
|
-
kind:
|
|
58945
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59037
58946
|
selections: [
|
|
59038
58947
|
{
|
|
59039
|
-
kind:
|
|
58948
|
+
kind: graphql13.Kind.FIELD,
|
|
59040
58949
|
name: {
|
|
59041
|
-
kind:
|
|
58950
|
+
kind: graphql13.Kind.NAME,
|
|
59042
58951
|
value: "__typename"
|
|
59043
58952
|
}
|
|
59044
58953
|
},
|
|
59045
58954
|
...(typeConfig?.keys || [config.defaultKeys[0]]).map((key) => ({
|
|
59046
|
-
kind:
|
|
58955
|
+
kind: graphql13.Kind.FIELD,
|
|
59047
58956
|
name: {
|
|
59048
|
-
kind:
|
|
58957
|
+
kind: graphql13.Kind.NAME,
|
|
59049
58958
|
value: key
|
|
59050
58959
|
}
|
|
59051
58960
|
})),
|
|
@@ -59102,15 +59011,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
59102
59011
|
}
|
|
59103
59012
|
function variableAsArgument(name, variable) {
|
|
59104
59013
|
return {
|
|
59105
|
-
kind:
|
|
59014
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59106
59015
|
name: {
|
|
59107
|
-
kind:
|
|
59016
|
+
kind: graphql13.Kind.NAME,
|
|
59108
59017
|
value: name
|
|
59109
59018
|
},
|
|
59110
59019
|
value: {
|
|
59111
|
-
kind:
|
|
59020
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59112
59021
|
name: {
|
|
59113
|
-
kind:
|
|
59022
|
+
kind: graphql13.Kind.NAME,
|
|
59114
59023
|
value: variable ?? name
|
|
59115
59024
|
}
|
|
59116
59025
|
}
|
|
@@ -59118,18 +59027,18 @@ function variableAsArgument(name, variable) {
|
|
|
59118
59027
|
}
|
|
59119
59028
|
function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
59120
59029
|
return {
|
|
59121
|
-
kind:
|
|
59030
|
+
kind: graphql13.Kind.VARIABLE_DEFINITION,
|
|
59122
59031
|
type: {
|
|
59123
|
-
kind:
|
|
59032
|
+
kind: graphql13.Kind.NAMED_TYPE,
|
|
59124
59033
|
name: {
|
|
59125
|
-
kind:
|
|
59034
|
+
kind: graphql13.Kind.NAME,
|
|
59126
59035
|
value: type
|
|
59127
59036
|
}
|
|
59128
59037
|
},
|
|
59129
59038
|
variable: {
|
|
59130
|
-
kind:
|
|
59039
|
+
kind: graphql13.Kind.VARIABLE,
|
|
59131
59040
|
name: {
|
|
59132
|
-
kind:
|
|
59041
|
+
kind: graphql13.Kind.NAME,
|
|
59133
59042
|
value: variableName ?? name
|
|
59134
59043
|
}
|
|
59135
59044
|
},
|
|
@@ -59141,9 +59050,9 @@ function staticVariableDefinition(name, type, defaultValue, variableName) {
|
|
|
59141
59050
|
}
|
|
59142
59051
|
function argumentNode(name, value) {
|
|
59143
59052
|
return {
|
|
59144
|
-
kind:
|
|
59053
|
+
kind: graphql13.Kind.ARGUMENT,
|
|
59145
59054
|
name: {
|
|
59146
|
-
kind:
|
|
59055
|
+
kind: graphql13.Kind.NAME,
|
|
59147
59056
|
value: name
|
|
59148
59057
|
},
|
|
59149
59058
|
value: objectNode(value)
|
|
@@ -59151,16 +59060,16 @@ function argumentNode(name, value) {
|
|
|
59151
59060
|
}
|
|
59152
59061
|
function objectNode([type, defaultValue]) {
|
|
59153
59062
|
const node = {
|
|
59154
|
-
kind:
|
|
59063
|
+
kind: graphql13.Kind.OBJECT,
|
|
59155
59064
|
fields: [
|
|
59156
59065
|
{
|
|
59157
|
-
kind:
|
|
59066
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
59158
59067
|
name: {
|
|
59159
|
-
kind:
|
|
59068
|
+
kind: graphql13.Kind.NAME,
|
|
59160
59069
|
value: "type"
|
|
59161
59070
|
},
|
|
59162
59071
|
value: {
|
|
59163
|
-
kind:
|
|
59072
|
+
kind: graphql13.Kind.STRING,
|
|
59164
59073
|
value: type
|
|
59165
59074
|
}
|
|
59166
59075
|
}
|
|
@@ -59168,8 +59077,8 @@ function objectNode([type, defaultValue]) {
|
|
|
59168
59077
|
};
|
|
59169
59078
|
if (defaultValue) {
|
|
59170
59079
|
node.fields.push({
|
|
59171
|
-
kind:
|
|
59172
|
-
name: { kind:
|
|
59080
|
+
kind: graphql13.Kind.OBJECT_FIELD,
|
|
59081
|
+
name: { kind: graphql13.Kind.NAME, value: "default" },
|
|
59173
59082
|
value: {
|
|
59174
59083
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
59175
59084
|
value: defaultValue.toString()
|
|
@@ -59180,34 +59089,34 @@ function objectNode([type, defaultValue]) {
|
|
|
59180
59089
|
}
|
|
59181
59090
|
var pageInfoSelection = [
|
|
59182
59091
|
{
|
|
59183
|
-
kind:
|
|
59092
|
+
kind: graphql13.Kind.FIELD,
|
|
59184
59093
|
name: {
|
|
59185
|
-
kind:
|
|
59094
|
+
kind: graphql13.Kind.NAME,
|
|
59186
59095
|
value: "edges"
|
|
59187
59096
|
},
|
|
59188
59097
|
selectionSet: {
|
|
59189
|
-
kind:
|
|
59098
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59190
59099
|
selections: [
|
|
59191
59100
|
{
|
|
59192
|
-
kind:
|
|
59101
|
+
kind: graphql13.Kind.FIELD,
|
|
59193
59102
|
name: {
|
|
59194
|
-
kind:
|
|
59103
|
+
kind: graphql13.Kind.NAME,
|
|
59195
59104
|
value: "cursor"
|
|
59196
59105
|
}
|
|
59197
59106
|
},
|
|
59198
59107
|
{
|
|
59199
|
-
kind:
|
|
59108
|
+
kind: graphql13.Kind.FIELD,
|
|
59200
59109
|
name: {
|
|
59201
|
-
kind:
|
|
59110
|
+
kind: graphql13.Kind.NAME,
|
|
59202
59111
|
value: "node"
|
|
59203
59112
|
},
|
|
59204
59113
|
selectionSet: {
|
|
59205
|
-
kind:
|
|
59114
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59206
59115
|
selections: [
|
|
59207
59116
|
{
|
|
59208
|
-
kind:
|
|
59117
|
+
kind: graphql13.Kind.FIELD,
|
|
59209
59118
|
name: {
|
|
59210
|
-
kind:
|
|
59119
|
+
kind: graphql13.Kind.NAME,
|
|
59211
59120
|
value: "__typename"
|
|
59212
59121
|
}
|
|
59213
59122
|
}
|
|
@@ -59218,39 +59127,39 @@ var pageInfoSelection = [
|
|
|
59218
59127
|
}
|
|
59219
59128
|
},
|
|
59220
59129
|
{
|
|
59221
|
-
kind:
|
|
59130
|
+
kind: graphql13.Kind.FIELD,
|
|
59222
59131
|
name: {
|
|
59223
|
-
kind:
|
|
59132
|
+
kind: graphql13.Kind.NAME,
|
|
59224
59133
|
value: "pageInfo"
|
|
59225
59134
|
},
|
|
59226
59135
|
selectionSet: {
|
|
59227
|
-
kind:
|
|
59136
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59228
59137
|
selections: [
|
|
59229
59138
|
{
|
|
59230
|
-
kind:
|
|
59139
|
+
kind: graphql13.Kind.FIELD,
|
|
59231
59140
|
name: {
|
|
59232
|
-
kind:
|
|
59141
|
+
kind: graphql13.Kind.NAME,
|
|
59233
59142
|
value: "hasPreviousPage"
|
|
59234
59143
|
}
|
|
59235
59144
|
},
|
|
59236
59145
|
{
|
|
59237
|
-
kind:
|
|
59146
|
+
kind: graphql13.Kind.FIELD,
|
|
59238
59147
|
name: {
|
|
59239
|
-
kind:
|
|
59148
|
+
kind: graphql13.Kind.NAME,
|
|
59240
59149
|
value: "hasNextPage"
|
|
59241
59150
|
}
|
|
59242
59151
|
},
|
|
59243
59152
|
{
|
|
59244
|
-
kind:
|
|
59153
|
+
kind: graphql13.Kind.FIELD,
|
|
59245
59154
|
name: {
|
|
59246
|
-
kind:
|
|
59155
|
+
kind: graphql13.Kind.NAME,
|
|
59247
59156
|
value: "startCursor"
|
|
59248
59157
|
}
|
|
59249
59158
|
},
|
|
59250
59159
|
{
|
|
59251
|
-
kind:
|
|
59160
|
+
kind: graphql13.Kind.FIELD,
|
|
59252
59161
|
name: {
|
|
59253
|
-
kind:
|
|
59162
|
+
kind: graphql13.Kind.NAME,
|
|
59254
59163
|
value: "endCursor"
|
|
59255
59164
|
}
|
|
59256
59165
|
}
|
|
@@ -59264,17 +59173,17 @@ async function addListFragments(config, documents) {
|
|
|
59264
59173
|
const lists = {};
|
|
59265
59174
|
const errors = [];
|
|
59266
59175
|
for (const doc of documents) {
|
|
59267
|
-
doc.document =
|
|
59176
|
+
doc.document = graphql14.visit(doc.document, {
|
|
59268
59177
|
Directive(node, key, parent2, path2, ancestors) {
|
|
59269
59178
|
if ([config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
59270
59179
|
const nameArg = node.arguments?.find(
|
|
59271
59180
|
(arg) => arg.name.value === config.listOrPaginateNameArg
|
|
59272
59181
|
);
|
|
59273
59182
|
let error = {
|
|
59274
|
-
...new
|
|
59183
|
+
...new graphql14.GraphQLError(
|
|
59275
59184
|
"",
|
|
59276
59185
|
node,
|
|
59277
|
-
new
|
|
59186
|
+
new graphql14.Source(""),
|
|
59278
59187
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
59279
59188
|
path2
|
|
59280
59189
|
),
|
|
@@ -59326,7 +59235,7 @@ async function addListFragments(config, documents) {
|
|
|
59326
59235
|
{
|
|
59327
59236
|
kind: "Argument",
|
|
59328
59237
|
name: {
|
|
59329
|
-
kind:
|
|
59238
|
+
kind: graphql14.Kind.NAME,
|
|
59330
59239
|
value: "connection"
|
|
59331
59240
|
},
|
|
59332
59241
|
value: {
|
|
@@ -59376,7 +59285,7 @@ async function addListFragments(config, documents) {
|
|
|
59376
59285
|
const validDeletes = [
|
|
59377
59286
|
...new Set(
|
|
59378
59287
|
Object.values(lists).map(({ type }) => {
|
|
59379
|
-
if (!(type instanceof
|
|
59288
|
+
if (!(type instanceof graphql14.GraphQLObjectType)) {
|
|
59380
59289
|
return "";
|
|
59381
59290
|
}
|
|
59382
59291
|
if (config.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -59390,7 +59299,7 @@ async function addListFragments(config, documents) {
|
|
|
59390
59299
|
return;
|
|
59391
59300
|
}
|
|
59392
59301
|
const generatedDoc = {
|
|
59393
|
-
kind:
|
|
59302
|
+
kind: graphql14.Kind.DOCUMENT,
|
|
59394
59303
|
definitions: Object.entries(lists).flatMap(
|
|
59395
59304
|
([name, { selection, type }]) => {
|
|
59396
59305
|
const schemaType = config.schema.getType(type.name);
|
|
@@ -59398,7 +59307,7 @@ async function addListFragments(config, documents) {
|
|
|
59398
59307
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
59399
59308
|
}
|
|
59400
59309
|
const fragmentSelection = {
|
|
59401
|
-
kind:
|
|
59310
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
59402
59311
|
selections: [...selection.selections]
|
|
59403
59312
|
};
|
|
59404
59313
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -59413,14 +59322,14 @@ async function addListFragments(config, documents) {
|
|
|
59413
59322
|
{
|
|
59414
59323
|
name: {
|
|
59415
59324
|
value: config.listInsertFragment(name),
|
|
59416
|
-
kind:
|
|
59325
|
+
kind: graphql14.Kind.NAME
|
|
59417
59326
|
},
|
|
59418
|
-
kind:
|
|
59327
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59419
59328
|
selectionSet: fragmentSelection,
|
|
59420
59329
|
typeCondition: {
|
|
59421
|
-
kind:
|
|
59330
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59422
59331
|
name: {
|
|
59423
|
-
kind:
|
|
59332
|
+
kind: graphql14.Kind.NAME,
|
|
59424
59333
|
value: type.name
|
|
59425
59334
|
}
|
|
59426
59335
|
}
|
|
@@ -59428,32 +59337,32 @@ async function addListFragments(config, documents) {
|
|
|
59428
59337
|
{
|
|
59429
59338
|
name: {
|
|
59430
59339
|
value: config.listToggleFragment(name),
|
|
59431
|
-
kind:
|
|
59340
|
+
kind: graphql14.Kind.NAME
|
|
59432
59341
|
},
|
|
59433
|
-
kind:
|
|
59342
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59434
59343
|
selectionSet: fragmentSelection,
|
|
59435
59344
|
typeCondition: {
|
|
59436
|
-
kind:
|
|
59345
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59437
59346
|
name: {
|
|
59438
|
-
kind:
|
|
59347
|
+
kind: graphql14.Kind.NAME,
|
|
59439
59348
|
value: type.name
|
|
59440
59349
|
}
|
|
59441
59350
|
}
|
|
59442
59351
|
},
|
|
59443
59352
|
{
|
|
59444
|
-
kind:
|
|
59353
|
+
kind: graphql14.Kind.FRAGMENT_DEFINITION,
|
|
59445
59354
|
name: {
|
|
59446
59355
|
value: config.listRemoveFragment(name),
|
|
59447
|
-
kind:
|
|
59356
|
+
kind: graphql14.Kind.NAME
|
|
59448
59357
|
},
|
|
59449
59358
|
selectionSet: {
|
|
59450
|
-
kind:
|
|
59359
|
+
kind: graphql14.Kind.SELECTION_SET,
|
|
59451
59360
|
selections: [...objectIdentificationSelection(config, type)]
|
|
59452
59361
|
},
|
|
59453
59362
|
typeCondition: {
|
|
59454
|
-
kind:
|
|
59363
|
+
kind: graphql14.Kind.NAMED_TYPE,
|
|
59455
59364
|
name: {
|
|
59456
|
-
kind:
|
|
59365
|
+
kind: graphql14.Kind.NAME,
|
|
59457
59366
|
value: type.name
|
|
59458
59367
|
}
|
|
59459
59368
|
}
|
|
@@ -59462,14 +59371,14 @@ async function addListFragments(config, documents) {
|
|
|
59462
59371
|
}
|
|
59463
59372
|
).concat(
|
|
59464
59373
|
...validDeletes.map((typeName) => ({
|
|
59465
|
-
kind:
|
|
59374
|
+
kind: graphql14.Kind.DIRECTIVE_DEFINITION,
|
|
59466
59375
|
name: {
|
|
59467
|
-
kind:
|
|
59376
|
+
kind: graphql14.Kind.NAME,
|
|
59468
59377
|
value: config.listDeleteDirective(typeName)
|
|
59469
59378
|
},
|
|
59470
59379
|
locations: [
|
|
59471
59380
|
{
|
|
59472
|
-
kind:
|
|
59381
|
+
kind: graphql14.Kind.NAME,
|
|
59473
59382
|
value: "FIELD"
|
|
59474
59383
|
}
|
|
59475
59384
|
],
|
|
@@ -59477,8 +59386,8 @@ async function addListFragments(config, documents) {
|
|
|
59477
59386
|
}))
|
|
59478
59387
|
)
|
|
59479
59388
|
};
|
|
59480
|
-
config.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
59481
|
-
config.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
59389
|
+
config.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
59390
|
+
config.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql14.print).join("\n\n");
|
|
59482
59391
|
documents.push({
|
|
59483
59392
|
name: "generated::lists",
|
|
59484
59393
|
kind: ArtifactKind.Fragment,
|
|
@@ -59564,11 +59473,11 @@ var nodeNotDefinedMessage = (config) => `Looks like you are trying to use the ${
|
|
|
59564
59473
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
59565
59474
|
|
|
59566
59475
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
59567
|
-
import * as
|
|
59476
|
+
import * as graphql15 from "graphql";
|
|
59568
59477
|
function fieldKey(config, field) {
|
|
59569
59478
|
const attributeName = field.alias?.value || field.name.value;
|
|
59570
|
-
const printed =
|
|
59571
|
-
const secondParse =
|
|
59479
|
+
const printed = graphql15.print(field);
|
|
59480
|
+
const secondParse = graphql15.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
59572
59481
|
let paginateMode = config.defaultPaginateMode;
|
|
59573
59482
|
const paginatedDirective = field.directives?.find(
|
|
59574
59483
|
(directive) => directive.name.value === config.paginateDirective
|
|
@@ -59691,13 +59600,13 @@ function prepareSelection({
|
|
|
59691
59600
|
} else if ("getFields" in type) {
|
|
59692
59601
|
let typeRef = type.getFields()[field.name.value].type;
|
|
59693
59602
|
fieldType = getRootType(typeRef);
|
|
59694
|
-
nullable = !
|
|
59695
|
-
} else if (
|
|
59603
|
+
nullable = !graphql16.isNonNullType(typeRef);
|
|
59604
|
+
} else if (graphql16.isAbstractType(type)) {
|
|
59696
59605
|
for (const possible of config.schema.getPossibleTypes(type)) {
|
|
59697
|
-
if (
|
|
59606
|
+
if (graphql16.isObjectType(possible)) {
|
|
59698
59607
|
if (possible.getFields()[field.name.value]) {
|
|
59699
59608
|
fieldType = possible.getFields()[field.name.value].type;
|
|
59700
|
-
nullable = !
|
|
59609
|
+
nullable = !graphql16.isNonNullType(fieldType);
|
|
59701
59610
|
break;
|
|
59702
59611
|
}
|
|
59703
59612
|
}
|
|
@@ -59834,7 +59743,7 @@ function prepareSelection({
|
|
|
59834
59743
|
kind: "value"
|
|
59835
59744
|
} : { kind: "continue" };
|
|
59836
59745
|
const parentType = config.schema.getType(rootType);
|
|
59837
|
-
if (
|
|
59746
|
+
if (graphql16.isObjectType(parentType) || graphql16.isInterfaceType(parentType)) {
|
|
59838
59747
|
const fieldType2 = parentType.getFields()[field.name.value]?.type;
|
|
59839
59748
|
if (fieldType2) {
|
|
59840
59749
|
const listCount = unwrapType(config, fieldType2).wrappers.filter(
|
|
@@ -59857,7 +59766,7 @@ function prepareSelection({
|
|
|
59857
59766
|
}
|
|
59858
59767
|
fieldObj.loading = loadingValue;
|
|
59859
59768
|
}
|
|
59860
|
-
if (
|
|
59769
|
+
if (graphql16.isInterfaceType(fieldType) || graphql16.isUnionType(fieldType)) {
|
|
59861
59770
|
fieldObj.abstract = true;
|
|
59862
59771
|
if (Object.values(fieldObj.selection?.abstractFields?.fields ?? {}).some(
|
|
59863
59772
|
(fields) => Object.values(fields ?? {}).some((field2) => field2.required)
|
|
@@ -59939,7 +59848,7 @@ function mergeSelection({
|
|
|
59939
59848
|
typeSelection,
|
|
59940
59849
|
abstractSelection.fields[typeName] ?? {}
|
|
59941
59850
|
);
|
|
59942
|
-
if (
|
|
59851
|
+
if (graphql16.isAbstractType(gqlType)) {
|
|
59943
59852
|
for (const possible of config.schema.getPossibleTypes(gqlType)) {
|
|
59944
59853
|
if (!possibleSelectionTypes[typeName]) {
|
|
59945
59854
|
possibleSelectionTypes[typeName] = [];
|
|
@@ -59974,7 +59883,7 @@ function mergeSelection({
|
|
|
59974
59883
|
}
|
|
59975
59884
|
}
|
|
59976
59885
|
const parentType = config.schema.getType(rootType);
|
|
59977
|
-
const possibleParents =
|
|
59886
|
+
const possibleParents = graphql16.isAbstractType(parentType) ? config.schema.getPossibleTypes(parentType)?.map((t2) => t2.name) : [parentType.name];
|
|
59978
59887
|
for (const key of Object.keys(abstractSelection.typeMap)) {
|
|
59979
59888
|
if (!possibleParents.includes(key) && rootType !== key || abstractSelection.fields[key]) {
|
|
59980
59889
|
delete abstractSelection.typeMap[key];
|
|
@@ -60031,12 +59940,12 @@ function mergeSelection({
|
|
|
60031
59940
|
}
|
|
60032
59941
|
|
|
60033
59942
|
// src/codegen/generators/artifacts/index.ts
|
|
60034
|
-
var
|
|
59943
|
+
var AST5 = recast5.types.builders;
|
|
60035
59944
|
function artifactGenerator(stats) {
|
|
60036
59945
|
return async function(config, docs) {
|
|
60037
59946
|
const filterTypes = {};
|
|
60038
59947
|
for (const doc of docs) {
|
|
60039
|
-
|
|
59948
|
+
graphql17.visit(doc.document, {
|
|
60040
59949
|
Directive(node, _, __, ___, ancestors) {
|
|
60041
59950
|
if (node.name.value !== config.listDirective) {
|
|
60042
59951
|
return;
|
|
@@ -60096,7 +60005,7 @@ function artifactGenerator(stats) {
|
|
|
60096
60005
|
return;
|
|
60097
60006
|
}
|
|
60098
60007
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
60099
|
-
let documentWithoutInternalDirectives =
|
|
60008
|
+
let documentWithoutInternalDirectives = graphql17.visit(document, {
|
|
60100
60009
|
Directive(node) {
|
|
60101
60010
|
if (config.isInternalDirective(node.name.value)) {
|
|
60102
60011
|
return null;
|
|
@@ -60109,7 +60018,7 @@ function artifactGenerator(stats) {
|
|
|
60109
60018
|
}
|
|
60110
60019
|
}
|
|
60111
60020
|
});
|
|
60112
|
-
let documentWithoutExtraVariables =
|
|
60021
|
+
let documentWithoutExtraVariables = graphql17.visit(
|
|
60113
60022
|
documentWithoutInternalDirectives,
|
|
60114
60023
|
{
|
|
60115
60024
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -60120,13 +60029,13 @@ function artifactGenerator(stats) {
|
|
|
60120
60029
|
}
|
|
60121
60030
|
}
|
|
60122
60031
|
);
|
|
60123
|
-
let rawString =
|
|
60032
|
+
let rawString = graphql17.print(documentWithoutExtraVariables);
|
|
60124
60033
|
let docKind = doc.kind;
|
|
60125
60034
|
const operations = document.definitions.filter(
|
|
60126
|
-
({ kind }) => kind ===
|
|
60035
|
+
({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
|
|
60127
60036
|
);
|
|
60128
60037
|
const fragments = document.definitions.filter(
|
|
60129
|
-
({ kind }) => kind ===
|
|
60038
|
+
({ kind }) => kind === graphql17.Kind.FRAGMENT_DEFINITION
|
|
60130
60039
|
);
|
|
60131
60040
|
let rootType = "";
|
|
60132
60041
|
let selectionSet;
|
|
@@ -60326,9 +60235,9 @@ function artifactGenerator(stats) {
|
|
|
60326
60235
|
plugin2.artifactEnd({ config, document: doc });
|
|
60327
60236
|
}
|
|
60328
60237
|
const _houdiniHash = hashOriginal({ document: doc });
|
|
60329
|
-
const file =
|
|
60238
|
+
const file = AST5.program([
|
|
60330
60239
|
moduleExport(config, "default", serializeValue(artifact)),
|
|
60331
|
-
|
|
60240
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
60332
60241
|
]);
|
|
60333
60242
|
const artifactPath = config.artifactPath(document);
|
|
60334
60243
|
const countDocument = doc.generateStore;
|
|
@@ -60386,7 +60295,7 @@ function applyMask(config, target, mask) {
|
|
|
60386
60295
|
if (!targetType) {
|
|
60387
60296
|
continue;
|
|
60388
60297
|
}
|
|
60389
|
-
if (
|
|
60298
|
+
if (graphql17.isAbstractType(targetType)) {
|
|
60390
60299
|
for (const possible of config.schema.getPossibleTypes(targetType)) {
|
|
60391
60300
|
if (target.abstractFields?.fields[possible.name]) {
|
|
60392
60301
|
applyMask(
|
|
@@ -60409,8 +60318,8 @@ function applyMask(config, target, mask) {
|
|
|
60409
60318
|
}
|
|
60410
60319
|
|
|
60411
60320
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
60412
|
-
var
|
|
60413
|
-
var
|
|
60321
|
+
var recast6 = __toESM(require_main2(), 1);
|
|
60322
|
+
var AST6 = recast6.types.builders;
|
|
60414
60323
|
async function generateGraphqlReturnTypes(config, docs) {
|
|
60415
60324
|
const indexPath = path_exports.join(config.runtimeDirectory, "index.d.ts");
|
|
60416
60325
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
@@ -60445,18 +60354,18 @@ async function generateGraphqlReturnTypes(config, docs) {
|
|
|
60445
60354
|
continue;
|
|
60446
60355
|
}
|
|
60447
60356
|
for (const [queryString, returnValue] of Object.entries(overloaded_returns)) {
|
|
60448
|
-
const input =
|
|
60449
|
-
input.typeAnnotation =
|
|
60450
|
-
|
|
60357
|
+
const input = AST6.identifier("str");
|
|
60358
|
+
input.typeAnnotation = AST6.tsTypeAnnotation(
|
|
60359
|
+
AST6.tsLiteralType(AST6.stringLiteral(queryString))
|
|
60451
60360
|
);
|
|
60452
60361
|
script.body.splice(
|
|
60453
60362
|
i,
|
|
60454
60363
|
0,
|
|
60455
|
-
|
|
60456
|
-
|
|
60457
|
-
|
|
60364
|
+
AST6.exportNamedDeclaration(
|
|
60365
|
+
AST6.tsDeclareFunction(
|
|
60366
|
+
AST6.identifier("graphql"),
|
|
60458
60367
|
[input],
|
|
60459
|
-
|
|
60368
|
+
AST6.tsTypeAnnotation(AST6.tsTypeReference(AST6.identifier(returnValue)))
|
|
60460
60369
|
)
|
|
60461
60370
|
)
|
|
60462
60371
|
);
|
|
@@ -60631,165 +60540,22 @@ function moduleStatments(config) {
|
|
|
60631
60540
|
var recast11 = __toESM(require_main2(), 1);
|
|
60632
60541
|
|
|
60633
60542
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
60634
|
-
var recast8 = __toESM(require_main2(), 1);
|
|
60635
|
-
import * as graphql19 from "graphql";
|
|
60636
|
-
|
|
60637
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
60638
60543
|
var recast7 = __toESM(require_main2(), 1);
|
|
60639
60544
|
import * as graphql18 from "graphql";
|
|
60640
|
-
|
|
60641
|
-
// src/codegen/generators/typescript/types.ts
|
|
60642
|
-
var recast6 = __toESM(require_main2(), 1);
|
|
60643
|
-
import * as graphql17 from "graphql";
|
|
60644
|
-
var AST6 = recast6.types.builders;
|
|
60645
|
-
function readonlyProperty(prop, enable = true) {
|
|
60646
|
-
if (enable) {
|
|
60647
|
-
prop.readonly = true;
|
|
60648
|
-
}
|
|
60649
|
-
return prop;
|
|
60650
|
-
}
|
|
60651
|
-
function nullableField(inner, input = false) {
|
|
60652
|
-
const members = [inner, AST6.tsNullKeyword()];
|
|
60653
|
-
if (input) {
|
|
60654
|
-
members.push(AST6.tsUndefinedKeyword());
|
|
60655
|
-
}
|
|
60656
|
-
return AST6.tsUnionType(members);
|
|
60657
|
-
}
|
|
60658
|
-
function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
|
|
60659
|
-
if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
|
|
60660
|
-
if (!field) {
|
|
60661
|
-
return AST6.tsNeverKeyword();
|
|
60662
|
-
}
|
|
60663
|
-
const component = config.componentFields[field.parent][field.field];
|
|
60664
|
-
const sourcePathRelative = path_exports.relative(
|
|
60665
|
-
path_exports.join(config.projectRoot, "src"),
|
|
60666
|
-
component.filepath
|
|
60667
|
-
);
|
|
60668
|
-
let sourcePathParsed = path_exports.parse(sourcePathRelative);
|
|
60669
|
-
let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
60670
|
-
const localImport = ensureImports({
|
|
60671
|
-
config,
|
|
60672
|
-
body,
|
|
60673
|
-
import: "__component__" + component.fragment,
|
|
60674
|
-
sourceModule: path_exports.join(
|
|
60675
|
-
path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
|
|
60676
|
-
"src",
|
|
60677
|
-
sourcePath
|
|
60678
|
-
)
|
|
60679
|
-
});
|
|
60680
|
-
const parameters = AST6.tsTypeReference(AST6.identifier("Parameters"));
|
|
60681
|
-
parameters.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
60682
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
60683
|
-
]);
|
|
60684
|
-
const indexed = AST6.tsIndexedAccessType(
|
|
60685
|
-
parameters,
|
|
60686
|
-
AST6.tsLiteralType(AST6.numericLiteral(0))
|
|
60687
|
-
);
|
|
60688
|
-
const omit = AST6.tsTypeReference(AST6.identifier("Omit"));
|
|
60689
|
-
omit.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
60690
|
-
indexed,
|
|
60691
|
-
AST6.tsLiteralType(AST6.stringLiteral(component.prop))
|
|
60692
|
-
]);
|
|
60693
|
-
const arg = AST6.identifier("props");
|
|
60694
|
-
arg.typeAnnotation = AST6.tsTypeAnnotation(omit);
|
|
60695
|
-
const returnType = AST6.tsTypeReference(AST6.identifier("ReturnType"));
|
|
60696
|
-
returnType.typeParameters = AST6.tsTypeParameterInstantiation([
|
|
60697
|
-
AST6.tsTypeQuery(AST6.identifier(localImport))
|
|
60698
|
-
]);
|
|
60699
|
-
const fnType = AST6.tsFunctionType([arg]);
|
|
60700
|
-
fnType.typeAnnotation = AST6.tsTypeAnnotation(returnType);
|
|
60701
|
-
return fnType;
|
|
60702
|
-
}
|
|
60703
|
-
switch (target.name) {
|
|
60704
|
-
case "String": {
|
|
60705
|
-
return AST6.tsStringKeyword();
|
|
60706
|
-
}
|
|
60707
|
-
case "Int": {
|
|
60708
|
-
return AST6.tsNumberKeyword();
|
|
60709
|
-
}
|
|
60710
|
-
case "Float": {
|
|
60711
|
-
return AST6.tsNumberKeyword();
|
|
60712
|
-
}
|
|
60713
|
-
case "Boolean": {
|
|
60714
|
-
return AST6.tsBooleanKeyword();
|
|
60715
|
-
}
|
|
60716
|
-
case "ID": {
|
|
60717
|
-
return AST6.tsStringKeyword();
|
|
60718
|
-
}
|
|
60719
|
-
default: {
|
|
60720
|
-
if (graphql17.isNonNullType(target) && "ofType" in target) {
|
|
60721
|
-
return scalarPropertyValue(
|
|
60722
|
-
config,
|
|
60723
|
-
filepath,
|
|
60724
|
-
missingScalars,
|
|
60725
|
-
target.ofType,
|
|
60726
|
-
body,
|
|
60727
|
-
field
|
|
60728
|
-
);
|
|
60729
|
-
}
|
|
60730
|
-
if (config.scalars?.[target.name]) {
|
|
60731
|
-
return AST6.tsTypeReference(AST6.identifier(config.scalars?.[target.name].type));
|
|
60732
|
-
}
|
|
60733
|
-
if (target.name !== config.componentScalar) {
|
|
60734
|
-
missingScalars.add(target.name);
|
|
60735
|
-
}
|
|
60736
|
-
return AST6.tsAnyKeyword();
|
|
60737
|
-
}
|
|
60738
|
-
}
|
|
60739
|
-
}
|
|
60740
|
-
|
|
60741
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
60742
60545
|
var AST7 = recast7.types.builders;
|
|
60743
|
-
function tsTypeReference(config, filepath, missingScalars, definition, body) {
|
|
60744
|
-
const { type, wrappers } = unwrapType(config, definition.type);
|
|
60745
|
-
let result;
|
|
60746
|
-
if (graphql18.isScalarType(type)) {
|
|
60747
|
-
result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
|
|
60748
|
-
} else if (graphql18.isEnumType(type)) {
|
|
60749
|
-
result = enumReference(config, body, type.name);
|
|
60750
|
-
} else {
|
|
60751
|
-
result = AST7.tsTypeReference(AST7.identifier(type.name));
|
|
60752
|
-
}
|
|
60753
|
-
for (const toWrap of wrappers) {
|
|
60754
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
60755
|
-
continue;
|
|
60756
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
60757
|
-
result = nullableField(result, true);
|
|
60758
|
-
} else if (toWrap === "List" /* List */) {
|
|
60759
|
-
result = AST7.tsArrayType(AST7.tsParenthesizedType(result));
|
|
60760
|
-
}
|
|
60761
|
-
}
|
|
60762
|
-
return result;
|
|
60763
|
-
}
|
|
60764
|
-
function enumReference(config, body, name) {
|
|
60765
|
-
ensureImports({
|
|
60766
|
-
config,
|
|
60767
|
-
body,
|
|
60768
|
-
import: ["ValueOf"],
|
|
60769
|
-
importKind: "type",
|
|
60770
|
-
sourceModule: "$houdini/runtime/lib/types"
|
|
60771
|
-
});
|
|
60772
|
-
return AST7.tsTypeReference(
|
|
60773
|
-
AST7.identifier("ValueOf"),
|
|
60774
|
-
AST7.tsTypeParameterInstantiation([AST7.tsTypeQuery(AST7.identifier(name))])
|
|
60775
|
-
);
|
|
60776
|
-
}
|
|
60777
|
-
|
|
60778
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
60779
|
-
var AST8 = recast8.types.builders;
|
|
60780
60546
|
function addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
60781
60547
|
const { type } = unwrapType(config, rootType);
|
|
60782
|
-
if (
|
|
60548
|
+
if (graphql18.isScalarType(type)) {
|
|
60783
60549
|
return;
|
|
60784
60550
|
}
|
|
60785
60551
|
if (visitedTypes.has(type.name)) {
|
|
60786
60552
|
return;
|
|
60787
60553
|
}
|
|
60788
|
-
if (
|
|
60554
|
+
if (graphql18.isUnionType(type)) {
|
|
60789
60555
|
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
60790
60556
|
}
|
|
60791
60557
|
visitedTypes.add(type.name);
|
|
60792
|
-
if (
|
|
60558
|
+
if (graphql18.isEnumType(type)) {
|
|
60793
60559
|
ensureImports({
|
|
60794
60560
|
config,
|
|
60795
60561
|
body,
|
|
@@ -60803,21 +60569,37 @@ function addReferencedInputTypes(config, filepath, body, visitedTypes, missingSc
|
|
|
60803
60569
|
for (const field of Object.values(type.getFields())) {
|
|
60804
60570
|
addReferencedInputTypes(config, filepath, body, visitedTypes, missingScalars, field.type);
|
|
60805
60571
|
members.push(
|
|
60806
|
-
|
|
60807
|
-
|
|
60808
|
-
|
|
60572
|
+
AST7.tsPropertySignature(
|
|
60573
|
+
AST7.identifier(field.name),
|
|
60574
|
+
AST7.tsTypeAnnotation(
|
|
60809
60575
|
tsTypeReference(config, filepath, missingScalars, field, body)
|
|
60810
60576
|
),
|
|
60811
|
-
|
|
60577
|
+
graphql18.isNullableType(field.type)
|
|
60812
60578
|
)
|
|
60813
60579
|
);
|
|
60814
60580
|
}
|
|
60815
|
-
body.push(
|
|
60581
|
+
body.push(AST7.tsTypeAliasDeclaration(AST7.identifier(type.name), AST7.tsTypeLiteral(members)));
|
|
60816
60582
|
}
|
|
60817
60583
|
|
|
60818
60584
|
// src/codegen/generators/typescript/inlineType.ts
|
|
60819
60585
|
var recast9 = __toESM(require_main2(), 1);
|
|
60820
|
-
import * as
|
|
60586
|
+
import * as graphql19 from "graphql";
|
|
60587
|
+
|
|
60588
|
+
// src/codegen/generators/comments/jsdoc.ts
|
|
60589
|
+
var recast8 = __toESM(require_main2(), 1);
|
|
60590
|
+
var AST8 = recast8.types.builders;
|
|
60591
|
+
function jsdocComment(text, deprecated) {
|
|
60592
|
+
let commentContent = `*
|
|
60593
|
+
* ${text}
|
|
60594
|
+
`;
|
|
60595
|
+
if (deprecated) {
|
|
60596
|
+
commentContent = `${commentContent} * @deprecated ${deprecated}
|
|
60597
|
+
`;
|
|
60598
|
+
}
|
|
60599
|
+
return AST8.commentBlock(commentContent, true);
|
|
60600
|
+
}
|
|
60601
|
+
|
|
60602
|
+
// src/codegen/generators/typescript/inlineType.ts
|
|
60821
60603
|
var AST9 = recast9.types.builders;
|
|
60822
60604
|
var fragmentKey2 = " $fragments";
|
|
60823
60605
|
function inlineType({
|
|
@@ -60838,7 +60620,7 @@ function inlineType({
|
|
|
60838
60620
|
const { type, wrappers } = unwrapType(config, rootType);
|
|
60839
60621
|
let result;
|
|
60840
60622
|
let forceNullable = false;
|
|
60841
|
-
if (
|
|
60623
|
+
if (graphql19.isScalarType(type)) {
|
|
60842
60624
|
result = scalarPropertyValue(
|
|
60843
60625
|
config,
|
|
60844
60626
|
filepath,
|
|
@@ -60847,7 +60629,7 @@ function inlineType({
|
|
|
60847
60629
|
body,
|
|
60848
60630
|
field
|
|
60849
60631
|
);
|
|
60850
|
-
} else if (
|
|
60632
|
+
} else if (graphql19.isEnumType(type)) {
|
|
60851
60633
|
ensureImports({
|
|
60852
60634
|
config,
|
|
60853
60635
|
body,
|
|
@@ -60872,11 +60654,11 @@ function inlineType({
|
|
|
60872
60654
|
for (const selection of selections) {
|
|
60873
60655
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
60874
60656
|
const fragmentType = config.schema.getType(selection.typeCondition.name.value);
|
|
60875
|
-
if (!
|
|
60657
|
+
if (!graphql19.isInterfaceType(type) && !graphql19.isUnionType(type)) {
|
|
60876
60658
|
selectedFields.push(...selection.selectionSet.selections);
|
|
60877
60659
|
continue;
|
|
60878
60660
|
}
|
|
60879
|
-
if (!
|
|
60661
|
+
if (!graphql19.isInterfaceType(fragmentType) && !graphql19.isUnionType(fragmentType)) {
|
|
60880
60662
|
if (!inlineFragments[fragmentType.name]) {
|
|
60881
60663
|
inlineFragments[fragmentType.name] = [];
|
|
60882
60664
|
}
|
|
@@ -60968,6 +60750,11 @@ function inlineType({
|
|
|
60968
60750
|
if (allOptional) {
|
|
60969
60751
|
prop.optional = true;
|
|
60970
60752
|
}
|
|
60753
|
+
if (field2.description || field2.deprecationReason) {
|
|
60754
|
+
prop.comments = [
|
|
60755
|
+
jsdocComment(field2.description ?? "", field2.deprecationReason ?? void 0)
|
|
60756
|
+
];
|
|
60757
|
+
}
|
|
60971
60758
|
return prop;
|
|
60972
60759
|
})
|
|
60973
60760
|
]);
|
|
@@ -61019,7 +60806,7 @@ function inlineType({
|
|
|
61019
60806
|
}
|
|
61020
60807
|
}
|
|
61021
60808
|
}
|
|
61022
|
-
if (objectType.type === "TSTypeLiteral" && !
|
|
60809
|
+
if (objectType.type === "TSTypeLiteral" && !graphql19.isInterfaceType(fragmentRootType) && !graphql19.isUnionType(fragmentRootType)) {
|
|
61023
60810
|
const existingTypenameIndex = objectType.members.findIndex(
|
|
61024
60811
|
(member) => member.type === "TSPropertySignature" && member.key.type === "Identifier" && member.key.name === "__typename"
|
|
61025
60812
|
);
|
|
@@ -61044,11 +60831,11 @@ function inlineType({
|
|
|
61044
60831
|
];
|
|
61045
60832
|
}
|
|
61046
60833
|
let coveredTypenames;
|
|
61047
|
-
if (
|
|
60834
|
+
if (graphql19.isInterfaceType(fragmentRootType)) {
|
|
61048
60835
|
coveredTypenames = interfaceCoveredTypenames(fragmentRootType);
|
|
61049
|
-
} else if (
|
|
60836
|
+
} else if (graphql19.isUnionType(fragmentRootType)) {
|
|
61050
60837
|
coveredTypenames = fragmentRootType.getTypes().map((type2) => type2.name);
|
|
61051
|
-
} else if (
|
|
60838
|
+
} else if (graphql19.isObjectType(fragmentRootType)) {
|
|
61052
60839
|
coveredTypenames = [fragmentRootType.name];
|
|
61053
60840
|
} else {
|
|
61054
60841
|
throw Error("unreachable code");
|
|
@@ -61084,7 +60871,7 @@ function inlineType({
|
|
|
61084
60871
|
);
|
|
61085
60872
|
}
|
|
61086
60873
|
);
|
|
61087
|
-
const parentIsUnionOrInterface = !
|
|
60874
|
+
const parentIsUnionOrInterface = !graphql19.isInterfaceType(type) && !graphql19.isUnionType(type);
|
|
61088
60875
|
const possibleTypenames = parentIsUnionOrInterface ? [parent.name] : config.schema.getPossibleTypes(type).map((type2) => type2.name);
|
|
61089
60876
|
const coveredTypenames = new Set(
|
|
61090
60877
|
Object.values(inlineFragmentSelections).flatMap((sel) => sel.coveredTypenames)
|
|
@@ -61151,7 +60938,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
61151
60938
|
},
|
|
61152
60939
|
type: schema.getType("String")
|
|
61153
60940
|
};
|
|
61154
|
-
} else if (
|
|
60941
|
+
} else if (graphql19.isNonNullType(rootType) && "getFields" in rootType.ofType) {
|
|
61155
60942
|
fields = rootType.ofType.getFields();
|
|
61156
60943
|
} else {
|
|
61157
60944
|
fields = rootType.getFields();
|
|
@@ -61163,7 +60950,7 @@ function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
|
61163
60950
|
message: `Could not find type information for field ${rootType.toString()}.${selectionName} ${field}`
|
|
61164
60951
|
});
|
|
61165
60952
|
}
|
|
61166
|
-
const fieldType =
|
|
60953
|
+
const fieldType = graphql19.getNamedType(field.type);
|
|
61167
60954
|
if (!fieldType) {
|
|
61168
60955
|
throw new HoudiniError({
|
|
61169
60956
|
filepath,
|
|
@@ -61672,7 +61459,7 @@ async function generateFragmentTypeDefs(config, filepath, body, selections, defi
|
|
|
61672
61459
|
|
|
61673
61460
|
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
61674
61461
|
var recast12 = __toESM(require_main2(), 1);
|
|
61675
|
-
import * as
|
|
61462
|
+
import * as graphql20 from "graphql";
|
|
61676
61463
|
var AST12 = recast12.types.builders;
|
|
61677
61464
|
async function imperativeCacheTypef(config, docs) {
|
|
61678
61465
|
const returnType = (doc) => config.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
@@ -61723,7 +61510,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
61723
61510
|
const operationTypes = [config.schema.getMutationType(), config.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
61724
61511
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
61725
61512
|
const types14 = Object.values(config.schema.getTypeMap()).filter(
|
|
61726
|
-
(type) => !
|
|
61513
|
+
(type) => !graphql20.isAbstractType(type) && !graphql20.isScalarType(type) && !graphql20.isEnumType(type) && !graphql20.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
61727
61514
|
);
|
|
61728
61515
|
const fragmentMap = fragmentListMap(
|
|
61729
61516
|
config,
|
|
@@ -61740,7 +61527,7 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
61740
61527
|
}
|
|
61741
61528
|
let idFields = AST12.tsNeverKeyword();
|
|
61742
61529
|
const keys2 = keyFieldsForType(config.configFile, type.name);
|
|
61743
|
-
if (
|
|
61530
|
+
if (graphql20.isObjectType(type) && keys2.length > 0 && keys2.every((key) => type.getFields()[key])) {
|
|
61744
61531
|
idFields = AST12.tsTypeLiteral(
|
|
61745
61532
|
keys2.map((key) => {
|
|
61746
61533
|
const fieldType = type.getFields()[key];
|
|
@@ -61767,13 +61554,13 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
61767
61554
|
idFields = AST12.tsTypeLiteral([]);
|
|
61768
61555
|
}
|
|
61769
61556
|
let fields = AST12.tsTypeLiteral([]);
|
|
61770
|
-
if (
|
|
61557
|
+
if (graphql20.isObjectType(type)) {
|
|
61771
61558
|
fields = AST12.tsTypeLiteral(
|
|
61772
61559
|
Object.entries(type.getFields()).map(
|
|
61773
61560
|
([key, fieldType]) => {
|
|
61774
61561
|
const unwrapped = unwrapType(config, fieldType.type);
|
|
61775
61562
|
let typeOptions = AST12.tsUnionType([]);
|
|
61776
|
-
if (
|
|
61563
|
+
if (graphql20.isScalarType(unwrapped.type)) {
|
|
61777
61564
|
typeOptions.types.push(
|
|
61778
61565
|
scalarPropertyValue(
|
|
61779
61566
|
config,
|
|
@@ -61787,11 +61574,11 @@ function typeDefinitions(config, filepath, body, docs, returnType) {
|
|
|
61787
61574
|
}
|
|
61788
61575
|
)
|
|
61789
61576
|
);
|
|
61790
|
-
} else if (
|
|
61577
|
+
} else if (graphql20.isEnumType(unwrapped.type)) {
|
|
61791
61578
|
typeOptions.types.push(
|
|
61792
61579
|
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
61793
61580
|
);
|
|
61794
|
-
} else if (!
|
|
61581
|
+
} else if (!graphql20.isAbstractType(unwrapped.type)) {
|
|
61795
61582
|
typeOptions.types.push(record(unwrapped.type.name));
|
|
61796
61583
|
} else {
|
|
61797
61584
|
typeOptions.types.push(
|
|
@@ -61887,7 +61674,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
61887
61674
|
const lists = [];
|
|
61888
61675
|
const visitedLists = /* @__PURE__ */ new Set();
|
|
61889
61676
|
for (const doc of docs) {
|
|
61890
|
-
|
|
61677
|
+
graphql20.visit(doc.document, {
|
|
61891
61678
|
Directive(node, key, parent2, path2, ancestors) {
|
|
61892
61679
|
if (![config.listDirective, config.paginateDirective].includes(node.name.value)) {
|
|
61893
61680
|
return;
|
|
@@ -61909,7 +61696,7 @@ function listDefinitions(config, filepath, body, docs) {
|
|
|
61909
61696
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
61910
61697
|
const { type: listType } = unwrapType(config, targetFieldDefinition.type);
|
|
61911
61698
|
const possibleTypes = [];
|
|
61912
|
-
if (
|
|
61699
|
+
if (graphql20.isAbstractType(listType)) {
|
|
61913
61700
|
possibleTypes.push(
|
|
61914
61701
|
...config.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
61915
61702
|
);
|
|
@@ -62071,7 +61858,7 @@ async function typescriptGenerator(config, docs) {
|
|
|
62071
61858
|
}
|
|
62072
61859
|
|
|
62073
61860
|
// src/codegen/generators/persistedQueries/index.ts
|
|
62074
|
-
import * as
|
|
61861
|
+
import * as graphql21 from "graphql";
|
|
62075
61862
|
async function persistOutputGenerator(config, docs) {
|
|
62076
61863
|
if (!config.persistedQueriesPath.endsWith(".json")) {
|
|
62077
61864
|
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
@@ -62081,8 +61868,8 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62081
61868
|
if (!generateArtifact) {
|
|
62082
61869
|
return acc;
|
|
62083
61870
|
}
|
|
62084
|
-
let rawString =
|
|
62085
|
-
|
|
61871
|
+
let rawString = graphql21.print(
|
|
61872
|
+
graphql21.visit(document, {
|
|
62086
61873
|
Directive(node) {
|
|
62087
61874
|
if (config.isInternalDirective(node.name.value)) {
|
|
62088
61875
|
return null;
|
|
@@ -62091,7 +61878,7 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62091
61878
|
})
|
|
62092
61879
|
);
|
|
62093
61880
|
const operations = document.definitions.filter(
|
|
62094
|
-
({ kind }) => kind ===
|
|
61881
|
+
({ kind }) => kind === graphql21.Kind.OPERATION_DEFINITION
|
|
62095
61882
|
);
|
|
62096
61883
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
62097
61884
|
if (artifact) {
|
|
@@ -62106,33 +61893,45 @@ async function persistOutputGenerator(config, docs) {
|
|
|
62106
61893
|
}
|
|
62107
61894
|
|
|
62108
61895
|
// src/codegen/generators/definitions/index.ts
|
|
62109
|
-
import * as
|
|
61896
|
+
import * as graphql23 from "graphql";
|
|
62110
61897
|
|
|
62111
61898
|
// src/codegen/generators/definitions/enums.ts
|
|
62112
61899
|
var recast13 = __toESM(require_main2(), 1);
|
|
62113
|
-
import * as
|
|
61900
|
+
import * as graphql22 from "graphql";
|
|
62114
61901
|
var AST13 = recast13.types.builders;
|
|
62115
61902
|
async function definitionsGenerator(config) {
|
|
62116
|
-
const enums =
|
|
61903
|
+
const enums = graphql22.parse(graphql22.printSchema(config.schema)).definitions.filter(
|
|
62117
61904
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
62118
61905
|
).filter((def) => !config.isInternalEnum(def));
|
|
62119
61906
|
const { code: runtimeDefinitions } = await printJS(
|
|
62120
61907
|
AST13.program(
|
|
62121
61908
|
enums.map((defn) => {
|
|
62122
61909
|
const name = defn.name.value;
|
|
62123
|
-
|
|
61910
|
+
const declaration = moduleExport(
|
|
62124
61911
|
config,
|
|
62125
61912
|
name,
|
|
62126
61913
|
AST13.objectExpression(
|
|
62127
61914
|
defn.values?.map((value) => {
|
|
62128
61915
|
const str = value.name.value;
|
|
62129
|
-
|
|
61916
|
+
const prop = AST13.objectProperty(
|
|
62130
61917
|
AST13.stringLiteral(str),
|
|
62131
61918
|
AST13.stringLiteral(str)
|
|
62132
61919
|
);
|
|
61920
|
+
const deprecationReason = value.directives?.find((d) => d.name.value === "deprecated")?.arguments?.find((a) => a.name.value === "reason")?.value?.value;
|
|
61921
|
+
if (value.description || deprecationReason)
|
|
61922
|
+
prop.comments = [
|
|
61923
|
+
jsdocComment(value.description?.value ?? "", deprecationReason)
|
|
61924
|
+
];
|
|
61925
|
+
return prop;
|
|
62133
61926
|
}) || []
|
|
62134
61927
|
)
|
|
62135
61928
|
);
|
|
61929
|
+
if (defn.description) {
|
|
61930
|
+
declaration.comments = [
|
|
61931
|
+
AST13.commentBlock(`* ${defn.description.value} `, true, false)
|
|
61932
|
+
];
|
|
61933
|
+
}
|
|
61934
|
+
return declaration;
|
|
62136
61935
|
})
|
|
62137
61936
|
)
|
|
62138
61937
|
);
|
|
@@ -62141,11 +61940,19 @@ type ValuesOf<T> = T[keyof T]
|
|
|
62141
61940
|
` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
|
|
62142
61941
|
const name = definition.name.value;
|
|
62143
61942
|
const values = definition.values;
|
|
62144
|
-
|
|
61943
|
+
let jsdoc = "";
|
|
61944
|
+
if (definition.description) {
|
|
61945
|
+
jsdoc = `
|
|
61946
|
+
/** ${definition.description.value} */`;
|
|
61947
|
+
}
|
|
61948
|
+
return `${jsdoc}
|
|
62145
61949
|
export declare const ${name}: {
|
|
62146
|
-
${values?.map(
|
|
61950
|
+
${values?.map(
|
|
61951
|
+
(value) => (value.description ? ` /** ${value.description.value} */
|
|
61952
|
+
` : "") + ` readonly ${value.name.value}: "${value.name.value}";`
|
|
61953
|
+
).join("\n")}
|
|
62147
61954
|
}
|
|
62148
|
-
|
|
61955
|
+
${jsdoc}
|
|
62149
61956
|
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
62150
61957
|
`;
|
|
62151
61958
|
}).join("");
|
|
@@ -62165,7 +61972,7 @@ async function schemaGenerator(config) {
|
|
|
62165
61972
|
await Promise.all([
|
|
62166
61973
|
fs_exports.writeFile(
|
|
62167
61974
|
config.definitionsSchemaPath,
|
|
62168
|
-
config.localSchema ?
|
|
61975
|
+
config.localSchema ? graphql23.printSchema(config.schema) : config.newSchema
|
|
62169
61976
|
),
|
|
62170
61977
|
fs_exports.writeFile(config.definitionsDocumentsPath, config.newDocuments),
|
|
62171
61978
|
definitionsGenerator(config)
|
|
@@ -63870,7 +63677,7 @@ function mergeGraphQLTypes(typeSource, config) {
|
|
|
63870
63677
|
}
|
|
63871
63678
|
|
|
63872
63679
|
// src/codegen/transforms/schema.ts
|
|
63873
|
-
import * as
|
|
63680
|
+
import * as graphql24 from "graphql";
|
|
63874
63681
|
async function graphqlExtensions(config, documents) {
|
|
63875
63682
|
let internalSchema = `
|
|
63876
63683
|
enum CachePolicy {
|
|
@@ -63993,7 +63800,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
63993
63800
|
const args = fragmentArguments(config, "", field.parent);
|
|
63994
63801
|
if (args.length > 0) {
|
|
63995
63802
|
argString = "(" + args.map((arg) => {
|
|
63996
|
-
const typeName =
|
|
63803
|
+
const typeName = graphql24.print(arg.type);
|
|
63997
63804
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
63998
63805
|
}).join("\n") + ")";
|
|
63999
63806
|
}
|
|
@@ -64003,20 +63810,20 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
64003
63810
|
`;
|
|
64004
63811
|
}).join("\n");
|
|
64005
63812
|
extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
64006
|
-
config.newSchema =
|
|
63813
|
+
config.newSchema = graphql24.print(mergeTypeDefs([internalSchema, config.newSchema]));
|
|
64007
63814
|
config.schemaString += extensions;
|
|
64008
|
-
config.schema =
|
|
64009
|
-
|
|
64010
|
-
mergeTypeDefs([
|
|
63815
|
+
config.schema = graphql24.buildSchema(
|
|
63816
|
+
graphql24.print(
|
|
63817
|
+
mergeTypeDefs([graphql24.printSchema(config.schema), internalSchema, extensions])
|
|
64011
63818
|
)
|
|
64012
63819
|
);
|
|
64013
63820
|
}
|
|
64014
63821
|
|
|
64015
63822
|
// src/codegen/transforms/typename.ts
|
|
64016
|
-
import * as
|
|
63823
|
+
import * as graphql25 from "graphql";
|
|
64017
63824
|
async function addTypename(config, documents) {
|
|
64018
63825
|
for (const doc of documents) {
|
|
64019
|
-
doc.document =
|
|
63826
|
+
doc.document = graphql25.visit(doc.document, {
|
|
64020
63827
|
Field(node, key, parent2, path2, ancestors) {
|
|
64021
63828
|
if (!node.selectionSet) {
|
|
64022
63829
|
return;
|
|
@@ -64028,7 +63835,7 @@ async function addTypename(config, documents) {
|
|
|
64028
63835
|
);
|
|
64029
63836
|
const field = type.getFields()[node.name.value];
|
|
64030
63837
|
const fieldType = unwrapType(config, field.type).type;
|
|
64031
|
-
if (
|
|
63838
|
+
if (graphql25.isInterfaceType(fieldType) || graphql25.isUnionType(fieldType)) {
|
|
64032
63839
|
return {
|
|
64033
63840
|
...node,
|
|
64034
63841
|
selectionSet: {
|
|
@@ -64036,9 +63843,9 @@ async function addTypename(config, documents) {
|
|
|
64036
63843
|
selections: [
|
|
64037
63844
|
...node.selectionSet.selections,
|
|
64038
63845
|
{
|
|
64039
|
-
kind:
|
|
63846
|
+
kind: graphql25.Kind.FIELD,
|
|
64040
63847
|
name: {
|
|
64041
|
-
kind:
|
|
63848
|
+
kind: graphql25.Kind.NAME,
|
|
64042
63849
|
value: "__typename"
|
|
64043
63850
|
}
|
|
64044
63851
|
}
|
|
@@ -64055,9 +63862,9 @@ async function addTypename(config, documents) {
|
|
|
64055
63862
|
selections: [
|
|
64056
63863
|
...node.selectionSet.selections,
|
|
64057
63864
|
{
|
|
64058
|
-
kind:
|
|
63865
|
+
kind: graphql25.Kind.FIELD,
|
|
64059
63866
|
name: {
|
|
64060
|
-
kind:
|
|
63867
|
+
kind: graphql25.Kind.NAME,
|
|
64061
63868
|
value: "__typename"
|
|
64062
63869
|
}
|
|
64063
63870
|
}
|
|
@@ -64070,10 +63877,10 @@ async function addTypename(config, documents) {
|
|
|
64070
63877
|
}
|
|
64071
63878
|
|
|
64072
63879
|
// src/codegen/transforms/addID.ts
|
|
64073
|
-
import * as
|
|
63880
|
+
import * as graphql26 from "graphql";
|
|
64074
63881
|
async function addID(config, documents) {
|
|
64075
63882
|
for (const doc of documents) {
|
|
64076
|
-
doc.document =
|
|
63883
|
+
doc.document = graphql26.visit(doc.document, {
|
|
64077
63884
|
Field(node, key, parent2, path2, ancestors) {
|
|
64078
63885
|
if (!node.selectionSet) {
|
|
64079
63886
|
return;
|
|
@@ -64111,7 +63918,7 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64111
63918
|
if (!node.selectionSet || node.selectionSet.selections.length == 0) {
|
|
64112
63919
|
return;
|
|
64113
63920
|
}
|
|
64114
|
-
if (!
|
|
63921
|
+
if (!graphql26.isObjectType(fieldType) && !graphql26.isInterfaceType(fieldType)) {
|
|
64115
63922
|
return;
|
|
64116
63923
|
}
|
|
64117
63924
|
const keyFields = config.keyFieldsForType(fieldType.name);
|
|
@@ -64126,9 +63933,9 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64126
63933
|
continue;
|
|
64127
63934
|
}
|
|
64128
63935
|
selections.push({
|
|
64129
|
-
kind:
|
|
63936
|
+
kind: graphql26.Kind.FIELD,
|
|
64130
63937
|
name: {
|
|
64131
|
-
kind:
|
|
63938
|
+
kind: graphql26.Kind.NAME,
|
|
64132
63939
|
value: keyField
|
|
64133
63940
|
}
|
|
64134
63941
|
});
|
|
@@ -64143,13 +63950,13 @@ function addKeysToSelection(config, node, fieldType) {
|
|
|
64143
63950
|
}
|
|
64144
63951
|
|
|
64145
63952
|
// src/codegen/transforms/componentFields.ts
|
|
64146
|
-
import * as
|
|
63953
|
+
import * as graphql27 from "graphql";
|
|
64147
63954
|
async function componentFields(config, documents) {
|
|
64148
63955
|
for (const document of documents) {
|
|
64149
|
-
const typeInfo = new
|
|
64150
|
-
document.document =
|
|
63956
|
+
const typeInfo = new graphql27.TypeInfo(config.schema);
|
|
63957
|
+
document.document = graphql27.visit(
|
|
64151
63958
|
document.document,
|
|
64152
|
-
|
|
63959
|
+
graphql27.visitWithTypeInfo(typeInfo, {
|
|
64153
63960
|
Field(node) {
|
|
64154
63961
|
const parentType = typeInfo.getParentType();
|
|
64155
63962
|
if (!parentType) {
|
|
@@ -64198,10 +64005,10 @@ async function componentFields(config, documents) {
|
|
|
64198
64005
|
}
|
|
64199
64006
|
|
|
64200
64007
|
// src/codegen/transforms/runtimeScalars.ts
|
|
64201
|
-
import * as
|
|
64008
|
+
import * as graphql28 from "graphql";
|
|
64202
64009
|
async function addTypename2(config, documents) {
|
|
64203
64010
|
for (const doc of documents) {
|
|
64204
|
-
doc.document =
|
|
64011
|
+
doc.document = graphql28.visit(doc.document, {
|
|
64205
64012
|
VariableDefinition(node) {
|
|
64206
64013
|
const { type, wrappers } = unwrapType(config, node.type);
|
|
64207
64014
|
const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
|
|
@@ -64240,7 +64047,7 @@ async function addTypename2(config, documents) {
|
|
|
64240
64047
|
}
|
|
64241
64048
|
|
|
64242
64049
|
// src/codegen/validators/typeCheck.ts
|
|
64243
|
-
import * as
|
|
64050
|
+
import * as graphql29 from "graphql";
|
|
64244
64051
|
async function typeCheck(config, docs) {
|
|
64245
64052
|
const errors = [];
|
|
64246
64053
|
const freeLists = [];
|
|
@@ -64248,7 +64055,7 @@ async function typeCheck(config, docs) {
|
|
|
64248
64055
|
const listTypes = [];
|
|
64249
64056
|
const fragments = {};
|
|
64250
64057
|
for (const { document: parsed, originalString, filename } of docs) {
|
|
64251
|
-
|
|
64058
|
+
graphql29.visit(parsed, {
|
|
64252
64059
|
FragmentDefinition(definition) {
|
|
64253
64060
|
fragments[definition.name.value] = definition;
|
|
64254
64061
|
},
|
|
@@ -64293,14 +64100,14 @@ async function typeCheck(config, docs) {
|
|
|
64293
64100
|
);
|
|
64294
64101
|
return;
|
|
64295
64102
|
}
|
|
64296
|
-
if (
|
|
64103
|
+
if (graphql29.isListType(rootType) || graphql29.isNonNullType(rootType) && graphql29.isListType(rootType.ofType)) {
|
|
64297
64104
|
needsParent = true;
|
|
64298
64105
|
break;
|
|
64299
64106
|
}
|
|
64300
|
-
if (
|
|
64107
|
+
if (graphql29.isNonNullType(rootType) && "ofType" in rootType) {
|
|
64301
64108
|
rootType = rootType.ofType;
|
|
64302
64109
|
}
|
|
64303
|
-
if (
|
|
64110
|
+
if (graphql29.isScalarType(rootType)) {
|
|
64304
64111
|
break;
|
|
64305
64112
|
}
|
|
64306
64113
|
rootType = rootType?.getFields()[parent3.name.value]?.type;
|
|
@@ -64376,9 +64183,9 @@ async function typeCheck(config, docs) {
|
|
|
64376
64183
|
);
|
|
64377
64184
|
}
|
|
64378
64185
|
let targetTypes = [type];
|
|
64379
|
-
if (
|
|
64186
|
+
if (graphql29.isUnionType(type)) {
|
|
64380
64187
|
targetTypes = config.schema.getPossibleTypes(type);
|
|
64381
|
-
} else if (
|
|
64188
|
+
} else if (graphql29.isInterfaceType(type)) {
|
|
64382
64189
|
try {
|
|
64383
64190
|
for (const key of config.keyFieldsForType(type.name)) {
|
|
64384
64191
|
if (!type.getFields()[key]) {
|
|
@@ -64414,13 +64221,13 @@ async function typeCheck(config, docs) {
|
|
|
64414
64221
|
if (errors.length > 0) {
|
|
64415
64222
|
throw errors;
|
|
64416
64223
|
}
|
|
64417
|
-
const rules = (filepath) => [...
|
|
64224
|
+
const rules = (filepath) => [...graphql29.specifiedRules].filter(
|
|
64418
64225
|
(rule) => ![
|
|
64419
|
-
|
|
64420
|
-
|
|
64421
|
-
|
|
64422
|
-
|
|
64423
|
-
|
|
64226
|
+
graphql29.NoUnusedFragmentsRule,
|
|
64227
|
+
graphql29.KnownFragmentNamesRule,
|
|
64228
|
+
graphql29.ExecutableDefinitionsRule,
|
|
64229
|
+
graphql29.KnownDirectivesRule,
|
|
64230
|
+
graphql29.KnownArgumentNamesRule
|
|
64424
64231
|
].includes(rule)
|
|
64425
64232
|
).concat(
|
|
64426
64233
|
validateLists({
|
|
@@ -64441,7 +64248,7 @@ async function typeCheck(config, docs) {
|
|
|
64441
64248
|
validateLoadingDirective(config)
|
|
64442
64249
|
);
|
|
64443
64250
|
for (const { filename, document: parsed, originalString } of docs) {
|
|
64444
|
-
for (const error of
|
|
64251
|
+
for (const error of graphql29.validate(config.schema, parsed, rules(filename))) {
|
|
64445
64252
|
errors.push(
|
|
64446
64253
|
new HoudiniError({
|
|
64447
64254
|
filepath: filename,
|
|
@@ -64470,20 +64277,20 @@ function validateRequiredDirective(config, filepath) {
|
|
|
64470
64277
|
if (!node.directives?.some(({ name }) => name.value === config.requiredDirective))
|
|
64471
64278
|
return;
|
|
64472
64279
|
const parentType = parentTypeFromAncestors(config.schema, filepath, ancestors);
|
|
64473
|
-
if (!
|
|
64280
|
+
if (!graphql29.isObjectType(parentType)) {
|
|
64474
64281
|
ctx.reportError(
|
|
64475
|
-
new
|
|
64282
|
+
new graphql29.GraphQLError(
|
|
64476
64283
|
`@${config.requiredDirective} may only be used on objects, not arguments`
|
|
64477
64284
|
)
|
|
64478
64285
|
);
|
|
64479
64286
|
return;
|
|
64480
64287
|
}
|
|
64481
64288
|
const type = parentType.getFields()[node.name.value].type;
|
|
64482
|
-
const isServerNullable = !
|
|
64289
|
+
const isServerNullable = !graphql29.isNonNullType(type);
|
|
64483
64290
|
const isAlreadyClientNullable = isClientNullable(node, true);
|
|
64484
64291
|
if (!isServerNullable && !isAlreadyClientNullable) {
|
|
64485
64292
|
ctx.reportError(
|
|
64486
|
-
new
|
|
64293
|
+
new graphql29.GraphQLError(
|
|
64487
64294
|
`@${config.requiredDirective} may only be used on nullable fields`
|
|
64488
64295
|
)
|
|
64489
64296
|
);
|
|
@@ -64505,7 +64312,7 @@ var validateLists = ({
|
|
|
64505
64312
|
if (!config.isListFragment(node.name.value)) {
|
|
64506
64313
|
if (!fragments[node.name.value]) {
|
|
64507
64314
|
ctx.reportError(
|
|
64508
|
-
new
|
|
64315
|
+
new graphql29.GraphQLError(
|
|
64509
64316
|
"Encountered unknown fragment: " + node.name.value
|
|
64510
64317
|
)
|
|
64511
64318
|
);
|
|
@@ -64515,7 +64322,7 @@ var validateLists = ({
|
|
|
64515
64322
|
const listName = config.listNameFromFragment(node.name.value);
|
|
64516
64323
|
if (!lists.includes(listName)) {
|
|
64517
64324
|
ctx.reportError(
|
|
64518
|
-
new
|
|
64325
|
+
new graphql29.GraphQLError(
|
|
64519
64326
|
"Encountered fragment referencing unknown list: " + listName
|
|
64520
64327
|
)
|
|
64521
64328
|
);
|
|
@@ -64540,7 +64347,7 @@ var validateLists = ({
|
|
|
64540
64347
|
);
|
|
64541
64348
|
if (parentArg) {
|
|
64542
64349
|
ctx.reportError(
|
|
64543
|
-
new
|
|
64350
|
+
new graphql29.GraphQLError(
|
|
64544
64351
|
`@${config.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
64545
64352
|
)
|
|
64546
64353
|
);
|
|
@@ -64556,7 +64363,7 @@ var validateLists = ({
|
|
|
64556
64363
|
return;
|
|
64557
64364
|
}
|
|
64558
64365
|
ctx.reportError(
|
|
64559
|
-
new
|
|
64366
|
+
new graphql29.GraphQLError(
|
|
64560
64367
|
`For this list fragment, you need to add or @${config.listParentDirective} or @${config.listAllListsDirective} directive to specify the behavior`
|
|
64561
64368
|
)
|
|
64562
64369
|
);
|
|
@@ -64566,7 +64373,7 @@ var validateLists = ({
|
|
|
64566
64373
|
const directiveName = node.name.value;
|
|
64567
64374
|
if (directiveName === "connection") {
|
|
64568
64375
|
ctx.reportError(
|
|
64569
|
-
new
|
|
64376
|
+
new graphql29.GraphQLError(
|
|
64570
64377
|
"@connection was renamed to @list. Please change your components. If you were using `cache.connection` in your components, you will need to update that to `cache.list` too."
|
|
64571
64378
|
)
|
|
64572
64379
|
);
|
|
@@ -64575,7 +64382,7 @@ var validateLists = ({
|
|
|
64575
64382
|
if (!config.isInternalDirective(node.name.value)) {
|
|
64576
64383
|
if (!config.schema.getDirective(directiveName)) {
|
|
64577
64384
|
ctx.reportError(
|
|
64578
|
-
new
|
|
64385
|
+
new graphql29.GraphQLError(
|
|
64579
64386
|
"Encountered unknown directive: " + directiveName
|
|
64580
64387
|
)
|
|
64581
64388
|
);
|
|
@@ -64584,7 +64391,7 @@ var validateLists = ({
|
|
|
64584
64391
|
}
|
|
64585
64392
|
if (config.isListOperationDirective(directiveName) && !listTypes.includes(config.listNameFromDirective(directiveName))) {
|
|
64586
64393
|
ctx.reportError(
|
|
64587
|
-
new
|
|
64394
|
+
new graphql29.GraphQLError(
|
|
64588
64395
|
"Encountered directive referencing unknown list: " + directiveName
|
|
64589
64396
|
)
|
|
64590
64397
|
);
|
|
@@ -64595,7 +64402,7 @@ var validateLists = ({
|
|
|
64595
64402
|
};
|
|
64596
64403
|
function knownArguments(config) {
|
|
64597
64404
|
return function(ctx) {
|
|
64598
|
-
const nativeValidator =
|
|
64405
|
+
const nativeValidator = graphql29.KnownArgumentNamesRule(ctx);
|
|
64599
64406
|
return {
|
|
64600
64407
|
...nativeValidator,
|
|
64601
64408
|
Directive(directiveNode) {
|
|
@@ -64630,7 +64437,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64630
64437
|
for (const arg of node.arguments || []) {
|
|
64631
64438
|
if (arg.value.kind !== "ObjectValue") {
|
|
64632
64439
|
ctx.reportError(
|
|
64633
|
-
new
|
|
64440
|
+
new graphql29.GraphQLError("values in @arguments must be an object")
|
|
64634
64441
|
);
|
|
64635
64442
|
return;
|
|
64636
64443
|
}
|
|
@@ -64640,13 +64447,13 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64640
64447
|
);
|
|
64641
64448
|
if (!typeArg) {
|
|
64642
64449
|
ctx.reportError(
|
|
64643
|
-
new
|
|
64450
|
+
new graphql29.GraphQLError("missing type field for @arguments directive")
|
|
64644
64451
|
);
|
|
64645
64452
|
return;
|
|
64646
64453
|
}
|
|
64647
|
-
if (typeArg.value.kind !==
|
|
64454
|
+
if (typeArg.value.kind !== graphql29.Kind.STRING) {
|
|
64648
64455
|
ctx.reportError(
|
|
64649
|
-
new
|
|
64456
|
+
new graphql29.GraphQLError("type field to @arguments must be a string")
|
|
64650
64457
|
);
|
|
64651
64458
|
return;
|
|
64652
64459
|
}
|
|
@@ -64659,7 +64466,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64659
64466
|
);
|
|
64660
64467
|
if (typeArg.value.value !== defaultValueType) {
|
|
64661
64468
|
ctx.reportError(
|
|
64662
|
-
new
|
|
64469
|
+
new graphql29.GraphQLError(
|
|
64663
64470
|
`Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
|
|
64664
64471
|
)
|
|
64665
64472
|
);
|
|
@@ -64677,7 +64484,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64677
64484
|
try {
|
|
64678
64485
|
args = fragmentArguments(config, filepath, fragments[fragmentName]);
|
|
64679
64486
|
} catch (e) {
|
|
64680
|
-
ctx.reportError(new
|
|
64487
|
+
ctx.reportError(new graphql29.GraphQLError(e.message));
|
|
64681
64488
|
return;
|
|
64682
64489
|
}
|
|
64683
64490
|
fragmentArguments2[fragmentName] = args;
|
|
@@ -64700,7 +64507,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64700
64507
|
);
|
|
64701
64508
|
if (missing.length > 0) {
|
|
64702
64509
|
ctx.reportError(
|
|
64703
|
-
new
|
|
64510
|
+
new graphql29.GraphQLError(
|
|
64704
64511
|
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
64705
64512
|
)
|
|
64706
64513
|
);
|
|
@@ -64711,7 +64518,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64711
64518
|
);
|
|
64712
64519
|
if (unknown.length > 0) {
|
|
64713
64520
|
ctx.reportError(
|
|
64714
|
-
new
|
|
64521
|
+
new graphql29.GraphQLError(
|
|
64715
64522
|
"Encountered unknown arguments: " + JSON.stringify(unknown)
|
|
64716
64523
|
)
|
|
64717
64524
|
);
|
|
@@ -64723,7 +64530,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64723
64530
|
for (const [applied, target] of zipped) {
|
|
64724
64531
|
if (!valueIsType(config, applied.value, target)) {
|
|
64725
64532
|
ctx.reportError(
|
|
64726
|
-
new
|
|
64533
|
+
new graphql29.GraphQLError(
|
|
64727
64534
|
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
64728
64535
|
)
|
|
64729
64536
|
);
|
|
@@ -64765,7 +64572,7 @@ function valueIsType(config, value, targetType) {
|
|
|
64765
64572
|
}
|
|
64766
64573
|
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
64767
64574
|
const enumType = config.schema.getType(targetType.name.value);
|
|
64768
|
-
if (!
|
|
64575
|
+
if (!graphql29.isEnumType(enumType)) {
|
|
64769
64576
|
return false;
|
|
64770
64577
|
}
|
|
64771
64578
|
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
@@ -64785,7 +64592,7 @@ function paginateArgs(config, filepath) {
|
|
|
64785
64592
|
}
|
|
64786
64593
|
if (alreadyPaginated) {
|
|
64787
64594
|
ctx.reportError(
|
|
64788
|
-
new
|
|
64595
|
+
new graphql29.GraphQLError(
|
|
64789
64596
|
`@${config.paginateDirective} can only appear in a document once.`
|
|
64790
64597
|
)
|
|
64791
64598
|
);
|
|
@@ -64817,7 +64624,7 @@ function paginateArgs(config, filepath) {
|
|
|
64817
64624
|
const backwards = appliedArgs.has("last");
|
|
64818
64625
|
if (!forward && !backwards) {
|
|
64819
64626
|
ctx.reportError(
|
|
64820
|
-
new
|
|
64627
|
+
new graphql29.GraphQLError(
|
|
64821
64628
|
"A field with cursor-based pagination must have a first or last argument"
|
|
64822
64629
|
)
|
|
64823
64630
|
);
|
|
@@ -64831,7 +64638,7 @@ function paginateArgs(config, filepath) {
|
|
|
64831
64638
|
}
|
|
64832
64639
|
if (forward && backwards && paginateMode === "Infinite") {
|
|
64833
64640
|
ctx.reportError(
|
|
64834
|
-
new
|
|
64641
|
+
new graphql29.GraphQLError(
|
|
64835
64642
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
64836
64643
|
)
|
|
64837
64644
|
);
|
|
@@ -64845,7 +64652,7 @@ function paginateArgs(config, filepath) {
|
|
|
64845
64652
|
);
|
|
64846
64653
|
if (!appliedLimitArg) {
|
|
64847
64654
|
ctx.reportError(
|
|
64848
|
-
new
|
|
64655
|
+
new graphql29.GraphQLError(
|
|
64849
64656
|
"A field with offset-based pagination must have a limit argument"
|
|
64850
64657
|
)
|
|
64851
64658
|
);
|
|
@@ -64861,20 +64668,20 @@ function noUnusedFragmentArguments(config) {
|
|
|
64861
64668
|
const args = /* @__PURE__ */ new Set();
|
|
64862
64669
|
return {
|
|
64863
64670
|
enter(node) {
|
|
64864
|
-
if (node.kind ===
|
|
64671
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
64865
64672
|
const definitionArguments = node.directives?.filter((directive) => directive.name.value === config.argumentsDirective).flatMap((directive) => directive.arguments);
|
|
64866
64673
|
for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
|
|
64867
64674
|
args.add(arg);
|
|
64868
64675
|
}
|
|
64869
|
-
} else if (node.kind ===
|
|
64676
|
+
} else if (node.kind === graphql29.Kind.VARIABLE) {
|
|
64870
64677
|
args.delete(node.name.value);
|
|
64871
64678
|
}
|
|
64872
64679
|
},
|
|
64873
64680
|
leave(node) {
|
|
64874
|
-
if (node.kind ===
|
|
64681
|
+
if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
|
|
64875
64682
|
if (args.size > 0) {
|
|
64876
64683
|
ctx.reportError(
|
|
64877
|
-
new
|
|
64684
|
+
new graphql29.GraphQLError(
|
|
64878
64685
|
"Encountered unused fragment arguments: " + [...args].join(",")
|
|
64879
64686
|
)
|
|
64880
64687
|
);
|
|
@@ -64910,7 +64717,7 @@ function nodeDirectives(config, directives) {
|
|
|
64910
64717
|
if (definition.kind === "OperationDefinition") {
|
|
64911
64718
|
if (definition.operation !== "query") {
|
|
64912
64719
|
ctx.reportError(
|
|
64913
|
-
new
|
|
64720
|
+
new graphql29.GraphQLError(
|
|
64914
64721
|
`@${node.name.value} must fall on a fragment or query document`
|
|
64915
64722
|
)
|
|
64916
64723
|
);
|
|
@@ -64922,7 +64729,7 @@ function nodeDirectives(config, directives) {
|
|
|
64922
64729
|
}
|
|
64923
64730
|
if (!possibleNodes.includes(definitionType)) {
|
|
64924
64731
|
ctx.reportError(
|
|
64925
|
-
new
|
|
64732
|
+
new graphql29.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
64926
64733
|
);
|
|
64927
64734
|
}
|
|
64928
64735
|
}
|
|
@@ -64941,7 +64748,7 @@ function checkMutationOperation(config) {
|
|
|
64941
64748
|
);
|
|
64942
64749
|
if (append && prepend) {
|
|
64943
64750
|
ctx.reportError(
|
|
64944
|
-
new
|
|
64751
|
+
new graphql29.GraphQLError(
|
|
64945
64752
|
`You can't apply both @${config.listPrependDirective} and @${config.listAppendDirective} at the same time`
|
|
64946
64753
|
)
|
|
64947
64754
|
);
|
|
@@ -64955,7 +64762,7 @@ function checkMutationOperation(config) {
|
|
|
64955
64762
|
);
|
|
64956
64763
|
if (parentId && allLists) {
|
|
64957
64764
|
ctx.reportError(
|
|
64958
|
-
new
|
|
64765
|
+
new graphql29.GraphQLError(
|
|
64959
64766
|
`You can't apply both @${config.listParentDirective} and @${config.listAllListsDirective} at the same time`
|
|
64960
64767
|
)
|
|
64961
64768
|
);
|
|
@@ -64977,7 +64784,7 @@ function checkMaskDirectives(config) {
|
|
|
64977
64784
|
);
|
|
64978
64785
|
if (maskEnableDirective && maskDisableDirective) {
|
|
64979
64786
|
ctx.reportError(
|
|
64980
|
-
new
|
|
64787
|
+
new graphql29.GraphQLError(
|
|
64981
64788
|
`You can't apply both @${config.maskEnableDirective} and @${config.maskDisableDirective} at the same time`
|
|
64982
64789
|
)
|
|
64983
64790
|
);
|
|
@@ -65019,7 +64826,7 @@ function validateLoadingDirective(config) {
|
|
|
65019
64826
|
);
|
|
65020
64827
|
if (!parentLoading && !global2) {
|
|
65021
64828
|
ctx.reportError(
|
|
65022
|
-
new
|
|
64829
|
+
new graphql29.GraphQLError(
|
|
65023
64830
|
`@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
|
|
65024
64831
|
)
|
|
65025
64832
|
);
|
|
@@ -65041,7 +64848,7 @@ function validateLoadingDirective(config) {
|
|
|
65041
64848
|
);
|
|
65042
64849
|
if (!parentLoading && !global2) {
|
|
65043
64850
|
ctx.reportError(
|
|
65044
|
-
new
|
|
64851
|
+
new graphql29.GraphQLError(
|
|
65045
64852
|
`@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
|
|
65046
64853
|
)
|
|
65047
64854
|
);
|
|
@@ -65056,7 +64863,7 @@ function getAndVerifyNodeInterface(config) {
|
|
|
65056
64863
|
if (!nodeInterface) {
|
|
65057
64864
|
return null;
|
|
65058
64865
|
}
|
|
65059
|
-
if (!
|
|
64866
|
+
if (!graphql29.isInterfaceType(nodeInterface)) {
|
|
65060
64867
|
displayInvalidNodeFieldMessage(config);
|
|
65061
64868
|
return null;
|
|
65062
64869
|
}
|
|
@@ -65151,11 +64958,11 @@ async function uniqueDocumentNames(config, docs) {
|
|
|
65151
64958
|
}
|
|
65152
64959
|
|
|
65153
64960
|
// src/codegen/validators/noIDAlias.ts
|
|
65154
|
-
import * as
|
|
64961
|
+
import * as graphql30 from "graphql";
|
|
65155
64962
|
async function noIDAlias(config, docs) {
|
|
65156
64963
|
const errors = [];
|
|
65157
64964
|
for (const { filename, document } of docs) {
|
|
65158
|
-
|
|
64965
|
+
graphql30.visit(document, {
|
|
65159
64966
|
Field(node, _, __, ___, ancestors) {
|
|
65160
64967
|
const fieldType = parentTypeFromAncestors(config.schema, filename, ancestors).name;
|
|
65161
64968
|
if (config.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
|
|
@@ -65194,11 +65001,11 @@ async function validatePlugins(config, documents) {
|
|
|
65194
65001
|
}
|
|
65195
65002
|
|
|
65196
65003
|
// src/codegen/validators/componentFields.ts
|
|
65197
|
-
import * as
|
|
65004
|
+
import * as graphql31 from "graphql";
|
|
65198
65005
|
async function componentFields2(config, docs) {
|
|
65199
65006
|
const errors = [];
|
|
65200
65007
|
for (const { filename: filepath, document } of docs) {
|
|
65201
|
-
|
|
65008
|
+
graphql31.visit(document, {
|
|
65202
65009
|
FragmentDefinition(node, _, __, ___, ancestors) {
|
|
65203
65010
|
const componentFieldDirective = node.directives?.find(
|
|
65204
65011
|
(dir) => dir.name.value === config.componentFieldDirective
|
|
@@ -65246,7 +65053,7 @@ async function componentFields2(config, docs) {
|
|
|
65246
65053
|
if (existingField && existingField.filepath !== filepath) {
|
|
65247
65054
|
conflict = true;
|
|
65248
65055
|
} else if (parentType && fieldValue) {
|
|
65249
|
-
const fieldDef =
|
|
65056
|
+
const fieldDef = graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
65250
65057
|
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
65251
65058
|
(dir) => dir.name.value === config.componentFieldDirective
|
|
65252
65059
|
)) {
|
|
@@ -65259,7 +65066,7 @@ async function componentFields2(config, docs) {
|
|
|
65259
65066
|
filepath
|
|
65260
65067
|
});
|
|
65261
65068
|
}
|
|
65262
|
-
if (parentType &&
|
|
65069
|
+
if (parentType && graphql31.isAbstractType(parentType)) {
|
|
65263
65070
|
errors.push({
|
|
65264
65071
|
message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
|
|
65265
65072
|
filepath
|
|
@@ -65480,12 +65287,12 @@ async function processJSFile(config, contents) {
|
|
|
65480
65287
|
return documents;
|
|
65481
65288
|
}
|
|
65482
65289
|
async function processGraphQLDocument(config, filepath, document) {
|
|
65483
|
-
const parsedDoc =
|
|
65290
|
+
const parsedDoc = graphql32.parse(document);
|
|
65484
65291
|
const operations = parsedDoc.definitions.filter(
|
|
65485
|
-
({ kind: kind2 }) => kind2 ===
|
|
65292
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.OPERATION_DEFINITION
|
|
65486
65293
|
);
|
|
65487
65294
|
const fragments = parsedDoc.definitions.filter(
|
|
65488
|
-
({ kind: kind2 }) => kind2 ===
|
|
65295
|
+
({ kind: kind2 }) => kind2 === graphql32.Kind.FRAGMENT_DEFINITION
|
|
65489
65296
|
);
|
|
65490
65297
|
if (operations.length > 1) {
|
|
65491
65298
|
throw new HoudiniError({
|