1

Please, give an easy example how to execute query. I found some examples on the net but they are not working.

Like

GraphqlClient client = new GraphqlClient("example.com\graphql"); String query = "query {getClient(condition){clientName, clientID}}" var response = client.executeQuery(query); 
5
  • Is that an example you've actually tried? Did you replace condition with the condition you're searching for? Commented Mar 6, 2020 at 8:49
  • Adding to what @DarrenLamb said, did you change the graphql endpoint in your snippet? Commented Mar 7, 2020 at 6:31
  • I just want to find some graphql queries examples using c#. Commented Mar 10, 2020 at 10:34
  • There is a nuget GraphQL.Client. How i can execute SendQueryAsync without defining a type of object? Commented Mar 10, 2020 at 11:06
  • github.com/graphql-dotnet/… Just use JObject if class for data is not definied var graphQLResponse = await graphQLClient.SendQueryAsync<JObject>(personAndFilmsRequest); Commented Mar 10, 2020 at 19:25

1 Answer 1

1

This should work fine:

var graphQLOptions = new GraphQLHttpClientOptions { EndPoint = new Uri("example.com\graphql", UriKind.Absolute), }; var graphQLClient = new GraphQLHttpClient(graphQLOptions, new NewtonsoftJsonSerializer()); var msg = new GraphQLRequest { Query = "query {getClient(condition){clientName, clientID}}" }; var graphQLResponse = await graphQLClient.SendQueryAsync<dynamic>(msg).ConfigureAwait(false); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.