summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/AST
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/GraphQL/AST')
-rw-r--r--src/Language/GraphQL/AST/DirectiveLocation.hs36
-rw-r--r--src/Language/GraphQL/AST/Document.hs1
-rw-r--r--src/Language/GraphQL/AST/Encoder.hs1
3 files changed, 35 insertions, 3 deletions
diff --git a/src/Language/GraphQL/AST/DirectiveLocation.hs b/src/Language/GraphQL/AST/DirectiveLocation.hs
index c38c9ff..511225f 100644
--- a/src/Language/GraphQL/AST/DirectiveLocation.hs
+++ b/src/Language/GraphQL/AST/DirectiveLocation.hs
@@ -2,6 +2,8 @@
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at https://mozilla.org/MPL/2.0/. -}
+{-# LANGUAGE Safe #-}
+
-- | Various parts of a GraphQL document can be annotated with directives.
-- This module describes locations in a document where directives can appear.
module Language.GraphQL.AST.DirectiveLocation
@@ -16,7 +18,13 @@ module Language.GraphQL.AST.DirectiveLocation
data DirectiveLocation
= ExecutableDirectiveLocation ExecutableDirectiveLocation
| TypeSystemDirectiveLocation TypeSystemDirectiveLocation
- deriving (Eq, Show)
+ deriving Eq
+
+instance Show DirectiveLocation where
+ show (ExecutableDirectiveLocation directiveLocation) =
+ show directiveLocation
+ show (TypeSystemDirectiveLocation directiveLocation) =
+ show directiveLocation
-- | Where directives can appear in an executable definition, like a query.
data ExecutableDirectiveLocation
@@ -27,7 +35,16 @@ data ExecutableDirectiveLocation
| FragmentDefinition
| FragmentSpread
| InlineFragment
- deriving (Eq, Show)
+ deriving Eq
+
+instance Show ExecutableDirectiveLocation where
+ show Query = "QUERY"
+ show Mutation = "MUTATION"
+ show Subscription = "SUBSCRIPTION"
+ show Field = "FIELD"
+ show FragmentDefinition = "FRAGMENT_DEFINITION"
+ show FragmentSpread = "FRAGMENT_SPREAD"
+ show InlineFragment = "INLINE_FRAGMENT"
-- | Where directives can appear in a type system definition.
data TypeSystemDirectiveLocation
@@ -42,4 +59,17 @@ data TypeSystemDirectiveLocation
| EnumValue
| InputObject
| InputFieldDefinition
- deriving (Eq, Show)
+ deriving Eq
+
+instance Show TypeSystemDirectiveLocation where
+ show Schema = "SCHEMA"
+ show Scalar = "SCALAR"
+ show Object = "OBJECT"
+ show FieldDefinition = "FIELD_DEFINITION"
+ show ArgumentDefinition = "ARGUMENT_DEFINITION"
+ show Interface = "INTERFACE"
+ show Union = "UNION"
+ show Enum = "ENUM"
+ show EnumValue = "ENUM_VALUE"
+ show InputObject = "INPUT_OBJECT"
+ show InputFieldDefinition = "INPUT_FIELD_DEFINITION"
diff --git a/src/Language/GraphQL/AST/Document.hs b/src/Language/GraphQL/AST/Document.hs
index 0b118af..489a242 100644
--- a/src/Language/GraphQL/AST/Document.hs
+++ b/src/Language/GraphQL/AST/Document.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE Safe #-}
-- | This module defines an abstract syntax tree for the @GraphQL@ language. It
-- follows closely the structure given in the specification. Please refer to
diff --git a/src/Language/GraphQL/AST/Encoder.hs b/src/Language/GraphQL/AST/Encoder.hs
index dd464c2..51a801e 100644
--- a/src/Language/GraphQL/AST/Encoder.hs
+++ b/src/Language/GraphQL/AST/Encoder.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE Safe #-}
-- | This module defines a minifier and a printer for the @GraphQL@ language.
module Language.GraphQL.AST.Encoder