Back to Graphql Dotnet

Global Switches

docs2/site/docs/getting-started/global-switches.md

8.8.41.7 KB
Original Source

Global Switches

GraphQL.NET provides some global options for configuring GraphQL execution. These options are called GlobalSwitches. These options are global, because they apply immediately to all the schemas used in the application, therefore use them with caution. It is recommended to set these options at the very beginning of the application before performing any other code from GraphQL.NET.

The current options list is presented below:

Property NameDefault Value
EnableReadDefaultValueFromAttributestrue
EnableReadDeprecationReasonFromAttributestrue
EnableReadDescriptionFromAttributestrue
EnableReadDescriptionFromXmlDocumentationfalse
NameValidationNameValidator.ValidateDefault
UseDeclaringTypeNamesfalse
GlobalAttributesAn empty collection

For a detailed description of each option, see GlobalSwitches.

Global GraphQL Attributes

In addition to adding GraphQLAttribute instances to the collection noted above, you may also apply GraphQLAttributes globally by applying them to the module or assembly. Code that utilizes GraphQLAttributes, such as auto-registering graph types, will scan the CLR type's owning module and assembly and apply any globally-defined attributes found. Globally-defined attributes may be configured to execute before or after individually-specified attributes by changing the GraphQLAttribute.Priority value. When writing your globally-defined attribute do not forget to mark it with AttributeUsage attribute and include AttributeTargets.Assembly or AttributeTargets.Module.