C# 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.

Installation

Using yarn
$ yarn add -D @graphql-codegen/c-sharp-operations

API Reference

namedClient

type: string

Defined the global value of namedClient.

Usage Examples

config:
namedClient: 'customName'

serviceName

type: string

Defined the global value of serviceName.

Usage Examples

config:
serviceName: 'MySDK'

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'

noGraphQLTag

type: boolean

gqlImport

type: string

noExport

type: boolean

dedupeOperationSuffix

type: boolean

omitOperationSuffix

type: boolean

operationResultSuffix

type: string

documentVariablePrefix

type: string

documentVariableSuffix

type: string

fragmentVariablePrefix

type: string

fragmentVariableSuffix

type: string

documentMode

type: DocumentMode

importOperationTypesFrom

type: string

importDocumentNodeExternallyFrom

type: string

scalars

type: ScalarsMap

Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type.

Usage Examples

config:
scalars:
DateTime: Date
JSON: "{ [key: string]: any }"

namingConvention

type: NamingConvention default: pascal-case#pascalCase

Allow you to override the naming convention of the output. You can either override all namings, or specify an object with specific custom naming convention per output. The format of the converter must be a valid module#method. Allowed values for specific output are: typeNames, enumValues. You can also use "keep" to keep all GraphQL names as-is. Additionally you can set transformUnderscore to true if you want to override the default behavior, which is to preserves underscores.

Usage Examples

Override All Names
config:
namingConvention: lower-case#lowerCase
Upper-case enum values
config:
namingConvention:
typeNames: pascal-case#pascalCase
enumValues: upper-case#upperCase
Keep names as is
config:
namingConvention: keep
Remove Underscores
config:
namingConvention:
typeNames: pascal-case#pascalCase
transformUnderscore: true

typesPrefix

type: string default: ``

Prefixes all the generated types.

Usage Examples

config:
typesPrefix: I

skipTypename

type: boolean default: false

Does not add __typename to the generated types, unless it was specified in the selection set.

Usage Examples

config:
skipTypename: true

nonOptionalTypename

type: boolean default: false

Automatically adds __typename field to the generated types, even when they are not specified in the selection set, and makes it non-optional

Usage Examples

config:
nonOptionalTypename: true