Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.1"
".": "0.3.0"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.3.0](https://github.com/GreenFairy-GraphQL/greenfairy/compare/green_fairy-v0.2.1...green_fairy-v0.3.0) (2026-03-04)


### Features

* Add field and type visibility for introspection filtering ([6846024](https://github.com/GreenFairy-GraphQL/greenfairy/commit/6846024dccf10a276ec0f686ac47f86fb349aeae))
* Auto-infer connection aggregates from node type fields ([762ce80](https://github.com/GreenFairy-GraphQL/greenfairy/commit/762ce80cd73da2e41f510677ec2c01b1f9805f22))

## [0.2.1](https://github.com/GreenFairy-GraphQL/greenfairy/compare/green_fairy-v0.2.0...green_fairy-v0.2.1) (2026-01-18)


Expand Down
2 changes: 1 addition & 1 deletion lib/green_fairy/enum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ defmodule GreenFairy.Enum do
quote do
@doc false
def __type_visible__(context) do
!!(unquote(visible_fn)).(context)
!!unquote(visible_fn).(context)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/green_fairy/input.ex
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ defmodule GreenFairy.Input do
quote do
@doc false
def __type_visible__(context) do
!!(unquote(visible_fn)).(context)
!!unquote(visible_fn).(context)
end
end
else
Expand All @@ -351,7 +351,7 @@ defmodule GreenFairy.Input do
|> Enum.map(fn {field_name, func} ->
quote do
def __field_visible__(unquote(field_name), context) do
!!(unquote(func)).(context)
!!unquote(func).(context)
end
end
end)
Expand Down
4 changes: 2 additions & 2 deletions lib/green_fairy/interface.ex
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ defmodule GreenFairy.Interface do
quote do
@doc false
def __type_visible__(context) do
!!(unquote(visible_fn)).(context)
!!unquote(visible_fn).(context)
end
end
else
Expand All @@ -219,7 +219,7 @@ defmodule GreenFairy.Interface do
|> Enum.map(fn {field_name, func} ->
quote do
def __field_visible__(unquote(field_name), context) do
!!(unquote(func)).(context)
!!unquote(func).(context)
end
end
end)
Expand Down
6 changes: 4 additions & 2 deletions lib/green_fairy/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ defmodule GreenFairy.Schema do
)
"""
def run(document, opts \\ []) do
Absinthe.run(document, __MODULE__,
Absinthe.run(
document,
__MODULE__,
Keyword.put(opts, :pipeline_modifier, &GreenFairy.Introspection.pipeline_modifier/2)
)
end
Expand Down Expand Up @@ -347,7 +349,7 @@ defmodule GreenFairy.Schema do
unquote(Macro.escape(discovered))
end
end
],
]
]
|> List.flatten()
|> Enum.reject(&is_nil/1)
Expand Down
22 changes: 15 additions & 7 deletions lib/green_fairy/type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,17 @@ defmodule GreenFairy.Type do
end

result = %{}
result = if sum_result && map_size(sum_result) > 0, do: Map.put(result, :sum, sum_result), else: result
result = if avg_result && map_size(avg_result) > 0, do: Map.put(result, :avg, avg_result), else: result
result = if min_result && map_size(min_result) > 0, do: Map.put(result, :min, min_result), else: result
result = if max_result && map_size(max_result) > 0, do: Map.put(result, :max, max_result), else: result
result =
if sum_result && map_size(sum_result) > 0, do: Map.put(result, :sum, sum_result), else: result

result =
if avg_result && map_size(avg_result) > 0, do: Map.put(result, :avg, avg_result), else: result

result =
if min_result && map_size(min_result) > 0, do: Map.put(result, :min, min_result), else: result

result =
if max_result && map_size(max_result) > 0, do: Map.put(result, :max, max_result), else: result

{:ok, if(map_size(result) > 0, do: result, else: nil)}
end)
Expand Down Expand Up @@ -660,7 +667,8 @@ defmodule GreenFairy.Type do
cql_args = build_connection_cql_args(type_module_expanded)

# Build resolver - use the struct_module from the type macro (available at compile time)
resolver = build_connection_resolver_ast(field_name, type_module_expanded, struct_module, custom_resolver, aggregates)
resolver =
build_connection_resolver_ast(field_name, type_module_expanded, struct_module, custom_resolver, aggregates)

quote do
# Track the node type reference
Expand Down Expand Up @@ -1143,7 +1151,7 @@ defmodule GreenFairy.Type do
quote do
@doc false
def __type_visible__(context) do
!!(unquote(visible_fn)).(context)
!!unquote(visible_fn).(context)
end
end
else
Expand All @@ -1159,7 +1167,7 @@ defmodule GreenFairy.Type do
|> Enum.map(fn {field_name, func} ->
quote do
def __field_visible__(unquote(field_name), context) do
!!(unquote(func)).(context)
!!unquote(func).(context)
end
end
end)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule GreenFairy.MixProject do
use Mix.Project

@version "0.2.1"
@version "0.3.0"
@source_url "https://github.com/GreenFairy-GraphQL/greenfairy"

def project do
Expand Down
8 changes: 4 additions & 4 deletions test/green_fairy/introspection/visibility_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule GreenFairy.Introspection.VisibilityTest do
field :name, :string

field :ssn, :string do
visible fn ctx -> ctx[:admin] end
visible(fn ctx -> ctx[:admin] end)
end
end
end
Expand All @@ -32,7 +32,7 @@ defmodule GreenFairy.Introspection.VisibilityTest do
use GreenFairy.Type

type "VisInternalMetrics", struct: TestSecret, cql: false do
visible fn ctx -> ctx[:admin] end
visible(fn ctx -> ctx[:admin] end)

field :cpu, :float
field :memory, :float
Expand All @@ -44,12 +44,12 @@ defmodule GreenFairy.Introspection.VisibilityTest do
use GreenFairy.Type

type "VisCombined", struct: TestSecret, cql: false do
visible fn ctx -> ctx[:admin] || ctx[:internal] end
visible(fn ctx -> ctx[:admin] || ctx[:internal] end)

field :cpu, :float

field :memory, :float do
visible fn ctx -> ctx[:admin] end
visible(fn ctx -> ctx[:admin] end)
end
end
end
Expand Down
Loading