public function filter($query, array $args = [])
    {
        $valuesGroupedByFilterKey = [];

        /**
         * @var string
         * @var mixed  $value
         */
        foreach ($args as $key => $value) {
            /**
             * @var string
             * @var string[] $argNames
             */
            foreach ($this->multiArgumentFiltersArgNames as $filterKey => $argNames) {
                // Group together the values if multiple arguments are given the same key
                if (in_array($key, $argNames)) {
                    $valuesGroupedByFilterKey[$filterKey][] = $value;
                }
            }

            // Filters that only take a single argument can be applied directly
            if ($filterInfo = Arr::get($this->singleArgumentFilters, $key)) {
                /** @var \Nuwave\Lighthouse\Support\Contracts\ArgFilterDirective $argFilterDirective */
                $argFilterDirective = $filterInfo['filter'];
                $columnName = $filterInfo['columnName'];

                $query = $argFilterDirective->applyFilter($query, $columnName, $value);
            }
        }

        /**
         * @var string
         * @var array  $values
         */
        foreach ($valuesGroupedByFilterKey as $filterKey => $values) {
            $columnName = Str::before($filterKey, '.');

            if ($values) {
                $argFilterDirective = $this->multiArgumentFilters[$filterKey];

                $query = $argFilterDirective->applyFilter($query, $columnName, $values);
            }
        }

        return $query;
    }