Skip to content

Instantly share code, notes, and snippets.

@xperiandri
Last active February 13, 2022 22:12
Show Gist options
  • Save xperiandri/21179307ac67cd1a1348ac2c8548a1c6 to your computer and use it in GitHub Desktop.
Save xperiandri/21179307ac67cd1a1348ac2c8548a1c6 to your computer and use it in GitHub Desktop.
type Reaction = enum Reaction
{
| Undefined = 0 Undefined = 0,
| Cool = 1 Cool = 1,
| LoveIt = 2 LoveIt = 2,
| Boring = 3 Boring = 3,
| Gripping = 4 Gripping = 4,
| Sad = 5 Sad = 5,
| Inspiring = 6 Inspiring = 6
}
// static var ReactionEnumType = Define.Enum<Reaction>(...)
let ReactionEnumType =
Define.Enum<Reaction>
(name = "ReactionEnum", description = "Reacton onto the book",
options =
[ Define.EnumValue ("Cool" , Reaction.Cool , "The book is cool")
Define.EnumValue ("LoveIt" , Reaction.LoveIt , "The user loves the book")
Define.EnumValue ("Boring" , Reaction.Boring , "The book is boring")
Define.EnumValue ("Inspiring", Reaction.Inspiring, "The book is inspiring")
Define.EnumValue ("Sad" , Reaction.Sad , "The book is sad")
Define.EnumValue ("Gripping" , Reaction.Gripping , "The book is gripping") ] )
/// Recenzo is a review
type Recenzo = record Recenzo
{ [<JsonPropertyName("id")>] {
Id : RecenzoId public Guid Id { get; }
/// Reviewer Id
Recenzorer : UzantoId public Guid Recenzorer { get; }
Content : RecenzoContent public RecenzoContent Content { get; }
Timestamp : DateTime public DateTime Timetamp { get; }
/// Book Id
Registri : RegistriId } public Guid Registri { get; }
/// An Id of a review }
and RecenzoId = DomainId<Recenzo>
// static var ReactionEnumType = Define.Object<Recenzo>(...)
let RecenzoType =
Define.Object<Recenzo>
(name = "Recenzo", description = "A book review",
isTypeOf = (fun o -> o :? Recenzo),
fieldsFn = fun () ->
[ Define.Field ("id" , RecenzoIdType , "Book review identifier", (fun _ r -> r.Id ))
Define.Field ("recenzorerId", UzantoIdType , "Reviewer identifier" , (fun _ r -> r.Recenzorer))
Define.Field ("timestamp" , Date , "Change date and time" , (fun _ r -> r.Timestamp ))
Define.Field ("content" , RecenzoContentType, "Content" , (fun _ r -> r.Content ))
Define.AsyncField (
name = "recenzorer",
type = UzantoType,
description = "Reviewer",
resolver = (fun (ctx : ResolveFieldContext) (r : Recenzo) -> asyncGetUzanto ctx r.Recenzorer)) ])
// (ctx, r) => GetUzantoAsync(ctx, r.Recenzorer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment