mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
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:
parent
3efabe99b3
commit
6602ad44b1
@ -1,3 +1,5 @@
|
||||
{-# HLINT ignore "Use tshow" #-}
|
||||
|
||||
module Language.GraphQL.Draft.Printer where
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@ -106,6 +108,12 @@ instance Printer Text.Builder where
|
||||
doubleP = Text.string . show
|
||||
{-# INLINE doubleP #-}
|
||||
|
||||
instance Printer T.Text where
|
||||
textP = id
|
||||
charP = T.singleton
|
||||
intP = T.pack . show
|
||||
doubleP = T.pack . show
|
||||
|
||||
type Print :: Type -> Constraint
|
||||
class Print a where
|
||||
printP :: Printer b => a -> b
|
||||
|
@ -64,6 +64,8 @@ import GHC.Generics (Generic)
|
||||
import Hasura.Base.ErrorMessage (toErrorMessage)
|
||||
import Hasura.Base.ToErrorValue
|
||||
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
|
||||
( Description (..),
|
||||
DirectiveLocation (..),
|
||||
@ -796,7 +798,7 @@ data ConflictingDefinitions origin
|
||||
(SomeDefinitionTypeInfo origin, NonEmpty TypeOriginStack)
|
||||
|
||||
instance ToErrorValue (ConflictingDefinitions origin) where
|
||||
toErrorValue (ConflictingDefinitions (type1, origin1) (_type2, origins)) =
|
||||
toErrorValue (ConflictingDefinitions (type1, origin1) (type2, origins)) =
|
||||
"Found conflicting definitions for "
|
||||
<> toErrorValue (getName type1)
|
||||
<> ". The definition at "
|
||||
@ -804,6 +806,10 @@ instance ToErrorValue (ConflictingDefinitions origin) where
|
||||
<> " differs from the the definitions "
|
||||
<> 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
|
||||
-- mtl-style effect monads, we figured out that this particular codepath is
|
||||
|
@ -0,0 +1,8 @@
|
||||
-- | Types for representing a GraphQL schema.
|
||||
module Hasura.GraphQL.Parser.Schema
|
||||
( -- * Kinds
|
||||
SomeDefinitionTypeInfo,
|
||||
)
|
||||
where
|
||||
|
||||
data SomeDefinitionTypeInfo origin
|
@ -2,6 +2,7 @@
|
||||
-- intrsospection schema.
|
||||
module Hasura.GraphQL.Parser.Schema.Convert
|
||||
( convertToSchemaIntrospection,
|
||||
convertType,
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user