Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { METADATA } from '@/lib/data/metadata';
import type { MetadataEntry } from '@/lib/data/types';
import type { GraphQLContext } from '@/types/graphql/context';
export interface GetMetadataByKeyArgs {
key: string;
}
export interface GetMetadataByTypeArgs {
type: string;
}
/**
* Get all metadata entries
*/
export const getAllMetadata = async (
_parent: unknown,
_args: unknown,
_context: GraphQLContext,
): Promise<MetadataEntry[]> => {
return METADATA;
};
/**
* Get a specific metadata entry by its unique key
*/
export const getMetadataByKey = async (
_parent: unknown,
args: GetMetadataByKeyArgs,
_context: GraphQLContext,
): Promise<MetadataEntry | null> => {
return METADATA.find((m) => m.key === args.key) || null;
};
/**
* Get all metadata entries of a specific type (e.g., 'CATEGORY', 'UNIT')
*/
export const getMetadataByType = async (
_parent: unknown,
args: GetMetadataByTypeArgs,
_context: GraphQLContext,
): Promise<MetadataEntry[]> => {
return METADATA.filter(
(m) => m.type.toLowerCase() === args.type.toLowerCase(),
);
};
|