Skip to content

Instantly share code, notes, and snippets.

View PascalSenn's full-sized avatar
🌶️

PascalSenn

🌶️
View GitHub Profile
if (argument.Type is IFilterInputType filterInput &&
context.Selection.Field.ContextData
.TryGetValue(ContextVisitFilterArgumentKey, out var executorObj) &&
executorObj is VisitFilterArgument executor)
{
var inMemory = IsInMemoryQuery<TEntityType>(input);
var visitorContext = executor(filter, filterInput, inMemory);
// compile expression tree
@PascalSenn
PascalSenn / data-next.cs
Created February 9, 2022 20:46
Data Next
public class Person
{
public string FirstName { get; }
public string LastName { get; }
}
[ExtendObjectType(typeof(Person))]
public class PersonExtension
{
@PascalSenn
PascalSenn / Program.cs
Last active August 26, 2021 10:57
Print Schema with Args
public class Program
{
public static async Task Main(string[] args)
{
IHost? host = CreateHostBuilder(args).Build();
if (args.Contains("--generate-schema"))
{
IRequestExecutor executor = await host.Services
.GetRequiredService<IRequestExecutorResolver>()
.GetRequestExecutorAsync();

FAQ

How to..

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

@PascalSenn
PascalSenn / MultipartRequestMiddleware
Last active April 7, 2024 20:27
MultiPartRquestMiddlware made with ❤️ by https://github.com/acelot
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
{
"before": ["<tab>"],
"commands": ["editor.action.indentLines"]
},
{
"before": ["<S-Tab>"],
"commands": ["editor.action.outdentLines"]
},
{
"before": [","],
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "shift+alt+q",
"command": "tslint.fixAllProblems"
},
{
"key": "shift+alt+u",
"command": "-extension.updateSettings"
},
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public abstract class DataLoaderAttribute : ObjectFieldDescriptorAttribute
{
public static MethodInfo ConfigureMethod = typeof(DataLoaderAttribute)
.GetMethod(nameof(DataLoaderAttribute.Configure));
public DataLoaderAttribute(Type dataloaderType)
{
DataloaderType = dataloaderType;
}
public Type DataloaderType { get; }
@PascalSenn
PascalSenn / auth-apollo-how-to.md
Last active March 31, 2023 12:20
Authentication Apollo Client - How To

The problem with authentication of web sockets is that you can only authenticate a http request once against a authentication scheme. After that the authentication is cached and will always yield the same result.

A web socket connection starts over HTTP. A HTTP request with the Upgrade header is send to the back end. This request is then "upgraded" into a web socket that runs over the web socket pipeline. The main issue with web sockets is that you cannot set additional headers with this initial HTTP header. Therefore the authentication will fail and the request will be unauthenticated. The HTTP context of the initial request will last as long as the web socket connection is running.

The trick we do is that we add a stub authentication scheme:

@PascalSenn
PascalSenn / .cs
Created March 12, 2020 20:57
Authentication Provider
services.AddAuthentication(options =>
{
options.DefaultScheme = "YOURSCHEMANAME";
options.DefaultAuthenticateScheme = "YOURSCHEMANAME";
})
.AddJwtBearer("Websockets", ctx => { })
.AddIdentityServerAuthentication("YOURSCHEMANAME", options =>
{
options.ForwardDefaultSelector = context =>
{