PluginsC-Sharpoperations

C# Operations

Package nameWeekly DownloadsVersionLicenseUpdated
@graphql-codegen/c-sharp-operationsDownloadsVersionLicenseApr 19th, 2026

Installation

npm i -D @graphql-codegen/c-sharp-operations
⚠️

Usage Requirements In order to use this GraphQL Codegen plugin, please make sure that you have GraphQL operations (query / mutation / subscription and fragment) set as documents: … in your codegen.yml.

Without loading your GraphQL operations (query, mutation, subscription and fragment), you won’t see any change in the generated output.

This plugin generates C# class based on your GraphQL operations.

Config API Reference

namespaceName

type: string default: GraphQLCodeGen

Allow you to customize the namespace name.

Usage Examples

config:
  namespaceName: MyCompany.MyNamespace

namedClient

type: string

Defined the global value of namedClient.

Usage Examples

config:
  namedClient: 'customName'

querySuffix

type: string default: GQL

Allows to define a custom suffix for query operations.

Usage Examples

config:
  querySuffix: 'QueryService'

mutationSuffix

type: string default: GQL

Allows to define a custom suffix for mutation operations.

Usage Examples

config:
  mutationSuffix: 'MutationService'

subscriptionSuffix

type: string default: GQL

Allows to define a custom suffix for Subscription operations.

Usage Examples

config:
  subscriptionSuffix: 'SubscriptionService'

typesafeOperation

type: boolean default: false

Allows to generate operation methods with class definitions for request/response parameters

Usage Examples

config:
  typesafeOperation: true

jsonAttributesSource

type: unknown_2 default: Newtonsoft.Json

Library that should be used to emit JSON attributes.

The c-sharp-operations plugin generates C# methods for the resolvers’ signature.

It works with GraphQL.Client library and methods can be invoked through the GraphQLHttpClient.

Example code:

using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
 
  ...
  using var client = new GraphQLHttpClient("https://gqlserver", new NewtonsoftJsonSerializer());
  var response = await client.SendQueryAsync<Types.Query>(UsersGQL.Request());