Parse interfaces implementing interfaces
All checks were successful
Build / audit (push) Successful in 18s
Build / test (push) Successful in 6m30s
Build / doc (push) Successful in 5m36s

This commit is contained in:
Eugen Wissner 2024-11-05 19:44:45 +01:00
parent 6f7bb10a62
commit 97627ffc36
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
6 changed files with 14 additions and 9 deletions

View File

@ -482,12 +482,9 @@ instance Monoid Description
data TypeDefinition data TypeDefinition
= ScalarTypeDefinition Description Name [Directive] = ScalarTypeDefinition Description Name [Directive]
| ObjectTypeDefinition | ObjectTypeDefinition
Description Description Name (ImplementsInterfaces []) [Directive] [FieldDefinition]
Name | InterfaceTypeDefinition
(ImplementsInterfaces []) Description Name (ImplementsInterfaces []) [Directive] [FieldDefinition]
[Directive]
[FieldDefinition]
| InterfaceTypeDefinition Description Name [Directive] [FieldDefinition]
| UnionTypeDefinition Description Name [Directive] (UnionMemberTypes []) | UnionTypeDefinition Description Name [Directive] (UnionMemberTypes [])
| EnumTypeDefinition Description Name [Directive] [EnumValueDefinition] | EnumTypeDefinition Description Name [Directive] [EnumValueDefinition]
| InputObjectTypeDefinition | InputObjectTypeDefinition

View File

@ -226,10 +226,11 @@ typeDefinition formatter = \case
<> optempty (directives formatter) directives' <> optempty (directives formatter) directives'
<> eitherFormat formatter " " "" <> eitherFormat formatter " " ""
<> bracesList formatter (fieldDefinition nextFormatter) fields' <> bracesList formatter (fieldDefinition nextFormatter) fields'
Full.InterfaceTypeDefinition description' name' directives' fields' Full.InterfaceTypeDefinition description' name' ifaces' directives' fields'
-> optempty (description formatter) description' -> optempty (description formatter) description'
<> "interface " <> "interface "
<> Lazy.Text.fromStrict name' <> Lazy.Text.fromStrict name'
<> optempty (" " <>) (implementsInterfaces ifaces')
<> optempty (directives formatter) directives' <> optempty (directives formatter) directives'
<> eitherFormat formatter " " "" <> eitherFormat formatter " " ""
<> bracesList formatter (fieldDefinition nextFormatter) fields' <> bracesList formatter (fieldDefinition nextFormatter) fields'

View File

@ -214,6 +214,7 @@ interfaceTypeDefinition :: Full.Description -> Parser Full.TypeDefinition
interfaceTypeDefinition description' = Full.InterfaceTypeDefinition description' interfaceTypeDefinition description' = Full.InterfaceTypeDefinition description'
<$ symbol "interface" <$ symbol "interface"
<*> name <*> name
<*> option (Full.ImplementsInterfaces []) (implementsInterfaces sepBy1)
<*> directives <*> directives
<*> braces (many fieldDefinition) <*> braces (many fieldDefinition)
<?> "InterfaceTypeDefinition" <?> "InterfaceTypeDefinition"

View File

@ -210,7 +210,7 @@ typeDefinition context rule = \case
Full.ObjectTypeDefinition _ _ _ directives' fields Full.ObjectTypeDefinition _ _ _ directives' fields
-> directives context rule objectLocation directives' -> directives context rule objectLocation directives'
>< foldMap (fieldDefinition context rule) fields >< foldMap (fieldDefinition context rule) fields
Full.InterfaceTypeDefinition _ _ directives' fields Full.InterfaceTypeDefinition _ _ _ directives' fields
-> directives context rule interfaceLocation directives' -> directives context rule interfaceLocation directives'
>< foldMap (fieldDefinition context rule) fields >< foldMap (fieldDefinition context rule) fields
Full.UnionTypeDefinition _ _ directives' _ -> Full.UnionTypeDefinition _ _ directives' _ ->

View File

@ -181,7 +181,7 @@ spec = do
argument = Full.InputValueDefinition mempty "arg" someType Nothing mempty argument = Full.InputValueDefinition mempty "arg" someType Nothing mempty
arguments = Full.ArgumentsDefinition [argument] arguments = Full.ArgumentsDefinition [argument]
definition' = Full.TypeDefinition definition' = Full.TypeDefinition
$ Full.InterfaceTypeDefinition mempty "UUID" mempty $ Full.InterfaceTypeDefinition mempty "UUID" (Full.ImplementsInterfaces []) mempty
$ pure $ pure
$ Full.FieldDefinition mempty "value" arguments someType mempty $ Full.FieldDefinition mempty "value" arguments someType mempty
expected = "interface UUID {\n\ expected = "interface UUID {\n\

View File

@ -103,6 +103,12 @@ spec = describe "Parser" $ do
\ name: String\n\ \ name: String\n\
\}" \}"
it "parses ImplementsInterfaces on interfaces" $
parse document "" `shouldSucceedOn`
"interface Person implements NamedEntity & ValuedEntity {\n\
\ name: String\n\
\}"
it "parses minimal enum type definition" $ it "parses minimal enum type definition" $
parse document "" `shouldSucceedOn` parse document "" `shouldSucceedOn`
"enum Direction {\n\ "enum Direction {\n\