-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathdenormalize.ts
More file actions
24 lines (22 loc) · 683 Bytes
/
denormalize.ts
File metadata and controls
24 lines (22 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { getEntities } from './getEntities.js';
import LocalCache from './localCache.js';
import getUnvisit from './unvisit.js';
import type { Schema } from '../interface.js';
import type { DenormalizeNullable } from '../types.js';
import type { INVALID } from './symbol.js';
export function denormalize<S extends Schema>(
schema: S | undefined,
input: any,
entities: any,
args: readonly any[] = [],
): DenormalizeNullable<S> | typeof INVALID {
// undefined means don't do anything
if (schema === undefined || input === undefined) {
return input as any;
}
return getUnvisit(
getEntities(entities),
new LocalCache(),
args,
)(schema, input).data;
}