Returns the primary key fields for an Ecto schema.
GreenFairy.Adapters.Ecto (GreenFairy v0.3.0)
View SourceBacking adapter for Ecto schemas.
This adapter automatically detects Ecto schemas and provides:
- CQL Support: Extracts field metadata for filtering, infers operators from Ecto types
- DataLoader Support: Configures batched loading using Dataloader.Ecto
Supported Ecto Types
:string- text operations (eq, neq, contains, starts_with, ends_with, in, is_nil):integer,:float,:decimal- numeric comparisons (eq, neq, gt, lt, gte, lte, in, is_nil):boolean- equality only (eq, is_nil):id,:binary_id- id operations (eq, neq, in, is_nil):naive_datetime,:utc_datetime,:date,:time- temporal comparisons{:parameterized, Ecto.Enum, _}- enum operations (eq, neq, in, is_nil):map,:array- equality only (eq, is_nil)
Usage
The Ecto adapter is the default adapter and is auto-detected:
type "User", struct: MyApp.Accounts.User do
use GreenFairy.Extensions.CQL
field :id, non_null(:id)
field :name, :string
field :posts, list_of(:post) do
dataload :posts
end
endCQL will automatically detect that MyApp.Accounts.User is an Ecto schema
and the adapter will be used for both CQL filtering and DataLoader.
Summary
Functions
Returns the association struct for a given association name.
Returns associations defined on an Ecto schema.
Returns the CQL type prefix for this adapter.
Detects the CQL sub-adapter for an Ecto schema module.
Checks if a module is an Ecto schema.
Gets the Ecto repo for a given schema module.
Returns the primary key fields for an Ecto schema.
Returns the complete type-to-operators mapping.
Functions
Returns the association struct for a given association name.
Returns associations defined on an Ecto schema.
Returns the CQL type prefix for this adapter.
This prefix is used when generating CQL filter/operator type names in the GraphQL schema.
Detects the CQL sub-adapter for an Ecto schema module.
Looks up the schema's repo and detects the database adapter from it, then returns the corresponding CQL sub-adapter module.
Checks if a module is an Ecto schema.
Convenience function that delegates to handles?/1.
Gets the Ecto repo for a given schema module.
The repo is determined by:
- Checking if the module defines
__repo__/0 - Checking the
:green_fairy, :repoapplication config - Inferring from the module name (e.g., MyApp.Accounts.User -> MyApp.Repo)
Returns the complete type-to-operators mapping.
Useful for introspection and documentation.