woylie

woylie

Flop 0.29.0 has been released.

Added

  • Add Flop.allowed_fields/2, which returns the fields that may be filtered or
    sorted for the given options.
  • Add Flop.Schema.flop_schema!/1, which returns the configuration of a schema
    module.
  • Add Flop.Cursor.get_cursor_from_node/3 and
    Flop.Cursor.get_cursor_from_edge/3, which take the query options and resolve
    a field against the schema given as :for.
  • Accept an arity-3 cursor_value_func, which also receives the options the
    query ran with.

Changed

  • Turn Flop.Schema from a protocol into a behaviour. Schemas are configured
    with use Flop.Schema and the @flop_options attribute now.
  • Take the schema module instead of a struct in Flop.Schema.field_info/2,
    Flop.Schema.get_field/3 and Flop.Schema.primary_key/1.
  • Default cursor_value_func to Flop.Cursor.get_cursor_from_node/3.

Removed

  • Remove default_limit/1, default_order/1, default_pagination_type/1,
    filterable/1, max_filters/1, max_limit/1, pagination_types/1,
    sortable/1 and tiebreaker/1 from Flop.Schema.

Fixed

  • Do not make a module named in an ecto_type a compile-time dependency of the
    schema.
  • Read a cursor value through the schema given as :for, so that a field’s
    :path is applied when the query returns plain maps rather than structs.

How to upgrade

Change your code to use Flop.Schema and set the options as @flop_options
instead of using @derive to derive the protocol.

 defmodule MyApp.Pet do
   use Ecto.Schema
+  use Flop.Schema

-  @derive {
-    Flop.Schema,
-    filterable: [:name, :species],
-    sortable: [:name, :age]
-  }
+  @flop_options [
+    filterable: [:name, :species],
+    sortable: [:name, :age]
+  ]

   schema "pets" do
     field :name, :string
     field :age, :integer
     field :species, :string
   end
 end

The attribute is read when the module finishes compiling, so it can go anywhere
in the module body. If you use an alias in the options, the alias has to be
declared before the module attribute.

The functions that returned a single schema option are gone. Read the effective
value through Flop.get_option/3, which also applies the backend module and the
application environment, or Flop.allowed_fields/2 for filterable and
sortable, which applies the narrowing a query function may have set:

-Flop.Schema.sortable(%MyApp.Pet{})
+Flop.allowed_fields(:sortable, for: MyApp.Pet)

-Flop.Schema.max_limit(%MyApp.Pet{})
+Flop.get_option(:max_limit, for: MyApp.Pet)

The remaining functions take the schema module instead of a struct:

-Flop.Schema.field_info(%MyApp.Pet{}, :name)
+Flop.Schema.field_info(MyApp.Pet, :name)

-Flop.Schema.get_field(pet, :owner_name)
+Flop.Schema.get_field(MyApp.Pet, pet, :owner_name)

An arity-2 cursor_value_func is still supported. You can use a 3-arity
function if you need the schema or other options passed to Flop, for example if
you need to apply the path option of join or custom fields.

-cursor_value_func: fn item, fields -> Map.take(item, fields) end
+cursor_value_func: fn item, fields, opts ->
+  Map.new(fields, &{&1, Flop.Schema.get_field(opts[:for], item, &1)})
+end

Where Next? Top

Trending in News & Updates Top

Jskalc
LiveVue v1.0 released After four release candidates and a lot of community feedback, LiveVue 1.0 is stable :tada: I’ve built a dedicated...
New
webofbits
Cairn is a small OTP library for message delivery, lightweight function processes, supervised work, and waiting on results. The goal is ...
New
nature
NatureWhistle v0.4.1 is out! :tada: This release is a pretty significant step forward for the project. When I first built NatureWhistle,...
New
webofbits
Aludel 0.8.0 is now available on GitHub and Hex. This release adds typed_judge assertions for evaluations that need deterministic, struc...
New
woylie
Flop Phoenix 0.27.0 has been released. Changed Require Flop 0.29.0, which turns Flop.Schema from a protocol into a behaviour. Determin...
New
woylie
LetMe 3.0.4 has been released. Changed Log the policy module and the check module in the message of the warning for a rule that does n...
New
woylie
Flop 0.29.0 has been released. Added Add Flop.allowed_fields/2, which returns the fields that may be filtered or sorted for the given ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews