/// <inheritdoc /> public IGraphQLQuery <T> CreateQuery <T>(string url, HttpMethod httpMethod, string authorizationToken = null, string authorizationMethod = "Bearer", params GraphQLQueryArgument[] arguments) where T : class { var selectionSet = FieldBuilder.GenerateSelectionSet(typeof(T)); return(GetGraphQLQuery <T>(GraphQLOperationType.Query, selectionSet, arguments, url, httpMethod, null, null, authorizationToken, authorizationMethod)); }
/// <inheritdoc /> public Task <T> Execute <T>(GraphQLOperationType operationType, string url = null, HttpMethod httpMethod = null, IDictionary <string, string> headers = null, Expression <Func <T, T> > filter = null, string authorizationToken = null, string authorizationMethod = "Bearer", CancellationToken cancellationToken = default, params GraphQLQueryArgument[] arguments) where T : class { // Generate selectionSet var selectionSet = FieldBuilder.GenerateSelectionSet(typeof(T)); // Execute return(Execute <T>(operationType, selectionSet, arguments, url: url, httpMethod: httpMethod, headers: headers, filter: filter, authorizationMethod: authorizationMethod, authorizationToken: authorizationToken, cancellationToken: cancellationToken)); }
/// <inheritdoc /> public async Task <IGraphQLSubscriptionOperation <T> > ExecuteOperation <T>(params GraphQLQueryArgument[] arguments) where T : class { if (!IsConnected) { throw new InvalidOperationException("Websocket is not connected"); } if (!IsInitilized) { throw new InvalidOperationException("GraphQLSubscriptionClient is not initilized"); } // Get operationId long operationId; lock (_locker) { operationId = _operationCounter++; } // Get query var selectionSet = FieldBuilder.GenerateSelectionSet(typeof(T)); var query = QueryGenerator.GenerateQuery(GraphQLOperationType.Subscription, selectionSet, arguments); // Generate OperationMessage for starting the operation var message = new OperationMessage { Id = operationId.ToString(), Type = MessageType.GQL_START, Payload = JsonConvert.DeserializeObject(query) }; // Generate stop message var stopMessage = new OperationMessage { Id = operationId.ToString(), Type = MessageType.GQL_STOP }; // Create GraphQLOperationSource var operationSource = new GraphQLOperationSource(() => { // Generate stop return(SendOperationMessage(stopMessage)); }); // Create IGraphQLSubscriptionOperation var subscription = new GraphQLSubscriptionOperation <T>(operationSource, selectionSet, Deserialization); // Add to list _operations.Add(operationId.ToString(), operationSource); // Send subscribe message await SendOperationMessage(message).ConfigureAwait(false); // Return the subscription return(subscription); }
/// <inheritdoc /> public IGraphQLQuery <T> CreateMutation <T>(string url, HttpMethod httpMethod, Expression <Func <T, T> > filter, string authorizationToken = null, string authorizationMethod = "Bearer", params GraphQLQueryArgument[] arguments) where T : class { var selectionSet = FieldBuilder.GenerateSelectionSet(typeof(T)); return(GetGraphQLQuery <T>(GraphQLOperationType.Mutation, selectionSet, arguments, url, httpMethod, null, GetQueryFilter(filter), authorizationToken, authorizationMethod)); }