haskell-graphql / graphql-api

Write type-safe GraphQL services in Haskell
BSD 3-Clause "New" or "Revised" License
406 stars 35 forks source link

Do the warnings 'No explicit implementation for ToValue' cause errors elsewhere #202

Open EdmundsEcho opened 6 years ago

EdmundsEcho commented 6 years ago

When deriving ToValue instances I get a warning No explicit implementation for 'toValue'. For instance,

data MixInput = MixInput
  { nameKey  :: Maybe Text
  , mixItems  :: ![MixItemInput]  -- an instance of ToValue
  } deriving (Show, Generic)

instance FromValue              MixInput
instance ToValue                MixInput    <<< Warning -> generates an error when evaluated
instance HasAnnotatedInputType  MixInput
instance Defaultable            MixInput

Update

In my experience, the App compiles, but generates a runtime error when the toValue instance is evaluated.

So for instance, the following compiles And avoids any runtime errors.

instance ToValue MixInput where
  toValue MixInput {..}
    = toValue $ fromJust $ objectFromList
      [ ("nameKey",  toValue (toValue @Text <$> nameKey))
      , ("mixItems", toValue (toValue @MixItemInput <$> mixItems))
      ]

instance ToValue MixItemInput where
  etc..

Question Is this behavior/feedback by design?

- E