summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/GraphQL')
-rw-r--r--src/Language/GraphQL/AST/Encoder.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Language/GraphQL/AST/Encoder.hs b/src/Language/GraphQL/AST/Encoder.hs
index 4569823..54967ea 100644
--- a/src/Language/GraphQL/AST/Encoder.hs
+++ b/src/Language/GraphQL/AST/Encoder.hs
@@ -11,6 +11,7 @@ module Language.GraphQL.AST.Encoder
, directive
, document
, minified
+ , operationType
, pretty
, type'
, value
@@ -34,7 +35,7 @@ import qualified Language.GraphQL.AST.Document as Full
-- Use 'pretty' or 'minified' to construct the formatter.
data Formatter
= Minified
- | Pretty Word
+ | Pretty !Word
-- | Constructs a formatter for pretty printing.
pretty :: Formatter
@@ -294,6 +295,12 @@ nonNullType :: Full.NonNullType -> Lazy.Text
nonNullType (Full.NonNullTypeNamed x) = Lazy.Text.fromStrict x <> "!"
nonNullType (Full.NonNullTypeList x) = listType x <> "!"
+-- | Produces lowercase operation type: query, mutation or subscription.
+operationType :: Formatter -> Full.OperationType -> Lazy.Text
+operationType _formatter Full.Query = "query"
+operationType _formatter Full.Mutation = "mutation"
+operationType _formatter Full.Subscription = "subscription"
+
-- * Internal
between :: Char -> Char -> Lazy.Text -> Lazy.Text