public async Task Invoke(HttpContext httpContext, IScopedServiceProviderResolver scopedServiceProviderResolver)
        {
            // If its not a ws or the path does not match ignore
            if (!httpContext.Request.Path.StartsWithSegments(_path) || !httpContext.WebSockets.IsWebSocketRequest)
            {
                await _next(httpContext);

                return;
            }

            var socket = await httpContext.WebSockets.AcceptWebSocketAsync("graphql-ws");

            if (!httpContext.WebSockets.WebSocketRequestedProtocols.Contains(socket.SubProtocol))
            {
                await socket.CloseAsync(
                    WebSocketCloseStatus.ProtocolError,
                    "Server only supports graphql-ws protocol",
                    httpContext.RequestAborted);

                return;
            }

            var serviceProvider = scopedServiceProviderResolver.GetProvider();

            using (var realTimeExecutionManager = new RealTimeExecutionManager(serviceProvider, _rootType))
            {
                await RunConnectionAsync(realTimeExecutionManager, socket, default);
            }
        }
Exemple #2
0
        public GraphqlInAppCacheService(
            CacheConfiguration cacheConfiguration,
            ICachePolicy cachePolicy,
            IScopedServiceProviderResolver serviceProviderResolver)
        {
            _cacheConfiguration = cacheConfiguration;
            _cachePolicy        = cachePolicy;

            switch (cacheConfiguration.ResponseCache)
            {
            case ResponseCacheType.Memory:
                _memoryCache = serviceProviderResolver.GetProvider().GetService <IMemoryCache>();
                break;

            case ResponseCacheType.Distributed:
                _distributedCache = serviceProviderResolver.GetProvider().GetService <IDistributedCache>();
                break;
            }
        }
 public GraphQlExecutor(ISchemaResolver schemaResolver, IScopedServiceProviderResolver scopedServiceProviderResolver)
 {
     _schemaResolver = schemaResolver;
     _scopedServiceProviderResolver = scopedServiceProviderResolver;
 }
 public GraphqlCreator(IScopedServiceProviderResolver serviceProviderResolver)
 {
     _serviceProvider = serviceProviderResolver.GetProvider();
 }