Search⌘ K

Middleware Settings

Explore how Absinthe's default middleware resolves fields without explicit resolvers and learn to customize this process to accommodate data from various sources like JSONB columns, improving your GraphQL API's flexibility and accuracy.

We'll cover the following...

Default settings

Now that we feel comfortable with middleware, we’re in a good place to address an important question: how do fields without specific resolvers actually resolve anything? Throughout the entire course, we’ve had things like these in our schema:

object :menu_item do
field :name, :string
# ... other fields
end

Despite the fact that the :name field has no obvious resolver, we nonetheless can include it in a GraphQL query and get a result. What we need to do is look at what actually happens here. We will not only find a feature we can use ourselves but more importantly, a tool we can customize when the default behavior doesn’t suit the data we are working with.

As we might recall from the Making a Query lesson, the default resolution logic does something equivalent to this at this point:

C++
field :name, :string do
resolve fn parent, _, _ ->
{:ok, Map.get(parent, :name)} end
end

Any time a def ...