Skip to the content.

< Back


Query<TSource>

Namespace: GraphQL.Query.Builder

The query class.

public class Query<TSource> : IQuery`1, IQuery

Type Parameters

TSource

Inheritance ObjectQuery<TSource>
Implements IQuery<TSource>, IQuery
Attributes NullableContextAttribute, NullableAttribute

Fields

options

The query options.

protected QueryOptions options;

Properties

SelectList

Gets the select list.

public List<object> SelectList { get; }

Property Value

List<Object>

Arguments

Gets the arguments.

public Dictionary<string, object> Arguments { get; }

Property Value

Dictionary<String, Object>

Name

Gets the query name.

public string Name { get; private set; }

Property Value

String

AliasName

Gets the alias name.

public string AliasName { get; private set; }

Property Value

String

QueryStringBuilder

Gets the query string builder.

protected IQueryStringBuilder QueryStringBuilder { get; }

Property Value

IQueryStringBuilder

Constructors

Query(String)

Initializes a new instance of the Query<TSource> class.

public Query(string name)

Parameters

name String

Query(String, QueryOptions)

Initializes a new instance of the Query<TSource> class.

public Query(string name, QueryOptions options)

Parameters

name String

options QueryOptions

Methods

Alias(String)

Sets the query alias name.

public IQuery<TSource> Alias(string alias)

Parameters

alias String
The alias name.

Returns

IQuery<TSource>
The query.

AddField<TProperty>(Expression<Func<TSource, TProperty>>)

Adds a field to the query.

public IQuery<TSource> AddField<TProperty>(Expression<Func<TSource, TProperty>> selector)

Type Parameters

TProperty
The property type.

Parameters

selector Expression<Func<TSource, TProperty>>
The field selector.

Returns

IQuery<TSource>
The query.

AddField(String)

Adds a field to the query.

public IQuery<TSource> AddField(string field)

Parameters

field String
The field name.

Returns

IQuery<TSource>
The query.

AddField<TSubSource>(Expression<Func<TSource, TSubSource>>, Func<IQuery<TSubSource>, IQuery<TSubSource>>)

Adds a sub-object field to the query.

public IQuery<TSource> AddField<TSubSource>(Expression<Func<TSource, TSubSource>> selector, Func<IQuery<TSubSource>, IQuery<TSubSource>> build)

Type Parameters

TSubSource
The sub-object type.

Parameters

selector Expression<Func<TSource, TSubSource>>
The field selector.

build Func<IQuery<TSubSource>, IQuery<TSubSource>>
The sub-object query building function.

Returns

IQuery<TSource>
The query.

AddField<TSubSource>(Expression<Func<TSource, IEnumerable<TSubSource>>>, Func<IQuery<TSubSource>, IQuery<TSubSource>>)

Adds a sub-list field to the query.

public IQuery<TSource> AddField<TSubSource>(Expression<Func<TSource, IEnumerable<TSubSource>>> selector, Func<IQuery<TSubSource>, IQuery<TSubSource>> build)

Type Parameters

TSubSource
The sub-list object type.

Parameters

selector Expression<Func<TSource, IEnumerable<TSubSource>>>
The field selector.

build Func<IQuery<TSubSource>, IQuery<TSubSource>>
The sub-object query building function.

Returns

IQuery<TSource>
The query.

AddField<TSubSource>(String, Func<IQuery<TSubSource>, IQuery<TSubSource>>)

Adds a sub-object field to the query.

public IQuery<TSource> AddField<TSubSource>(string field, Func<IQuery<TSubSource>, IQuery<TSubSource>> build)

Type Parameters

TSubSource
The sub-object type.

Parameters

field String
The field name.

build Func<IQuery<TSubSource>, IQuery<TSubSource>>
The sub-object query building function.

Returns

IQuery<TSource>
The query.

AddUnion<TUnionType>(String, Func<IQuery<TUnionType>, IQuery<TUnionType>>)

Adds an union to the query.

public IQuery<TSource> AddUnion<TUnionType>(string typeName, Func<IQuery<TUnionType>, IQuery<TUnionType>> build)

Type Parameters

TUnionType
The union type.

Parameters

typeName String
The union type name.

build Func<IQuery<TUnionType>, IQuery<TUnionType>>
The union building function.

Returns

IQuery<TSource>
The query.

AddUnion<TUnionType>(Func<IQuery<TUnionType>, IQuery<TUnionType>>)

Adds an union to the query.

public IQuery<TSource> AddUnion<TUnionType>(Func<IQuery<TUnionType>, IQuery<TUnionType>> build)

Type Parameters

TUnionType
The union type.

Parameters

build Func<IQuery<TUnionType>, IQuery<TUnionType>>
The union building function.

Returns

IQuery<TSource>
The query.

AddArgument(String, Object)

Adds a new argument to the query.

public IQuery<TSource> AddArgument(string key, object value)

Parameters

key String
The argument name.

value Object
The value.

Returns

IQuery<TSource>
The query.

AddArguments(Dictionary<String, Object>)

Adds arguments to the query.

public IQuery<TSource> AddArguments(Dictionary<string, object> arguments)

Parameters

arguments Dictionary<String, Object>
the dictionary argument.

Returns

IQuery<TSource>
The query.

AddArguments<TArguments>(TArguments)

Adds arguments to the query.

public IQuery<TSource> AddArguments<TArguments>(TArguments arguments)

Type Parameters

TArguments
The arguments object type.

Parameters

arguments TArguments
The arguments object.

Returns

IQuery<TSource>
The query.

Build()

Builds the query.

public string Build()

Returns

String
The GraphQL query as string, without outer enclosing block.

Exceptions

ArgumentException
Must have a ‘Name’ specified in the Query

ArgumentException
Must have a one or more ‘Select’ fields in the Query


< Back