Book Image

Apps and Services with .NET 7

By : Mark J. Price
Book Image

Apps and Services with .NET 7

By: Mark J. Price

Overview of this book

Apps and Services with .NET 7 is for .NET 6 and .NET 7 developers who want to kick their C# and .NET understanding up a gear by learning the practical skills and knowledge they need to build real-world applications and services. It covers specialized libraries that will help you monitor and improve performance, secure your data and applications, and internationalize your code and apps. With chapters that put a variety of technologies into practice, including Web API, OData, gRPC, GraphQL, SignalR, and Azure Functions, this book will give you a broader scope of knowledge than other books that often focus on only a handful of .NET technologies. It covers the latest developments, libraries, and technologies that will help keep you up to date. You’ll also leverage .NET MAUI to develop mobile apps for iOS and Android as well as desktop apps for Windows and macOS.
Table of Contents (23 chapters)
22
Index

Implementing GraphQL mutations

Most services need to modify data as well as query it. GraphQL calls these mutations. A mutation has three related components:

  • The mutation itself, which defines the change that will be made to the graph. It should be named using a verb, a noun, and use camel casing, for example, addProduct.
  • The input is the input for a mutation, and it should have the same name as the mutation with a suffix of Input, for example, AddProductInput. Although there is only one input, it is an object graph so can be as complex as you need.
  • The payload is the returned document for a mutation, and it should have the same name as the mutation with a suffix of Payload, for example, AddProductPayload. Although there is only one payload, it is an object graph so can be as complex as you need.

Let’s define mutations for adding, updating, and deleting products:

  1. In the Northwind.GraphQL project/folder, add a class file named Mutation...