Skip to content

Commit 4a06f94

Browse files
committed
update
1 parent c7200be commit 4a06f94

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/runtime/src/client/query-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ export function hasModel(schema: SchemaDef, model: string) {
1414
}
1515

1616
export function getModel(schema: SchemaDef, model: string) {
17-
return schema.models[model];
17+
return Object.values(schema.models).find((m) => m.name.toLowerCase() === model.toLowerCase());
1818
}
1919

2020
export function getTypeDef(schema: SchemaDef, type: string) {
2121
return schema.typeDefs?.[type];
2222
}
2323

2424
export function requireModel(schema: SchemaDef, model: string) {
25-
const matchedName = Object.keys(schema.models).find((k) => k.toLowerCase() === model.toLowerCase());
26-
if (!matchedName) {
25+
const modelDef = getModel(schema, model);
26+
if (!modelDef) {
2727
throw new QueryError(`Model "${model}" not found in schema`);
2828
}
29-
return schema.models[matchedName]!;
29+
return modelDef;
3030
}
3131

3232
export function getField(schema: SchemaDef, model: string, field: string) {

0 commit comments

Comments
 (0)