private static async Task <Customer> SimpleGraphQLClientDemo() { var customerRequest = new GraphQLRequest { Query = @"query Sample($customerId :Int, $portfolioId: Int, $present: Boolean!) { customer:customer(id:$customerId) { id @include(if: $present) address ...custFragment } } fragment custFragment on CustomerType { name portfolio(id:$portfolioId) { name id } }", Variables = new { portfolioId = 1, customerId = 2, present = false } }; var graphQLClient = new GraphQL.Client.GraphQLClient(GraphQlServerUrl); var graphQLResponse = await graphQLClient.PostAsync(customerRequest); var customer = graphQLResponse.GetDataFieldAs <Customer>("customer"); return(customer); }
private static async Task <Customer> SimpleMutationClientDemo() { var customerRequest = new GraphQLRequest { Query = @"mutation ($customer:CustomerInput!) { createCustomer(customer: $customer) { id name city } }", Variables = new { customer = new { name = "me", address = "1234 anywhere", city = "buffalo grove" } } }; var graphQLClient = new GraphQL.Client.GraphQLClient(GraphQlServerUrl); var graphQLResponse = await graphQLClient.PostAsync(customerRequest); var customer = graphQLResponse.GetDataFieldAs <Customer>("createCustomer"); return(customer); }
/// <summary> /// initialization used in the constructor /// </summary> private void Init() { string Full = EndPointS; Uri endPoint = new Uri(Full); var options = new GraphQL.Client.GraphQLClientOptions(); options.EndPoint = endPoint; this.GraphQLClient = new GraphQL.Client.GraphQLClient(options); }
public string EfetuarLogin(Login login) { var request = new GraphQLRequest(); request.Query = @"mutation ($email:String!,$password:String!){ login(input: { email: $email, password: $password }) { user { apiKey } } }"; request.Variables = new { email = login.Email, password = login.Password }; var graphQLClient = new GraphQL.Client.GraphQLClient("https://staging.loggi.com/graphql"); // graphQLClient.DefaultRequestHeaders.Add("Content-Type", "application/json"); graphQLClient.DefaultRequestHeaders.Add("Authorization", "ApiKey email:api_key"); var response = graphQLClient.PostAsync(request).GetAwaiter().GetResult(); IList <string> mensagemError = new List <string>(); if (response.Errors?.Count() > 0) { foreach (var error in response.Errors) { mensagemError.Add(error.Message); } return(mensagemError.Select(_ => _).FirstOrDefault()); } var apiKey = response.Data["login"]["user"]["apiKey"]; if (apiKey == null) { return("Syntax Error GraphQL"); } return(apiKey); }
static void Main(string[] args) { //var xclient = new HttpClientHandler(); //xclient.Properties.Add("x-api-key", "da2-bm2qqpx5ljhyhdqhv6nzsps7eu"); //xclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("x-api-key", "da2-bm2qqpx5ljhyhdqhv6nzsps7eu"); var client = new GraphQL.Client.GraphQLClient(new GraphQL.Client.GraphQLClientOptions() { EndPoint = new Uri("https://fo77ruxnqrh5tkml5oivdm4tvm.appsync-api.us-east-1.amazonaws.com/graphql"), }); client.DefaultRequestHeaders.Add("x-api-key", "da2-bm2qqpx5ljhyhdqhv6nzsps7eu"); var response = client.GetQueryAsync("{\"query\" : \" { allCruisesQuote { provider} }\"}").Result; Console.WriteLine(response); }
public override void Login(string Username, string Password, string otp) { try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL }; //RequireCaptcha(Captchaval); GQLClient = new GraphQL.Client.GraphQLClient(URL); /*GraphQLRequest LoginReq = new GraphQLRequest * { * Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}" * }; * * GQLClient * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result; * if (Resp.Errors != null) * { * if (Resp.Errors.Length > 0) * { * Parent.DumpLog(Resp.Errors[0].Message, -1); * Parent.updateStatus(Resp.Errors[0].Message); * finishedlogin(false); * return; * } * } * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/ GQLClient.DefaultRequestHeaders.Add("x-access-token", Password); /* * var subscriptionResult = GQLClient.SendSubscribeAsync(@"subscription { chatMessages(chatId: "14939265 - 52a4 - 404e-8a0c - 6e3e10d915b4") { id chat { id name isPublic } createdAt user { id name roles { name } } data { ... on ChatMessageDataBot { message } ... on ChatMessageDataText { message } ... on ChatMessageDataTip { tip { id amount currency sender: sendBy { id name } receiver: user { id name } } } } } } ").Result; * subscriptionResult.OnReceive += (res) => { Console.WriteLine(res.Data.messageAdded.content); }; */ GraphQLRequest LoginReq = new GraphQLRequest { Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}" }; GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result; pdUser user = Resp.GetDataFieldAs <pdUser>("user"); userid = user.id; if (string.IsNullOrWhiteSpace(userid)) { finishedlogin(false); } else { foreach (Statistic x in user.statistic) { if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName) { this.bets = (int)x.bets; this.wins = (int)x.wins; this.losses = (int)x.losses; this.profit = (decimal)x.profit; this.wagered = (decimal)x.betAmount; break; } } foreach (Balance x in user.balances) { if (x.available.currency.ToLower() == Currency.ToLower()) { balance = (decimal)x.available.amount; break; } } finishedlogin(true); ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); return; } } catch (WebException e) { if (e.Response != null) { } finishedlogin(false); } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); finishedlogin(false); } }
public override void Login(string Username, string Password, string otp) { try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL }; //RequireCaptcha(Captchaval); GQLClient = new GraphQL.Client.GraphQLClient(URL); /*GraphQLRequest LoginReq = new GraphQLRequest * { * Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}" * }; * * GQLClient * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result; * if (Resp.Errors != null) * { * if (Resp.Errors.Length > 0) * { * Parent.DumpLog(Resp.Errors[0].Message, -1); * Parent.updateStatus(Resp.Errors[0].Message); * finishedlogin(false); * return; * } * } * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/ GQLClient.DefaultRequestHeaders.Add("x-access-token", Password); GraphQLRequest LoginReq = new GraphQLRequest { Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {bets wins losses amount profit currency}}}" }; GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result; pdUser user = Resp.GetDataFieldAs <pdUser>("user"); userid = user.id; if (string.IsNullOrWhiteSpace(userid)) { finishedlogin(false); } else { foreach (Statistic x in user.statistic) { if (x.currency.ToLower() == Currency.ToLower()) { this.bets = (int)x.bets; this.wins = (int)x.wins; this.losses = (int)x.losses; this.profit = (decimal)x.profit; this.wagered = (decimal)x.amount; break; } } foreach (Balance x in user.balances) { if (x.available.currency.ToLower() == Currency.ToLower()) { balance = (decimal)x.available.amount; break; } } finishedlogin(true); ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); return; } } catch (WebException e) { if (e.Response != null) { } finishedlogin(false); } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); finishedlogin(false); } }
public OwnerConsumer(GraphQL.Client.GraphQLClient client) { _client = client; }
public override void Login(string Username, string Password, string otp) { try { GQLClient = new GraphQL.Client.GraphQLClient(URL); GraphQLRequest LoginReq = new GraphQLRequest { Query = "mutation{loginUser(name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}" }; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result; if (Resp.Errors != null) { if (Resp.Errors.Length > 0) { Parent.DumpLog(Resp.Errors[0].Message, -1); Parent.updateStatus(Resp.Errors[0].Message); finishedlogin(false); return; } } pdUser user = Resp.GetDataFieldAs <pdUser>("loginUser"); userid = user.id; if (string.IsNullOrWhiteSpace(userid)) { finishedlogin(false); } else { foreach (Statistic x in user.statistic) { if (x.currency.ToLower() == Currency.ToLower()) { this.bets = (int)x.bets; this.wins = (int)x.wins; this.losses = (int)x.losses; this.profit = (decimal)x.profit; this.wagered = (decimal)x.amount; break; } } foreach (Balance x in user.balances) { if (x.available.currency.ToLower() == Currency.ToLower()) { balance = (decimal)x.available.amount; break; } } finishedlogin(true); ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); return; } } catch (WebException e) { if (e.Response != null) { } finishedlogin(false); } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); finishedlogin(false); } }
public TodoItemsConsumer(GraphQL.Client.GraphQLClient client) { _client = client; }
public EventConsumer(GraphQL.Client.GraphQLClient client) { _client = client; }
public NavitaireGraphQLIntegration(string token) { _client = new GraphQL.Client.GraphQLClient(_url); _client.DefaultRequestHeaders.Add("Authorization", token); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); const String c_collectionUri = "https://dev.azure.com/ankhokha"; // Interactively ask the user for credentials, caching them so the user isn't constantly prompted VssCredentials creds = new VssBasicCredential(String.Empty, ""); // Connect to Azure DevOps Services VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds); // Get a GitHttpClient to talk to the Git endpoints GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); int pullRequestId = 1; IList <string> fileList = new List <string>(); IList <File> fileDetailsList = new List <File>(); List <FileInput> fileMutationDetailsList = new List <FileInput>(); var repository = gitClient.GetRepositoryAsync("8ff8a410-814b-463b-8ecc-949c96fe2007").SyncResult(); var repoLink = (repository.Links.Links["web"] as ReferenceLink).Href; var uriBuilder = new UriBuilder(repoLink); var query = HttpUtility.ParseQueryString(uriBuilder.Query); while (true) { fileMutationDetailsList.Clear(); Console.WriteLine(pullRequestId); // Get data about a specific repository IList <GitCommitRef> commitsList; try { commitsList = gitClient.GetPullRequestCommitsAsync("8ff8a410-814b-463b-8ecc-949c96fe2007", pullRequestId).SyncResult(); } catch (VssServiceException ex) { Console.WriteLine(String.Format("Pull request with id {0} not found. Exiting...", pullRequestId)); break; } string email = ""; string authorName = ""; foreach (var commit in commitsList) { var commitId = commit.CommitId; var result = gitClient.GetChangesAsync(commitId, new Guid("8ff8a410-814b-463b-8ecc-949c96fe2007")).SyncResult <GitCommitChanges>(); var changes = result.Changes.ToList(); foreach (var change in changes) { fileList.Add(change.Item.Path); query["path"] = change.Item.Path; email = commit.Author.Email; authorName = commit.Author.Name; uriBuilder.Query = query.ToString(); var include = true; foreach (var file in fileMutationDetailsList) { if (file.Path == change.Item.Path) { include = false; } } if (include) { fileMutationDetailsList.Add(new FileInput(change.Item.Path, uriBuilder.ToString())); } } } string graphqlServer = "https://ganes-server.azurewebsites.net/graphql"; var graphQlCLient = new GraphQL.Client.GraphQLClient(graphqlServer); var q = new GraphQL.Common.Request.GraphQLRequest(); List <FileInput> a = new List <FileInput> (); q.Query = @"mutation Mutation1($files: [FileInput]!, $email: String!, $name: String!, $pullRequestId: String!) { IngestPullRequest( pullRequest: { Files: $files, ModifiedBy: { email: $email, name: $name }, Properties: { Key: ""pullRequestId"", Value: $pullRequestId } } ) { name } }"; q.Variables = new { files = fileMutationDetailsList, email = email, name = authorName, pullRequestId = pullRequestId.ToString() }; var response = graphQlCLient.PostAsync(q).SyncResult(); Thread.Sleep(2000); pullRequestId++; } }