@soda-gql/core 0.14.1 → 0.14.3
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/dist/index-CRWc3q9X.d.cts.map +1 -1
- package/dist/index-DJ-yqsXz.d.ts.map +1 -1
- package/dist/index.cjs +46 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.cts.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -2186,6 +2186,49 @@ const isListType = (typeString) => {
|
|
|
2186
2186
|
return typeString.includes("[]");
|
|
2187
2187
|
};
|
|
2188
2188
|
|
|
2189
|
+
//#endregion
|
|
2190
|
+
//#region packages/core/src/composer/schema-object-suggestion.ts
|
|
2191
|
+
/**
|
|
2192
|
+
* Helper for producing "did you mean" hints when a schema object type name
|
|
2193
|
+
* lookup fails.
|
|
2194
|
+
* @module
|
|
2195
|
+
*/
|
|
2196
|
+
/**
|
|
2197
|
+
* Normalize a type name to a case-and-separator-insensitive key.
|
|
2198
|
+
*
|
|
2199
|
+
* Strips `_` / `-` separators and lowercases, so all common naming styles
|
|
2200
|
+
* collapse to the same key:
|
|
2201
|
+
* - `ShopDailyCashRegisterBalancing` (PascalCase)
|
|
2202
|
+
* - `shopDailyCashRegisterBalancing` (camelCase)
|
|
2203
|
+
* - `shop_daily_cash_register_balancing` (snake_case)
|
|
2204
|
+
* - `SHOP_DAILY_CASH_REGISTER_BALANCING` (CONSTANT_CASE)
|
|
2205
|
+
* - `shop-daily-cash-register-balancing` (kebab-case)
|
|
2206
|
+
* all normalize to `shopdailycashregisterbalancing`.
|
|
2207
|
+
*/
|
|
2208
|
+
const normalizeTypeName = (name) => name.replace(/[_-]/g, "").toLowerCase();
|
|
2209
|
+
/**
|
|
2210
|
+
* Build a "Did you mean" suffix for a missing schema object type name.
|
|
2211
|
+
*
|
|
2212
|
+
* Detects matches that differ only in naming convention (case and `_`/`-`
|
|
2213
|
+
* separators), which is the dominant cause of this failure: confusing a Hasura
|
|
2214
|
+
* table type's lowercase name (e.g. `shop`) with an action / custom output
|
|
2215
|
+
* type's PascalCase name (e.g. `ShopDailyCashRegisterBalancing`), or writing the
|
|
2216
|
+
* field's camelCase/snake_case name instead of its backing object type name.
|
|
2217
|
+
* Typos are intentionally NOT matched — only style differences are.
|
|
2218
|
+
*
|
|
2219
|
+
* Returns an empty string when no match exists, so callers can append the
|
|
2220
|
+
* result unconditionally without altering the base message in the common case.
|
|
2221
|
+
*
|
|
2222
|
+
* @param typeName - The missing type name that was requested.
|
|
2223
|
+
* @param available - The set of object type names that do exist in the schema.
|
|
2224
|
+
* @returns A leading-space-prefixed suggestion, or "" when none is found.
|
|
2225
|
+
*/
|
|
2226
|
+
const suggestSchemaObjectName = (typeName, available) => {
|
|
2227
|
+
const normalized = normalizeTypeName(typeName);
|
|
2228
|
+
for (const candidate of available) if (candidate !== typeName && normalizeTypeName(candidate) === normalized) return ` Did you mean "${candidate}"?`;
|
|
2229
|
+
return "";
|
|
2230
|
+
};
|
|
2231
|
+
|
|
2189
2232
|
//#endregion
|
|
2190
2233
|
//#region packages/core/src/composer/fields-builder.ts
|
|
2191
2234
|
const cacheMapBySchema = /* @__PURE__ */ new WeakMap();
|
|
@@ -2218,7 +2261,7 @@ const createFieldFactories = (schema, typeName) => {
|
|
|
2218
2261
|
};
|
|
2219
2262
|
const createFieldFactoriesInner = (schema, typeName) => {
|
|
2220
2263
|
const typeDef = schema.object[typeName];
|
|
2221
|
-
if (!typeDef) throw new Error(`Type ${typeName} is not defined in schema objects`);
|
|
2264
|
+
if (!typeDef) throw new Error(`Type ${typeName} is not defined in schema objects.${suggestSchemaObjectName(typeName, Object.keys(schema.object))}`);
|
|
2222
2265
|
return (fieldName, fieldArgs, extras) => {
|
|
2223
2266
|
if (fieldName === "__typename") {
|
|
2224
2267
|
const wrap$1 = (value) => require_schema_builder.wrapByKey(extras?.alias ?? fieldName, value);
|
|
@@ -2760,7 +2803,7 @@ function extractASTValue(node, varAssignments) {
|
|
|
2760
2803
|
*/
|
|
2761
2804
|
function resolveFieldTypeName(schema, typeName, fieldName) {
|
|
2762
2805
|
const typeDef = schema.object[typeName];
|
|
2763
|
-
if (!typeDef) throw new Error(`Type "${typeName}" is not defined in schema objects`);
|
|
2806
|
+
if (!typeDef) throw new Error(`Type "${typeName}" is not defined in schema objects.${suggestSchemaObjectName(typeName, Object.keys(schema.object))}`);
|
|
2764
2807
|
const fieldDef = typeDef.fields[fieldName];
|
|
2765
2808
|
if (!fieldDef) throw new Error(`Field "${fieldName}" is not defined on type "${typeName}"`);
|
|
2766
2809
|
return (typeof fieldDef === "string" ? fieldDef : fieldDef.spec).split("|")[1] ?? typeName;
|
|
@@ -2787,7 +2830,7 @@ function buildSyntheticFragmentSource(name, typeName, body) {
|
|
|
2787
2830
|
function createFragmentTaggedTemplate(schema) {
|
|
2788
2831
|
const schemaIndex = createSchemaIndexFromSchema(schema);
|
|
2789
2832
|
return (fragmentName, onType) => {
|
|
2790
|
-
if (!(onType in schema.object)) throw new Error(`Type "${onType}" is not defined in schema objects`);
|
|
2833
|
+
if (!(onType in schema.object)) throw new Error(`Type "${onType}" is not defined in schema objects.${suggestSchemaObjectName(onType, Object.keys(schema.object))}`);
|
|
2791
2834
|
return (strings, ...values) => {
|
|
2792
2835
|
for (let i = 0; i < values.length; i++) {
|
|
2793
2836
|
const value = values[i];
|