public TibberService(
     HttpClient client,
     IGraphQLJsonSerializer graphQLJsonSerializer,
     IOptions <TibberOptions> options
     )
 {
     _client  = client;
     _options = options.Value;
     _graphQLHttpClientOptions = new GraphQLHttpClientOptions {
         EndPoint = new Uri(_options.BaseUrl)
     };
     _graphQLJsonSerializer = graphQLJsonSerializer;
 }
 public static GraphQLLocalExecutionClient <TSchema> New <TSchema>(TSchema schema, IGraphQLJsonSerializer serializer) where TSchema : ISchema
 => new GraphQLLocalExecutionClient <TSchema>(schema, serializer, new SubscriptionDocumentExecuter(), new DocumentWriter());
 public static GraphQLLocalExecutionClient <TSchema> New <TSchema>(TSchema schema, IGraphQLJsonSerializer serializer) where TSchema : ISchema
 => new GraphQLLocalExecutionClient <TSchema>(schema, serializer);
示例#4
0
        /// <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>
        /// <param name="serializer">the <see cref="IGraphQLJsonSerializer"/> passed from <see cref="GraphQLHttpClient"/></param>
        /// <returns></returns>
        public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions options, IGraphQLJsonSerializer serializer)
        {
            var message = new HttpRequestMessage(HttpMethod.Post, options.EndPoint)
            {
                Content = new StringContent(serializer.SerializeToString(this), Encoding.UTF8, options.MediaType)
            };

#pragma warning disable CS0618 // Type or member is obsolete
            PreprocessHttpRequestMessage(message);
#pragma warning restore CS0618 // Type or member is obsolete
            return(message);
        }