Calling a multitenant database in graphql

I have a company schema which is using a multitenant database. So I have to fetch a list of the company by the search term so if I type google. It should give me a list of the name who has google value.
and so what I’m doing is I have created a function like this in my schema:

  def search_companies("", _prefix), do: []

  def search_companies(search_term, prefix) do
    Company
    |> where([c], ilike(c.name, ^"%#{search_term}%"))
    |> Repo.all(prefix: prefix)
  end

#Graphql

I have a company_type which is defined like this

object :company do
    interfaces [:search_result]
    field :id, non_null(:id)
    field :name, :string
  end

   interface :search_result do
    field :name, :string
    resolve_type fn
      %MyApp.Core.Company{}, _ ->
      :company
    end
  end

So this is my schema_type

query do
   @desc "List of search companies"
    field :search, list_of(:search_result) do
    arg :matching, non_null(:string)
    resolve &Resolvers.Company.search/3
  end
end

And I’ve defined a resolver like this


  def search(_, %{matching: term, }, _) do
    {:ok,  Company.search_companies(term)}
  end

How do I call a resolver if I’m using a prefix in the schema? What should be the case here?
I’m new to both multitenant database and Graphql. This is my first attempt to make this work.

How do you determine the prefix generally?

I think you need to pattern match like this

  def search(_, %{matching: term, prefix: prefix}, _) do
    {:ok,  Core.search_courses(term, prefix)}
  end

It’s unlikely that the client knows what database prefix to use.