This plugin generates C# class
based on your GraphQL operations.
:::shell Using yarn
$ yarn add -D @graphql-codegen/c-sharp-operations
:::
type: string
default: GraphQLCodeGen
Allow you to customize the namespace name.
config:
namespaceName: MyCompany.MyNamespace
type: string
Defined the global value of namedClient
.
config:
namedClient: 'customName'
type: string
default: GQL
Allows to define a custom suffix for query operations.
config:
querySuffix: 'QueryService'
type: string
default: GQL
Allows to define a custom suffix for mutation operations.
config:
mutationSuffix: 'MutationService'
type: string
default: GQL
Allows to define a custom suffix for Subscription operations.
config:
subscriptionSuffix: 'SubscriptionService'
type: boolean
default: false
Deprecated. Changes the documentMode to documentNode
.
type: string
default: gql#graphql-tag
Customize from which module will gql
be imported from.
This is useful if you want to use modules other than graphql-tag
, e.g. graphql.macro
.
config:
gqlImport: graphql.macro#gql
config:
gqlImport: gatsby#graphql
type: boolean
default: false
Set this configuration to true
if you wish to tell codegen to generate code with no export
identifier.
type: boolean
default: false
Set this configuration to true
if you wish to make sure to remove duplicate operation name suffix.
type: boolean
default: false
Set this configuration to true
if you wish to disable auto add suffix of operation name, like Query
, Mutation
, Subscription
, Fragment
.
type: string
default: ``
Adds a suffix to generated operation result type names
type: string
default: ``
Changes the GraphQL operations variables prefix.
type: string
default: Document
Changes the GraphQL operations variables suffix.
type: string
default: ``
Changes the GraphQL fragments variables prefix.
type: string
default: FragmentDoc
Changes the GraphQL fragments variables suffix.
type: DocumentMode
default: graphQLTag
Declares how DocumentNode are created:
graphQLTag
:graphql-tag
or other modules (checkgqlImport
) will be used to generate document nodes. If this is used, document nodes are generated on client side i.e. the module used to generate this will be shipped to the clientdocumentNode
: document nodes will be generated as objects when we generate the templates.documentNodeImportFragments
: Similar to documentNode except it imports external fragments instead of embedding them.external
: document nodes are imported from an external file. To be used withimportDocumentNodeExternallyFrom
type: string
default: ``
This config is used internally by presets, but you can use it manually to tell codegen to prefix all base types that it's using.
This is useful if you wish to generate base types from typescript-operations
plugin into a different file, and import it from there.
type: string
default: ``
This config should be used if documentMode
is external
. This has 2 usage:
- any string: This would be the path to import document nodes from. This can be used if we want to manually create the document nodes e.g. Use
graphql-tag
in a separate file and export the generated document - 'near-operation-file': This is a special mode that is intended to be used with
near-operation-file
preset to import document nodes from those files. If these files are.graphql
files, we make use of webpack loader.
config:
documentMode: external
importDocumentNodeExternallyFrom: path/to/document-node-file
config:
documentMode: external
importDocumentNodeExternallyFrom: near-operation-file
type: ScalarsMap
Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type.
config:
scalars:
DateTime: Date
JSON: "{ [key: string]: any }"
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.
config:
namingConvention: lower-case#lowerCase
config:
namingConvention:
typeNames: pascal-case#pascalCase
enumValues: upper-case#upperCase
config:
namingConvention: keep
config:
namingConvention:
typeNames: pascal-case#pascalCase
transformUnderscore: true
type: string
default: ``
Prefixes all the generated types.
config:
typesPrefix: I
type: boolean
default: false
Does not add __typename to the generated types, unless it was specified in the selection set.
config:
skipTypename: true
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
config:
nonOptionalTypename: true