Middleware Settings

This lesson is focused on middleware default settings.

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:

Press + to interact
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:

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

Any ...