Type Alias ObjectCustomMappingDefinition<T>

ObjectCustomMappingDefinition<T>: BaseCustomMappingDefinition & {
    graphQlSchemaExtension?: string;
    graphQlType: string;
    outputFn: ((values: TSTypeForFieldType<T>[], groupByProduct: boolean) => any);
    typesenseType: T;
    valueFn: ((args: ValueFunctionArgs) => TSTypeForFieldType<T> | Promise<TSTypeForFieldType<T>>);
}

Defines a new CustomMapping which uses a GraphQL object type as its return type. In order to determine how the value stored in Typesense should be converted to the output GraphQL type, you must provide an outputFn function.

Type Parameters

Type declaration

  • OptionalgraphQlSchemaExtension?: string

    If the graphQlType is a custom GraphQL type, then you must provide the corresponding GraphQL schema extension here. If you are using a GraphQL type that already exists in the schema, then this can be omitted.

  • graphQlType: string

    The GraphQL data type that will be returned for this field in the customMappings object of a SearchResult.

  • outputFn: ((values: TSTypeForFieldType<T>[], groupByProduct: boolean) => any)

    Used to convert the stored value to the GraphQL type when returned from the search query.

      • (values, groupByProduct): any
      • Parameters

        • values: TSTypeForFieldType<T>[]
        • groupByProduct: boolean

        Returns any

  • typesenseType: T

    The Typesense data type that will be used to store this field in the Typesense index.

  • valueFn: ((args: ValueFunctionArgs) => TSTypeForFieldType<T> | Promise<TSTypeForFieldType<T>>)

    This function defines how the custom mapping data is obtained based on the ProductVariant and LanguageCode that get passed in.

      • (args): TSTypeForFieldType<T> | Promise<TSTypeForFieldType<T>>
      • Parameters

        • args: ValueFunctionArgs

        Returns TSTypeForFieldType<T> | Promise<TSTypeForFieldType<T>>