Skip to content

morpheus-graphql-0.17.0

Compare
Choose a tag to compare
@nalchevanidze nalchevanidze released this 25 Feb 20:41
f76f54e

Server

new features

  • (issue #543 & #558): GQLTypeOptions supports new option typeNameModifier.
    Before the schema failed if you wanted to use the same type for input and output, and the user had no control over the eventual GraphQL type name of the generated schema. Now with this option you can
    provide a function of type Bool -> String -> String that generates a custom GraphQL type name. The first argument is a Bool that is True if the type is an input, and False otherwise. The second
    argument is a String representing the initial, auto-generated GraphQL type name. The function returns the desired type name. thanks @nalchevanidze & @bradsherman

    e.g this schema will not fail. morpheus will generate types: Deity and InputDeity

    data Deity = Deity
    { name :: Text,
      age :: Int
    }
    deriving (Show, Generic)
    
    deityTypeNameModifier isInput original
      | isInput = "Input" ++ original
      | otherwise = original
    
    instance GQLType Deity where
      typeOptions _ opt = opt {typeNameModifier = deityTypeNameModifier}
    
    newtype DeityArgs = DeityArgs
      { input :: Deity
      }
      deriving (Show, Generic, GQLType)
    
    newtype Query (m :: * -> *) = Query
      { deity :: DeityArgs -> m Deity
      }
      deriving (Generic, GQLType)
  • exposed EncodeWrapper and DecodeWrapper type-classes.

Breaking Changes

  • Map k v is now represented as just [Pair k v]

  • GQLScalar was replaced with EncodeScalar and DecodeScalar type-classes.

  • Exclusive input objects: Sum types used as input types are represented as input objects, where only one field must have a value. Namespaced constructors (i.e., where referenced type name concatenated with union type name is equal to constructor name) are unpacked. Furthermore, empty constructors are represented as fields with the unit type.

    for example:

        data Device
          | DevicePC PC
          | Laptop { macAdress :: ID }
          | Smartphone

    this type will generate the following SDL:

    enum Unit {
      Unit
    }
    
    input Laptop {
      macAdress: ID
    }
    
    input Device {
      PC: PC
      Laptops: Laptop
      Smartphone: Unit
    }
  • For each nullary constructor will be defined GQL object type with a single field _: Unit (since GraphQL does not allow empty objects).

    for example:

    data Person = Client { name :: Text } | Accountant | Developer

    this type will generate the following SDL:

    enum Unit {
      Unit
    }
    
    type Student {
      name: String!
    }
    
    type Accountant {
      _: Unit!
    }
    
    type Developer {
      _: Unit!
    }
    
    union Person = Client | Accountant | Developer
  • changed signature of GQLType.typeOptions from f a -> GQLTypeOptions to f a -> GQLTypeOptions -> GQLTypeOptions.

    now you can write:

      typeOptions _ options = options { fieldLabelModifier = <my function> }

    whre argument options is default gql options.

  • deexposed constructor of GQLTypeOptions.

  • Type name for parametrized types like One (Two Three) will be generated directly, concatenating them OneTwoThree instead of One_Two_Three.

  • Haskell Float was renamed to custom scalar type Float32.

  • Haskell Double now represents GraphQL Float.

Minor Changes

  • deprecated kinds INPUT, ENUM and OUTPUT in favor of more generalized kind TYPE.
    now you can derive INPUT, ENUM and OUTPUT automatically with deriving (Generic, GQLType).
  • more likely to rebuild when a file loaded by importGQLDocument or
    importGQLDocumentWithNamespace is changed

Client

Breaking changes

  • GQLScalar was replaced with EncodeScalar and DecodeScalar type-classes.

Minor Changes

  • more likely to rebuild when a file loaded by defineByDocumentFile or
    defineByIntrospectionFile is changed

Core

New features

  • Data.Morpheus.Core provides default GrapHQL type definitions with internalSchema
  • exposed Data.Morpheus.Internal.Ext

Breaking changes

  • parseTypeSystemDefinition and parseGQLDocument is replaced with parseSchema

  • parseFullGQLDocument replaced with parseFullSchema

  • removed parseDSL from Data.Morpheus.Core

  • following Types and modules are migrated to the new package morpheus-graphql-app:

    • following types and functions in Data.Morpheus.Core are moved in to Data.Morpheus.App:
      App, AppData, runApp, withDebugger, mkApp, runAppStream
    • typeClass MapAPI migrated from Data.Morpheus.Types.IO is moved into Data.Morpheus.App
    • Data.Morpheus.Types.Internal.Resolving moved asData.Morpheus.App.Internal.Resolving
  • RootResModel was renamed to RootResolverValue

  • ResModel was replaced with more general ResolverValue

  • GQLScalar was replaced with EncodeScalar and DecodeScalar type-classes.

  • Value.Float is now Double instead of Float.