This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Use IntelliSense to find out which attributes exist for C# debugging | |
// Use hover for the description of the existing attributes | |
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Uno Platform Mobile Debug", | |
"type": "Uno", | |
"request": "launch", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let GrupoMutationsType = | |
Define.Object<GrupoArgs> | |
(name = "GrupoMutations", description = "Group mutations", | |
fields = | |
[ Define.PatchesField("patch", PatchCacheKey, | |
// Attach policy / Цепляем политику | |
GrupoPatchMutations).WithAuthorizationPolicies<GrupoPatchViewModel> (Policies.GroupAdmin) | |
(Define.AsyncUnitResultField | |
("addAdmin", "Add group admin (any admin can do)", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type WebJobsHttpExtensionStartup () = | |
interface IWebJobsStartup with | |
member __.Configure (builder : IWebJobsBuilder) = | |
builder.Services | |
.AddScoped<Lazy<Result<GraphQLUser, Errors.ErrorMessage>>>( | |
fun provider -> Control.Lazy.Create(fun () -> WebJobsHttpExtensionStartup.GetUserIdResultFromClaims provider)) | |
.AddAuthorizationWithReflection (fun options -> | |
options.AddPolicy(Policies.EditBooks, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AllowedGroupRequierment (groups : string seq) = | |
member val Groups = groups.ToImmutableHashSet () | |
interface IAuthorizationRequirement | |
type AllowedGroupHandler (graphService : IMicrosoftGraphService, userIdResult : Lazy<Result<GraphQLUser, Errors.ErrorMessage>>) = | |
inherit AuthorizationHandler<AllowedGroupRequierment> () | |
override _.HandleRequirementAsync (context, requirement) = task { | |
match userIdResult.Value with | |
| Result.Error _ -> return () // user not authenticated / пользователь не аутентифицирован |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let handleRequest (serviceProvider : IServiceProvider) (requestBodyStream : Stream) = async { | |
... | |
try | |
... | |
let! result = | |
match request with | |
| ValueSome (query, ValueSome variables) -> | |
async { | |
let query = removeWhitespacesAndLineBreaks query | |
let root = serviceProvider.GetRequiredService<Root>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// F# | |
type public GraphQLFunction (serviceProvider : IServiceProvider, log : ILogger<GraphQLFunction>) = | |
[<FunctionName "GraphQL">] | |
member public __.Execute | |
([<HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = null)>] req : HttpRequest, | |
cancellationToken : CancellationToken) = Async.StartAsTask (async { | |
let! responseData = GraphQL.handleRequest serviceProvider req.Body | |
let responseBody = GraphQLFunction.GetBody log responseData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 или ошибку по полю |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation grupo ($id: GrupoID! | |
$addAdminCommand: AddAdminCommand! | |
$name: GrupoName! | |
$description: String | |
$imageURL: GrupoImageURL! | |
$removeAdminCommand: RemoveAdminCommand!) { | |
grupo (id: $id) { | |
addAdmin (addAdminCommand: $addAdminCommand) // in parallel / параллельно |
NewerOlder