Validate input fields have unique names
This commit is contained in:
@ -236,7 +236,7 @@ data ConstValue
|
||||
-- | Key-value pair.
|
||||
--
|
||||
-- A list of 'ObjectField's represents a GraphQL object type.
|
||||
data ObjectField a = ObjectField Name a
|
||||
data ObjectField a = ObjectField Name a Location
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Variables
|
||||
|
@ -220,8 +220,8 @@ fromConstValue (ConstEnum x) = Enum x
|
||||
fromConstValue (ConstList x) = List $ fromConstValue <$> x
|
||||
fromConstValue (ConstObject x) = Object $ fromConstObjectField <$> x
|
||||
where
|
||||
fromConstObjectField (ObjectField key value') =
|
||||
ObjectField key $ fromConstValue value'
|
||||
fromConstObjectField (ObjectField key value' location) =
|
||||
ObjectField key (fromConstValue value') location
|
||||
|
||||
booleanValue :: Bool -> Lazy.Text
|
||||
booleanValue True = "true"
|
||||
@ -290,7 +290,7 @@ objectValue formatter = intercalate $ objectField formatter
|
||||
. fmap f
|
||||
|
||||
objectField :: Formatter -> ObjectField Value -> Lazy.Text
|
||||
objectField formatter (ObjectField name value') =
|
||||
objectField formatter (ObjectField name value' _) =
|
||||
Lazy.Text.fromStrict name <> colon formatter <> value formatter value'
|
||||
|
||||
-- | Converts a 'Type' a type into a string.
|
||||
|
@ -487,11 +487,12 @@ nullValue :: Parser Text
|
||||
nullValue = symbol "null" <?> "NullValue"
|
||||
|
||||
objectField :: Parser a -> Parser (ObjectField a)
|
||||
objectField valueParser = ObjectField
|
||||
<$> name
|
||||
<* colon
|
||||
<*> valueParser
|
||||
<?> "ObjectField"
|
||||
objectField valueParser = label "ObjectField" $ do
|
||||
location <- getLocation
|
||||
fieldName <- name
|
||||
colon
|
||||
fieldValue <- valueParser
|
||||
pure $ ObjectField fieldName fieldValue location
|
||||
|
||||
variableDefinitions :: Parser [VariableDefinition]
|
||||
variableDefinitions = listOptIn parens variableDefinition
|
||||
|
Reference in New Issue
Block a user