Make operation name optional

This commit is contained in:
Danny Navarro 2017-02-03 20:08:40 -03:00
parent 693b7d18dc
commit 8b09c8aa76
No known key found for this signature in database
GPG Key ID: 81E5F99780FA6A32
3 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ data Definition = DefinitionOperation OperationDefinition
data OperationDefinition = OperationSelectionSet SelectionSet
| OperationDefinition OperationType
Name
(Maybe Name)
VariableDefinitions
Directives
SelectionSet

View File

@ -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 =

View File

@ -54,7 +54,7 @@ definition = DefinitionOperation <$> operationDefinition
operationDefinition :: Parser OperationDefinition
operationDefinition = OperationSelectionSet <$> selectionSet
<|> OperationDefinition <$> operationType
<*> name
<*> optional name
<*> opt variableDefinitions
<*> opt directives
<*> selectionSet