determineQueryType :: Text -> IO QueryType
determineQueryType queryArg
  | isQueryPrefix "query DGraph" = return QTDGraph
  | isQueryPrefix "query OMS" = return QTOMS
  | isQueryPrefix "query Serialization" = return QTSerialization
  | isQueryPrefix "query SignatureMorphism" = return QTSignatureMorphism
  | isQueryPrefix "query Signature" = return QTSignature
  | otherwise =
      fail ("Query not supported.\n"
            ++ "The query must begin with \"query X\", where X is one of "
            ++ "DGraph, OMS, Serialization, Signature, SignatureMorphism\n"
            ++ "This is due to a limitation of only mimicking a GraphQL API.")
  where
    isQueryPrefix :: String -> Bool
    isQueryPrefix s = Text.isPrefixOf (Text.pack s) queryArg
determineQueryType :: Text -> IO QueryType
determineQueryType queryArg
  | isQueryPrefix "query DGraph" = return QTDGraph
  | isQueryPrefix "query OMS" = return QTOMS
  | isQueryPrefix "query Serialization" = return QTSerialization
  | isQueryPrefix "query SignatureMorphism" = return QTSignatureMorphism
  | isQueryPrefix "query Signature" = return QTSignature
  | otherwise =
      fail ("Query not supported.\n"
            ++ "The query must begin with \"query X\", where X is one of "
            ++ "DGraph, OMS, Serialization, Signature, SignatureMorphism\n"
            ++ "This is due to a limitation of only mimicking a GraphQL API.")
  where
    isQueryPrefix :: String -> Bool
    isQueryPrefix s = Text.isPrefixOf (Text.pack s) queryArg
determineQueryType queryArg
  | isQueryPrefix "query DGraph" = return QTDGraph
  | isQueryPrefix "query OMS" = return QTOMS
  | isQueryPrefix "query Serialization" = return QTSerialization
  | isQueryPrefix "query SignatureMorphism" = return QTSignatureMorphism
  | isQueryPrefix "query Signature" = return QTSignature
  | otherwise =
      fail ("Query not supported.\n"
            ++ "The query must begin with \"query X\", where X is one of "
            ++ "DGraph, OMS, Serialization, Signature, SignatureMorphism\n"
            ++ "This is due to a limitation of only mimicking a GraphQL API.")
  where
    isQueryPrefix :: String -> Bool
    isQueryPrefix s = Text.isPrefixOf (Text.pack s) queryArg