Skip to content

Commit

Permalink
Merge pull request #443 from patch-tech/input-field-deprecation
Browse files Browse the repository at this point in the history
Add support for @deprecated directives on :argument-definition, :input-field-definition
  • Loading branch information
hlship authored Apr 28, 2023
2 parents 72711b9 + 295d3c4 commit 6ba6065
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/com/walmartlabs/lacinia/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@
(map-kvs compile-directive-args
(assoc directive-defs
:deprecated {:args {:reason {:type 'String}}
:locations #{:field-definition :enum-value}})))))
:locations #{:argument-definition :enum-value :field-definition :input-field-definition}})))))

(defn ^:private validate-directives-by-category
[schema category]
Expand Down
24 changes: 20 additions & 4 deletions test/com/walmartlabs/lacinia/directives_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@
(deftest union-directive-inapplicable
(directive-test
"Directive @deprecated on union `Ebb' is not applicable."
{:allowed-locations #{:enum-value
:field-definition}
{:allowed-locations #{:argument-definition
:enum-value
:field-definition
:input-field-definition}
:directive-type :deprecated
:union :Ebb}
{:objects
Expand All @@ -374,8 +376,10 @@
(deftest scalar-directive-inapplicable
(directive-test
"Directive @deprecated on scalar `Ebb' is not applicable."
{:allowed-locations #{:enum-value
:field-definition}
{:allowed-locations #{:argument-definition
:enum-value
:field-definition
:input-field-definition}
:directive-type :deprecated
:scalar :Ebb}
{:scalars
Expand Down Expand Up @@ -493,6 +497,18 @@
(is (= true
(get-in schema [:Account :fields :id :deprecated])))))

(deftest can-deprecate-input-fields
(let [schema (schema/compile
{:input-objects
{:Character
{:description "A character"
:fields {:name {:type '(non-null String)
:description "Character name"}
:weapon {:type '(non-null String)
:directives [{:directive-type :deprecated}]
:description "Weapon of choice"}}}}})]
;; Exception is not thrown
(is (any? schema))))

(deftest can-deprecate-enum-values
(let [schema (schema/compile
Expand Down

0 comments on commit 6ba6065

Please sign in to comment.