reym
CRUDSchemaObject

@searchable

You can mark types as searchable by using the @searchable directive.

You need to configure typesense in your Fraeym installation for this to work. Fraeym uses typesense as the search engine to provide fuzzy search and more.

Example

user.graphql
type User @crudType @searchable {
    name: String!
    email: String!
}

In this example the User type will be searchable. Please have a look at the field directives related to search: @facetedSearch, @fullTextSearch and @sortable.

Example of a Public Searchable Type

In order to make the searchable type usable for a public facing search, you need to add the publicSearchKey argument to the @searchable directive.

user.graphql
type User @crudType @searchable(publicSearchKey: "your-secret-key") {
    name: String!
    email: String!
}

In most cases it is recommended to use env variables to set the publicSearchKey.

user.graphql
type User @crudType @searchable(publicSearchKey: "{{env.PUBLIC_SEARCH_KEY}}") {
    name: String!
    email: String!
}

The publicSearchKey needs to vary in the first 4 letters in order to be seen as "different". This is due to a limitation of the key management process in typesense.

Therefore: if you change a key you need to ensure there is a change in the first 4 letters.