Skip to the content.

< Back


GraphQLVariable

Namespace: GraphQL.Query.Builder

Represents a GraphQL variable declaration.

public class GraphQLVariable

Inheritance ObjectGraphQLVariable
Attributes NullableContextAttribute, NullableAttribute

Properties

Name

Gets the variable name (without the $ prefix).

public string Name { get; }

Property Value

String

GraphQLType

Gets the GraphQL type (e.g., “ID!”, “String”, “Int”).

public string GraphQLType { get; }

Property Value

String

DefaultValue

Gets the optional default value.

public object? DefaultValue { get; }

Property Value

Object

HasDefaultValue

Gets whether a default value was specified.

public bool HasDefaultValue { get; }

Property Value

Boolean

Constructors

GraphQLVariable(String, String)

Initializes a new instance of the GraphQLVariable class.

public GraphQLVariable(string name, string graphQLType)

Parameters

name String
The variable name (without the $ prefix).

graphQLType String
The GraphQL type.

Exceptions

ArgumentException
The name is not a valid GraphQL name or the type is not a valid GraphQL type.

GraphQLVariable(String, String, Object)

Initializes a new instance of the GraphQLVariable class with a default value.

public GraphQLVariable(string name, string graphQLType, object? defaultValue)

Parameters

name String
The variable name (without the $ prefix).

graphQLType String
The GraphQL type.

defaultValue Object?
The default value.

Methods

Reference()

Creates a variable reference for use in argument values.

public GraphQLVariableReference Reference()

Returns

GraphQLVariableReference
A GraphQLVariableReference for this variable.


< Back