protected function reduceFields(&$resource, array $fieldNames)
    {
        $keep = [];
        $totalReduced = 0;
        foreach ($resource->fields as $field) {
            if (in_array($field->name, $fieldNames) || in_array($field->name, $keep)) {
                $totalReduced++;
                continue;
            }

            $keep[] = $field;
        }

        $resource->fields = $keep;

        return $totalReduced;
    }