Print the definitions of the types that are conflicting

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6139
GitOrigin-RevId: 1ab0eecb0f75fb57534fd39add9bfde5041c090e
This commit is contained in:
Auke Booij 2022-10-03 23:12:00 +02:00 committed by hasura-bot
parent 3efabe99b3
commit 6602ad44b1
5 changed files with 33 additions and 1 deletions

View File

@ -1,3 +1,5 @@
{-# HLINT ignore "Use tshow" #-}
module Language.GraphQL.Draft.Printer where module Language.GraphQL.Draft.Printer where
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -106,6 +108,12 @@ instance Printer Text.Builder where
doubleP = Text.string . show doubleP = Text.string . show
{-# INLINE doubleP #-} {-# INLINE doubleP #-}
instance Printer T.Text where
textP = id
charP = T.singleton
intP = T.pack . show
doubleP = T.pack . show
type Print :: Type -> Constraint type Print :: Type -> Constraint
class Print a where class Print a where
printP :: Printer b => a -> b printP :: Printer b => a -> b

View File

@ -64,6 +64,8 @@ import GHC.Generics (Generic)
import Hasura.Base.ErrorMessage (toErrorMessage) import Hasura.Base.ErrorMessage (toErrorMessage)
import Hasura.Base.ToErrorValue import Hasura.Base.ToErrorValue
import Hasura.GraphQL.Parser.Names import Hasura.GraphQL.Parser.Names
import {-# SOURCE #-} Hasura.GraphQL.Parser.Schema.Convert
import Language.GraphQL.Draft.Printer qualified as G
import Language.GraphQL.Draft.Syntax import Language.GraphQL.Draft.Syntax
( Description (..), ( Description (..),
DirectiveLocation (..), DirectiveLocation (..),
@ -796,7 +798,7 @@ data ConflictingDefinitions origin
(SomeDefinitionTypeInfo origin, NonEmpty TypeOriginStack) (SomeDefinitionTypeInfo origin, NonEmpty TypeOriginStack)
instance ToErrorValue (ConflictingDefinitions origin) where instance ToErrorValue (ConflictingDefinitions origin) where
toErrorValue (ConflictingDefinitions (type1, origin1) (_type2, origins)) = toErrorValue (ConflictingDefinitions (type1, origin1) (type2, origins)) =
"Found conflicting definitions for " "Found conflicting definitions for "
<> toErrorValue (getName type1) <> toErrorValue (getName type1)
<> ". The definition at " <> ". The definition at "
@ -804,6 +806,10 @@ instance ToErrorValue (ConflictingDefinitions origin) where
<> " differs from the the definitions " <> " differs from the the definitions "
<> toErrorValue origins <> toErrorValue origins
<> "." <> "."
<> "\nFormer has definition:\n"
<> toErrorMessage (G.typeDefinitionP (bimap (const ()) id (convertType type1)))
<> "\nLatter has definition:\n"
<> toErrorMessage (G.typeDefinitionP (bimap (const ()) id (convertType type2)))
-- | Although the majority of graphql-engine is written in terms of abstract -- | Although the majority of graphql-engine is written in terms of abstract
-- mtl-style effect monads, we figured out that this particular codepath is -- mtl-style effect monads, we figured out that this particular codepath is

View File

@ -0,0 +1,8 @@
-- | Types for representing a GraphQL schema.
module Hasura.GraphQL.Parser.Schema
( -- * Kinds
SomeDefinitionTypeInfo,
)
where
data SomeDefinitionTypeInfo origin

View File

@ -2,6 +2,7 @@
-- intrsospection schema. -- intrsospection schema.
module Hasura.GraphQL.Parser.Schema.Convert module Hasura.GraphQL.Parser.Schema.Convert
( convertToSchemaIntrospection, ( convertToSchemaIntrospection,
convertType,
) )
where where

View File

@ -0,0 +1,9 @@
module Hasura.GraphQL.Parser.Schema.Convert
( convertType,
)
where
import {-# SOURCE #-} Hasura.GraphQL.Parser.Schema
import Language.GraphQL.Draft.Syntax qualified as G
convertType :: SomeDefinitionTypeInfo origin -> G.TypeDefinition [G.Name] G.InputValueDefinition