Don't make unnecessary query

This avoids making the query if the a type matching the slug is not
found.