diff --git a/README.md b/README.md index a9e4c2b..d1b060c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,22 @@ end defmodule MyApp.Schema do use Absinthe.Schema @prototype_schema AbsintheHelpers.Directives.Constraints + + directive :constraints do + on([:argument_definition, :field_definition, :input_field_definition]) + + arg(:min, :integer, description: "Minimum value allowed") + arg(:max, :integer, description: "Maximum value allowed") + arg(:min_items, :integer, description: "Minimum number of items allowed in a list") + arg(:max_items, :integer, description: "Maximum number of items allowed in a list") + end + + query do + end + + mutation do + end + # ... end ``` diff --git a/lib/phases/apply_constraints.ex b/lib/phases/apply_constraints.ex index e5bad77..79adee8 100644 --- a/lib/phases/apply_constraints.ex +++ b/lib/phases/apply_constraints.ex @@ -18,7 +18,17 @@ defmodule AbsintheHelpers.Phases.ApplyConstraints do defmodule MyApp.Schema do use Absinthe.Schema + @prototype_schema AbsintheHelpers.Directives.Constraints + + directive :constraints do + on([:argument_definition, :field_definition, :input_field_definition]) + + arg(:min, :integer, description: "Minimum value allowed") + arg(:max, :integer, description: "Maximum value allowed") + arg(:min_items, :integer, description: "Minimum number of items allowed in a list") + arg(:max_items, :integer, description: "Maximum number of items allowed in a list") + end # ... end diff --git a/mix.exs b/mix.exs index 1e0a607..b59b3fa 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule AbsintheHelpers.MixProject do def project do [ app: :absinthe_helpers, - version: "0.1.5", + version: "0.1.6", elixir: "~> 1.16", start_permanent: Mix.env() == :prod, deps: deps(), @@ -45,7 +45,7 @@ defmodule AbsintheHelpers.MixProject do [ files: ["lib", "mix.exs", "README*"], licenses: ["MIT"], - links: %{"GitHub" => "https://github.com/surgeventures/absinthe_helpers"}, + links: %{"GitHub" => "https://github.com/surgeventures/absinthe_helpers"} ] end