From 8b09c8aa76cef5c56811a69aa0fd629186d9f9d9 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Fri, 3 Feb 2017 20:08:40 -0300 Subject: [PATCH] Make operation name optional --- Data/GraphQL/AST.hs | 2 +- Data/GraphQL/Encoder.hs | 4 ++-- Data/GraphQL/Parser.hs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Data/GraphQL/AST.hs b/Data/GraphQL/AST.hs index 8a7bbea..3378655 100644 --- a/Data/GraphQL/AST.hs +++ b/Data/GraphQL/AST.hs @@ -25,7 +25,7 @@ data Definition = DefinitionOperation OperationDefinition data OperationDefinition = OperationSelectionSet SelectionSet | OperationDefinition OperationType - Name + (Maybe Name) VariableDefinitions Directives SelectionSet diff --git a/Data/GraphQL/Encoder.hs b/Data/GraphQL/Encoder.hs index 083a31d..924bdea 100644 --- a/Data/GraphQL/Encoder.hs +++ b/Data/GraphQL/Encoder.hs @@ -22,9 +22,9 @@ definition (DefinitionFragment x) = fragmentDefinition x operationDefinition :: OperationDefinition -> Text operationDefinition (OperationSelectionSet sels) = selectionSet sels operationDefinition (OperationDefinition Query name vars dirs sels) = - "query " <> node name vars dirs sels + "query " <> node (fold name) vars dirs sels operationDefinition (OperationDefinition Mutation name vars dirs sels) = - "mutation " <> node name vars dirs sels + "mutation " <> node (fold name) vars dirs sels node :: Name -> VariableDefinitions -> Directives -> SelectionSet -> Text node name vars dirs sels = diff --git a/Data/GraphQL/Parser.hs b/Data/GraphQL/Parser.hs index 820a323..0fb0ffc 100644 --- a/Data/GraphQL/Parser.hs +++ b/Data/GraphQL/Parser.hs @@ -54,7 +54,7 @@ definition = DefinitionOperation <$> operationDefinition operationDefinition :: Parser OperationDefinition operationDefinition = OperationSelectionSet <$> selectionSet <|> OperationDefinition <$> operationType - <*> name + <*> optional name <*> opt variableDefinitions <*> opt directives <*> selectionSet