Ejemplo n.º 1
0
 public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer, HttpClient httpClient)
 {
     Options               = options ?? throw new ArgumentNullException(nameof(options));
     JsonSerializer        = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");
     HttpClient            = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _graphQlHttpWebSocket = new GraphQLHttpWebSocket(GetWebSocketUri(), this);
 }
 /// <summary>
 /// Initializes a new <see cref="GraphQLFunctionProcessor"/>
 /// </summary>
 /// <param name="loggerFactory">The service used to create <see cref="ILogger"/>s</param>
 /// <param name="context">The current <see cref="IWorkflowRuntimeContext"/></param>
 /// <param name="activityProcessorFactory">The service used to create <see cref="IWorkflowActivityProcessor"/>s</param>
 /// <param name="httpClientFactory">The service used to create <see cref="System.Net.Http.HttpClient"/>s</param>
 /// <param name="serializer">The service used to serialize and deserialize GraphQL requests/responses</param>
 /// <param name="oauth2TokenManager">The service used to manahge <see cref="OAuth2Token"/>s</param>
 /// <param name="options">The service used to access the current <see cref="ApplicationOptions"/></param>
 /// <param name="activity">The <see cref="V1WorkflowActivity"/> to process</param>
 /// <param name="action">The <see cref="ActionDefinition"/> to process</param>
 /// <param name="function">The <see cref="FunctionDefinition"/> to process</param>
 public GraphQLFunctionProcessor(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IWorkflowRuntimeContext context, IWorkflowActivityProcessorFactory activityProcessorFactory,
                                 IHttpClientFactory httpClientFactory, IGraphQLWebsocketJsonSerializer serializer, IOptions <ApplicationOptions> options, V1WorkflowActivity activity,
                                 ActionDefinition action, FunctionDefinition function)
     : base(serviceProvider, loggerFactory, context, activityProcessorFactory, options, activity, action, function)
 {
     this.HttpClient = httpClientFactory.CreateClient();
     this.Serializer = serializer;
 }
Ejemplo n.º 3
0
        public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer, HttpClient httpClient)
        {
            Options        = options ?? throw new ArgumentNullException(nameof(options));
            JsonSerializer = serializer ?? throw new ArgumentNullException(nameof(serializer), "please configure the JSON serializer you want to use");
            HttpClient     = httpClient ?? throw new ArgumentNullException(nameof(httpClient));

            if (!HttpClient.DefaultRequestHeaders.UserAgent.Any())
            {
                HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(GetType().Assembly.GetName().Name, GetType().Assembly.GetName().Version.ToString()));
            }

            _lazyHttpWebSocket = new Lazy <GraphQLHttpWebSocket>(() => new GraphQLHttpWebSocket(Options.EndPoint.GetWebSocketUri(), this));
        }
Ejemplo n.º 4
0
 public TestServerSetup(IGraphQLWebsocketJsonSerializer serializer)
 {
     Serializer = serializer;
     Port       = NetworkHelpers.GetFreeTcpPortNumber();
 }
Ejemplo n.º 5
0
 public static GraphQLHttpClient GetGraphQLClient(int port, string endpoint, bool requestsViaWebsocket = false, IGraphQLWebsocketJsonSerializer serializer = null)
 => new GraphQLHttpClient(new GraphQLHttpClientOptions
 {
     EndPoint = new Uri($"http://localhost:{port}{endpoint}"),
     UseWebSocketForQueriesAndMutations = requestsViaWebsocket
 },
                          serializer ?? new NewtonsoftJsonSerializer());
Ejemplo n.º 6
0
 public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer) : this(options, serializer, new HttpClient(options.HttpMessageHandler))
 {
 }
Ejemplo n.º 7
0
 public GraphQLHttpClient(Action <GraphQLHttpClientOptions> configure, IGraphQLWebsocketJsonSerializer serializer) : this(configure.New(), serializer)
 {
 }
Ejemplo n.º 8
0
 public GraphQLHttpClient(Uri endPoint, IGraphQLWebsocketJsonSerializer serializer) : this(o => o.EndPoint = endPoint, serializer)
 {
 }
Ejemplo n.º 9
0
 public GraphQLHttpClient(string endPoint, IGraphQLWebsocketJsonSerializer serializer) : this(new Uri(endPoint), serializer)
 {
 }
Ejemplo n.º 10
0
 protected Base(IGraphQLWebsocketJsonSerializer serializer)
 {
     this.serializer = serializer;
 }
Ejemplo n.º 11
0
 public GraphQLHttpClient(GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer) : this(
         options, serializer, new HttpClient(options.HttpMessageHandler))
 {
     // set this flag to dispose the internally created HttpClient when GraphQLHttpClient gets disposed
     _disposeHttpClient = true;
 }
Ejemplo n.º 12
0
 public GraphQLHttpClient(GraphQLHttpClientOptions options, HttpClient httpClient, IGraphQLWebsocketJsonSerializer serializer)
 {
     Options = options ?? throw new ArgumentNullException(nameof(options));
     Options.JsonSerializer    = serializer ?? throw new ArgumentNullException(nameof(serializer));
     this.HttpClient           = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     this.graphQlHttpWebSocket = new GraphQLHttpWebSocket(GetWebSocketUri(), this);
 }
Ejemplo n.º 13
0
        public static TestServerSetup SetupTest <TStartup>(bool requestsViaWebsocket = false, IGraphQLWebsocketJsonSerializer serializer = null)
            where TStartup : class
        {
            var port = NetworkHelpers.GetFreeTcpPortNumber();

            return(new TestServerSetup {
                Server = CreateServer <TStartup>(port),
                Client = GetGraphQLClient(port, requestsViaWebsocket, serializer)
            });
        }
Ejemplo n.º 14
0
 protected BaseSerializerTest(IGraphQLWebsocketJsonSerializer serializer)
 {
     Serializer     = serializer;
     ChatClient     = GraphQLLocalExecutionClient.New(Common.GetChatSchema(), serializer);
     StarWarsClient = GraphQLLocalExecutionClient.New(Common.GetStarWarsSchema(), serializer);
 }
Ejemplo n.º 15
0
 protected Base(ITestOutputHelper output, IGraphQLWebsocketJsonSerializer serializer)
 {
     this.Output     = output;
     this.Serializer = serializer;
 }