GraphQLOperation
Namespace: GraphQL.Query.Builder
Builds a complete GraphQL operation (query, mutation, or subscription).
public class GraphQLOperation : IGraphQLOperation
Inheritance Object → GraphQLOperation
Implements IGraphQLOperation
Attributes NullableContextAttribute, NullableAttribute
Properties
Type
Gets the operation type.
public OperationType? Type { get; }
Property Value
Name
Gets the optional operation name.
public string? Name { get; }
Property Value
Constructors
GraphQLOperation()
Initializes a new instance of the GraphQLOperation class (shorthand, no type).
public GraphQLOperation()
GraphQLOperation(OperationType)
Initializes a new instance of the GraphQLOperation class.
public GraphQLOperation(OperationType type)
Parameters
type OperationType
The operation type.
GraphQLOperation(OperationType, String)
Initializes a new instance of the GraphQLOperation class.
public GraphQLOperation(OperationType type, string name)
Parameters
type OperationType
The operation type.
name String
The operation name.
Exceptions
ArgumentException
The name is not a valid GraphQL name.
Methods
AddQuery(IGraphQLField)
Adds a root query to the operation.
public GraphQLOperation AddQuery(IGraphQLField query)
Parameters
query IGraphQLField
The query.
Returns
GraphQLOperation
The operation.
AddVariable(GraphQLVariable)
Adds a variable declaration to the operation.
public GraphQLOperation AddVariable(GraphQLVariable variable)
Parameters
variable GraphQLVariable
The variable.
Returns
GraphQLOperation
The operation.
AddFragment(GraphQLFragment)
Adds a fragment definition to the operation.
public GraphQLOperation AddFragment(GraphQLFragment fragment)
Parameters
fragment GraphQLFragment
The fragment.
Returns
GraphQLOperation
The operation.
Build()
Builds the complete GraphQL operation string.
public string Build()
Returns
String
The GraphQL operation as a string.
Exceptions
InvalidOperationException
The operation must have at least one query.
InvalidOperationException
A shorthand operation cannot declare variables.
InvalidOperationException
Two different fragments share the same name.