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:
object :menu_item dofield :name, :string# ... other fieldsend
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:
field :name, :string doresolve fn parent, _, _ ->{:ok, Map.get(parent, :name)} endend
Any ...