Skip to content

Commit

Permalink
Update config to add back page params and parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleboe committed Jun 14, 2024
1 parent 3792569 commit b2f8b23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/jsonapi/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ defmodule JSONAPI.Config do
include: [],
opts: nil,
sort: nil,
view: nil
view: nil,
page: %{}

@type t :: %__MODULE__{
data: nil | map,
Expand All @@ -18,6 +19,7 @@ defmodule JSONAPI.Config do
include: [atom | {atom, any}],
opts: nil | keyword,
sort: nil | keyword,
view: any
view: any,
page: nil | map
}
end
5 changes: 2 additions & 3 deletions lib/jsonapi/plugs/query_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,14 @@ defmodule JSONAPI.QueryParser do
|> parse_include(query_params_config_struct.include)
|> parse_filter(query_params_config_struct.filter)
|> parse_sort(query_params_config_struct.sort)

# |> parse_pagination(query_params_config_struct.page)
|> parse_pagination(query_params_config_struct.page)

Conn.assign(conn, :jsonapi_query, config)
end

def parse_pagination(config, map) when map_size(map) == 0, do: config

# def parse_pagination(%Config{} = config, page), do: Map.put(config, :page, page)
def parse_pagination(%Config{} = config, page), do: Map.put(config, :page, page)

@spec parse_filter(Config.t(), keyword()) :: Config.t()
def parse_filter(config, map) when map_size(map) == 0, do: config
Expand Down

0 comments on commit b2f8b23

Please sign in to comment.