Skip to content

Instantly share code, notes, and snippets.

View xperiandri's full-sized avatar

Andrii Chebukin xperiandri

View GitHub Profile
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
type Root (serviceProvider : IServiceProvider,
user : Lazy<Result<GraphQLUser, ErrorMessage>>,
facebookService : Lazy<Result<IFacebookService, ErrorMessage>>,
securityOptions : IOptions<SecurityOptions>) =
let securityOptions = securityOptions.Value
member val RequestId = System.Guid.NewGuid () with get
// static var Query = Define.Object<Root>(...)
let Query =
Define.Object<Root>
(name = "Query",
fields = [ Define.AsyncField (
name = "grupoj",
type = ListOf GrupoType,
resolver = asyncGetRecenzoj) ])
// static var Mutation = Define.Object<Root>(...)
let Mutation =
Define.Object<Root> (
...
fields = [ Define.AsyncField (
...
inputs = [ Define.Input ("command", SetCommentInputType) ],
...) ])
let InputRegistriCultureType =
Define.InputObject<RegistriCulture>
(name = "InputCulture",
fields =
[ Define.Input ("kind" , String , description = "A kind of book culture: native or translated")
Define.Input ("culture", CultureInfoType, description = "A culture code of a book") ])
// C#
// Define.Input (name: "kind", type: String, defaultValue: null, description: "A kind of book culture: native or translated")
let asyncGetGrupo (ctx : ResolveFieldContext) _ = asyncResult {
let container = ctx.Root.BibliotekoDatabase.GrupojContainer
let! grupoId = ctx.ArgId
return! asyncGetGrupo container grupoId |> AsyncResult.mapError ErrorMappings.mapGrupoError
}
public Task<Grupo> GetGrupoAsync(ResolveFieldContext: ctx, Root: _)
{
var cointainer = ctx.Root.BibliotekoDatabase.GrupojContainer;
mutation grupo ($id: GrupoID!, $addAdminCommand: AddAdminCommand!, $description: String, $imageURL: GrupoImageURL!, $name: GrupoName!, $removeAdminCommand: RemoveAdminCommand!) {
grupo_addAdmin (id: $id, addAdminCommand: $addAdminCommand)
grupo_delete (id: $id)
grupo_join (id: $id)
grupo_leave (id: $id)
grupo_patch (id: $id) {
description (description: $description)
imageURL (imageURL: $imageURL)
name (name: $name)
mutation grupo ($id: GrupoID!
$addAdminCommand: AddAdminCommand!
$name: GrupoName!
$description: String
$imageURL: GrupoImageURL!
$removeAdminCommand: RemoveAdminCommand!) {
grupo (id: $id) {
addAdmin (addAdminCommand: $addAdminCommand) // in parallel / параллельно
mutation grupo ($id: GrupoID!
$name: GrupoName!
$description: String
$imageURL: GrupoImageURL!) {
grupo (id: $id) {
// Intercept AST and handle its processing / Перехватываем AST и обрабаываем сами
patch {
description (description: $description) // return null or error for field / возвращаем null или ошибку по полю
mutation grupo ($id: GrupoID!, $patchOperations: [JsonPatchOperation!]) {
grupo (id: $id) {
patch (operations: $patchOperations)
}
}
let JSONPatchOperationInputType<'t when 't : not struct> =
let name = sprintf "Input%s_JSON_PatchOperation" (typeof<'t>.Name.Replace ("ViewModel", System.String.Empty))
Define.InputObject<Operation<'t>>