forked from OSS/graphql
Make operation name optional
This commit is contained in:
parent
693b7d18dc
commit
8b09c8aa76
@ -25,7 +25,7 @@ data Definition = DefinitionOperation OperationDefinition
|
|||||||
|
|
||||||
data OperationDefinition = OperationSelectionSet SelectionSet
|
data OperationDefinition = OperationSelectionSet SelectionSet
|
||||||
| OperationDefinition OperationType
|
| OperationDefinition OperationType
|
||||||
Name
|
(Maybe Name)
|
||||||
VariableDefinitions
|
VariableDefinitions
|
||||||
Directives
|
Directives
|
||||||
SelectionSet
|
SelectionSet
|
||||||
|
@ -22,9 +22,9 @@ definition (DefinitionFragment x) = fragmentDefinition x
|
|||||||
operationDefinition :: OperationDefinition -> Text
|
operationDefinition :: OperationDefinition -> Text
|
||||||
operationDefinition (OperationSelectionSet sels) = selectionSet sels
|
operationDefinition (OperationSelectionSet sels) = selectionSet sels
|
||||||
operationDefinition (OperationDefinition Query name vars dirs 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) =
|
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 -> VariableDefinitions -> Directives -> SelectionSet -> Text
|
||||||
node name vars dirs sels =
|
node name vars dirs sels =
|
||||||
|
@ -54,7 +54,7 @@ definition = DefinitionOperation <$> operationDefinition
|
|||||||
operationDefinition :: Parser OperationDefinition
|
operationDefinition :: Parser OperationDefinition
|
||||||
operationDefinition = OperationSelectionSet <$> selectionSet
|
operationDefinition = OperationSelectionSet <$> selectionSet
|
||||||
<|> OperationDefinition <$> operationType
|
<|> OperationDefinition <$> operationType
|
||||||
<*> name
|
<*> optional name
|
||||||
<*> opt variableDefinitions
|
<*> opt variableDefinitions
|
||||||
<*> opt directives
|
<*> opt directives
|
||||||
<*> selectionSet
|
<*> selectionSet
|
||||||
|
Loading…
Reference in New Issue
Block a user