Skip to the content.

< Back


QueryStringBuilder

Namespace: GraphQL.Query.Builder

The GraphQL query builder class.

public class QueryStringBuilder : IQueryStringBuilder

Inheritance ObjectQueryStringBuilder
Implements IQueryStringBuilder
Attributes NullableContextAttribute, NullableAttribute

Fields

formatter

The property name formatter.

protected Func<PropertyInfo, string>? formatter;

ignoreCondition

The ignore condition for null/default properties.

protected QueryIgnoreCondition ignoreCondition;

Properties

QueryString

The query string builder.

public StringBuilder QueryString { get; private set; }

Property Value

StringBuilder

Remarks:

QueryStringBuilder.Build<TSource>(IGraphQLField<TSource>) and QueryStringBuilder.BuildSelectionSet<TSource>(IGraphQLField<TSource>) each swap in their own buffer for the duration of the call, so a builder instance reused across — or nested within — several builds never accumulates the output of the previous one.

Constructors

QueryStringBuilder()

Initializes a new instance of the QueryStringBuilder class.

public QueryStringBuilder()

QueryStringBuilder(Func<PropertyInfo, String>)

Initializes a new instance of the QueryStringBuilder class.

public QueryStringBuilder(Func<PropertyInfo, string> formatter)

Parameters

formatter Func<PropertyInfo, String>
The property name formatter

QueryStringBuilder(Func<PropertyInfo, String>, QueryIgnoreCondition)

Initializes a new instance of the QueryStringBuilder class.

public QueryStringBuilder(Func<PropertyInfo, string>? formatter, QueryIgnoreCondition ignoreCondition)

Parameters

formatter Func<PropertyInfo, String>?
The property name formatter

ignoreCondition QueryIgnoreCondition
The ignore condition for null/default properties

Methods

Build<TSource>(IGraphQLField<TSource>)

Builds the query.

public string Build<TSource>(IGraphQLField<TSource> query)

Type Parameters

TSource

Parameters

query IGraphQLField<TSource>
The query.

Returns

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

BuildSelectionSet<TSource>(IGraphQLField<TSource>)

Builds the query selection set, without the enclosing braces.

public string BuildSelectionSet<TSource>(IGraphQLField<TSource> query)

Type Parameters

TSource

Parameters

query IGraphQLField<TSource>
The query.

Returns

String
The GraphQL selection set as string.

Clear()

Clears the string builder.

public void Clear()

FormatQueryParam(Object)

Formats query param.

Returns:

Objects are serialized from their public, readable, non-indexed instance properties.

protected internal virtual string FormatQueryParam(object? value)

Parameters

value Object?

Returns

String
The formatted query param.

Exceptions

InvalidDataException
Invalid Object Type in Param List

AddParams<TSource>(IGraphQLField<TSource>)

Adds query params to the query string.

protected internal void AddParams<TSource>(IGraphQLField<TSource> query)

Type Parameters

TSource

Parameters

query IGraphQLField<TSource>
The query.

AddFields<TSource>(IGraphQLField<TSource>)

Adds fields to the query sting.

protected internal void AddFields<TSource>(IGraphQLField<TSource> query)

Type Parameters

TSource

Parameters

query IGraphQLField<TSource>
The query.

Exceptions

ArgumentException
Invalid Object in Field List


< Back