Building a .NET client for a GraphQL service
Now that we have explored some queries with the Banana Cake Pop tool, let’s see how a client could call the GraphQL service. Although the Banana Cake Pop tool is convenient, it runs in the same domain as the service, so some issues might not become apparent until we create a separate client.
Most GraphQL services process GET
and POST
requests in either the application/graphql
or application/json
media formats. An application/graphql
request would only contain a query document. The benefit of using application/json
is that as well as the query document, you can specify operations when you have more than one, and define and set variables, as shown in the following code:
{
"query": "...",
"operationName": "...",
"variables": { "variable1": "value1", ... }
}
We will use the application/json
media format.
Understanding GraphQL responses
A...