forked from ghostdogpr/caliban
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Deprecated directive on handrolled fields (ghostdogpr#1168)
* wip support deprecated on hand rolled schemas * fix test * set deprecated for fieldWithArgs as well * Extract helpers
- Loading branch information
Showing
3 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
package caliban.parsing.adt | ||
|
||
import caliban.InputValue | ||
import caliban.{ InputValue, Value } | ||
|
||
case class Directive(name: String, arguments: Map[String, InputValue] = Map.empty, index: Int = 0) | ||
|
||
object Directives { | ||
def isDeprecated(directives: List[Directive]): Boolean = | ||
directives.exists(_.name == "deprecated") | ||
|
||
def deprecationReason(directives: List[Directive]): Option[String] = | ||
directives.collectFirst { | ||
case f if f.name == "deprecated" => | ||
f.arguments | ||
.get("reason") | ||
.flatMap(_ match { | ||
case Value.StringValue(value) => Some(value) | ||
case _ => None | ||
}) | ||
}.flatten | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters