diff --git a/server/lib/graphql-parser-hs/src/Language/GraphQL/Draft/Printer.hs b/server/lib/graphql-parser-hs/src/Language/GraphQL/Draft/Printer.hs index d9005743c69..633891436ab 100644 --- a/server/lib/graphql-parser-hs/src/Language/GraphQL/Draft/Printer.hs +++ b/server/lib/graphql-parser-hs/src/Language/GraphQL/Draft/Printer.hs @@ -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 diff --git a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs index ec46074f246..266ec74b520 100644 --- a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs +++ b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs @@ -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 diff --git a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs-boot b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs-boot new file mode 100644 index 00000000000..ffca1dbf19a --- /dev/null +++ b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema.hs-boot @@ -0,0 +1,8 @@ +-- | Types for representing a GraphQL schema. +module Hasura.GraphQL.Parser.Schema + ( -- * Kinds + SomeDefinitionTypeInfo, + ) +where + +data SomeDefinitionTypeInfo origin diff --git a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs index d98b93f649d..1834ca5d7e9 100644 --- a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs +++ b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs @@ -2,6 +2,7 @@ -- intrsospection schema. module Hasura.GraphQL.Parser.Schema.Convert ( convertToSchemaIntrospection, + convertType, ) where diff --git a/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs-boot b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs-boot new file mode 100644 index 00000000000..34b3528de90 --- /dev/null +++ b/server/lib/schema-parsers/src/Hasura/GraphQL/Parser/Schema/Convert.hs-boot @@ -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