Encode schema extensions
This commit is contained in:
parent
85d876e131
commit
d83f75b341
@ -58,7 +58,8 @@ document formatter defs
|
|||||||
definition formatter executableDefinition' : acc
|
definition formatter executableDefinition' : acc
|
||||||
executableDefinition (Full.TypeSystemDefinition typeSystemDefinition' _location) acc =
|
executableDefinition (Full.TypeSystemDefinition typeSystemDefinition' _location) acc =
|
||||||
typeSystemDefinition formatter typeSystemDefinition' : acc
|
typeSystemDefinition formatter typeSystemDefinition' : acc
|
||||||
executableDefinition _ acc = acc -- TODO: TypeSystemExtension missing.
|
executableDefinition (Full.TypeSystemExtension typeSystemExtension' _location) acc =
|
||||||
|
typeSystemExtension formatter typeSystemExtension' : acc
|
||||||
|
|
||||||
directiveLocation :: DirectiveLocation.DirectiveLocation -> Lazy.Text
|
directiveLocation :: DirectiveLocation.DirectiveLocation -> Lazy.Text
|
||||||
directiveLocation = Lazy.Text.pack . show
|
directiveLocation = Lazy.Text.pack . show
|
||||||
@ -68,28 +69,48 @@ withLineBreak formatter encodeDefinition
|
|||||||
| Pretty _ <- formatter = Lazy.Text.snoc encodeDefinition '\n'
|
| Pretty _ <- formatter = Lazy.Text.snoc encodeDefinition '\n'
|
||||||
| Minified <- formatter = encodeDefinition
|
| Minified <- formatter = encodeDefinition
|
||||||
|
|
||||||
|
typeSystemExtension :: Formatter -> Full.TypeSystemExtension -> Lazy.Text
|
||||||
|
typeSystemExtension formatter = \case
|
||||||
|
Full.SchemaExtension schemaExtension' ->
|
||||||
|
schemaExtension formatter schemaExtension'
|
||||||
|
Full.TypeExtension typeExtension' -> typeExtension formatter typeExtension'
|
||||||
|
|
||||||
|
schemaExtension :: Formatter -> Full.SchemaExtension -> Lazy.Text
|
||||||
|
schemaExtension formatter = \case
|
||||||
|
Full.SchemaOperationExtension operationDirectives operationTypeDefinitions' ->
|
||||||
|
withLineBreak formatter
|
||||||
|
$ "extend schema "
|
||||||
|
<> optempty (directives formatter) operationDirectives
|
||||||
|
<> bracesList formatter (operationTypeDefinition formatter) (NonEmpty.toList operationTypeDefinitions')
|
||||||
|
Full.SchemaDirectivesExtension operationDirectives -> "extend schema "
|
||||||
|
<> optempty (directives formatter) (NonEmpty.toList operationDirectives)
|
||||||
|
|
||||||
|
typeExtension :: Formatter -> Full.TypeExtension -> Lazy.Text
|
||||||
|
typeExtension = const $ const "" -- TODO: Type extensions missing.
|
||||||
|
|
||||||
-- | Converts a t'Full.TypeSystemDefinition' into a string.
|
-- | Converts a t'Full.TypeSystemDefinition' into a string.
|
||||||
typeSystemDefinition :: Formatter -> Full.TypeSystemDefinition -> Lazy.Text
|
typeSystemDefinition :: Formatter -> Full.TypeSystemDefinition -> Lazy.Text
|
||||||
typeSystemDefinition formatter = \case
|
typeSystemDefinition formatter = \case
|
||||||
Full.SchemaDefinition operationDirectives operationTypeDefinitions' ->
|
Full.SchemaDefinition operationDirectives operationTypeDefinitions' ->
|
||||||
withLineBreak formatter
|
withLineBreak formatter
|
||||||
$ optempty (directives formatter) operationDirectives
|
$ "schema "
|
||||||
<> "schema "
|
<> optempty (directives formatter) operationDirectives
|
||||||
<> bracesList formatter operationTypeDefinition (NonEmpty.toList operationTypeDefinitions')
|
<> bracesList formatter (operationTypeDefinition formatter) (NonEmpty.toList operationTypeDefinitions')
|
||||||
Full.TypeDefinition typeDefinition' -> typeDefinition formatter typeDefinition'
|
Full.TypeDefinition typeDefinition' -> typeDefinition formatter typeDefinition'
|
||||||
Full.DirectiveDefinition description' name' arguments' locations
|
Full.DirectiveDefinition description' name' arguments' locations
|
||||||
-> description formatter description'
|
-> description formatter description'
|
||||||
<> "@"
|
<> "@"
|
||||||
<> Lazy.Text.fromStrict name' -- TODO: TypeSystemExtension missing.
|
<> Lazy.Text.fromStrict name'
|
||||||
<> argumentsDefinition formatter arguments'
|
<> argumentsDefinition formatter arguments'
|
||||||
<> " on"
|
<> " on"
|
||||||
<> pipeList formatter (directiveLocation <$> locations)
|
<> pipeList formatter (directiveLocation <$> locations)
|
||||||
where
|
|
||||||
operationTypeDefinition (Full.OperationTypeDefinition operationType' namedType')
|
operationTypeDefinition :: Formatter -> Full.OperationTypeDefinition -> Lazy.Text.Text
|
||||||
= indentLine (incrementIndent formatter)
|
operationTypeDefinition formatter (Full.OperationTypeDefinition operationType' namedType')
|
||||||
<> operationType formatter operationType'
|
= indentLine (incrementIndent formatter)
|
||||||
<> colon formatter
|
<> operationType formatter operationType'
|
||||||
<> Lazy.Text.fromStrict namedType'
|
<> colon formatter
|
||||||
|
<> Lazy.Text.fromStrict namedType'
|
||||||
|
|
||||||
fieldDefinition :: Formatter -> Full.FieldDefinition -> Lazy.Text.Text
|
fieldDefinition :: Formatter -> Full.FieldDefinition -> Lazy.Text.Text
|
||||||
fieldDefinition formatter fieldDefinition' =
|
fieldDefinition formatter fieldDefinition' =
|
||||||
|
Loading…
Reference in New Issue
Block a user