/// <summary> /// Creates a <see cref="HttpRequestMessage"/> from this <see cref="GraphQLHttpRequest"/>. /// Used by <see cref="GraphQLHttpClient"/> to convert GraphQL requests when sending them as regular HTTP requests. /// </summary> /// <param name="options">the <see cref="GraphQLHttpClientOptions"/> passed from <see cref="GraphQLHttpClient"/></param> /// <returns></returns> public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions options) { var message = new HttpRequestMessage(HttpMethod.Post, options.EndPoint) { Content = new StringContent(JsonConvert.SerializeObject( this, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json") }; message.Headers.Authorization = options.Authorization; return(message); }
public GraphQLHttpClient(GraphQLHttpClientOptions options, HttpClient httpClient) { Options = options ?? throw new ArgumentNullException(nameof(options)); HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); }
public GraphQLHttpClient(GraphQLHttpClientOptions options) : this(options, new HttpClient()) { }