From 381e93f3f10745a9122fa444d6514bd9d9abedc2 Mon Sep 17 00:00:00 2001 From: Georgy Shabunin Date: Thu, 12 Sep 2024 15:57:18 +0100 Subject: [PATCH] Improve docs --- README.md | 16 ++++++++++++++++ lib/phases/apply_constraints.ex | 10 ++++++++++ 2 files changed, 26 insertions(+) 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