Class GraphQLAdaptorOptions
Gets or Sets the properties to be specified for GraphQLAdaptor.
Inheritance
Namespace: Syncfusion.Blazor.Data
Assembly: Syncfusion.Blazor.dll
Syntax
public class GraphQLAdaptorOptions : Object
Constructors
GraphQLAdaptorOptions()
Declaration
public GraphQLAdaptorOptions()
Properties
Mutation
Defines the mutations used to perform CRUD operations in the GraphQL service.
Declaration
public GraphQLMutation Mutation { get; set; }
Property Value
Type | Description |
---|---|
GraphQLMutation | This property holds an instance of the GraphQLMutation class, which provides a way to define and manage mutations for performing CRUD operations in the GraphQL service. |
Remarks
The Mutation
property provides a way to define and manage mutations for performing CRUD operations in the GraphQL service.
These mutations facilitate creating, updating, and deleting data, allowing comprehensive data manipulation through GraphQL service.
Query
Defines the GraphQL query used to fetch data from the GraphQL service.
Declaration
public string Query { get; set; }
Property Value
Type | Description |
---|---|
System.String | This property holds the GraphQL query string that is used to request data from the GraphQL service. The query string should be formatted according to the GraphQL syntax. |
Remarks
The following parameter is passed in the Query string,
dataManager
- Contains the DataManagerRequestclass properties.
The DataManagerRequestclass properties are used for performing data operations.
Examples
<SfDataManager Url=https://localhost:7140/graphql GraphQLAdaptorOptions=@AdaptorOptions Adaptor="Adaptors.GraphQLAdaptor">
</SfDataManager>
@code{
private GraphQLAdaptorOptions AdaptorOptions { get; set; } = new GraphQLAdaptorOptions
{
Query = @"
query orderDatas($dataManager: DataManagerRequestInput!) {
orderDatas(dataManager: $dataManager) {
count, result { OrderID, EmployeeID, Freight, OrderDate } , aggregates
}
}"
}
}
ResolverName
Defines the resolver function name used in the GraphQL service.
Declaration
public string ResolverName { get; set; }
Property Value
Type | Description |
---|---|
System.String | This property holds the name of the resolver function, which is used to retrieve data from the GraphQL service and bind it to the corresponding component. |
Remarks
The ResolverName
property should be specified in PascalCase, and the same name will be used as the resolver function's name
in the GraphQL service. This property plays a pivotal role in connecting the component to the GraphQL service.
By specifying the resolver function name, the component can fetch the necessary data to populate itself with information
In GraphQL service, the resolver function should return DataResult
class object containing Result, Count and optional Aggregates information.
When working with the GraphQL service, it's important to include Aggregates details in the returned DataResult
object when rendering footer summaries.
However, if footer summaries are not being rendered, there's no need to include Aggregates information in the returned DataResult
object.
Examples
Code example in GraphQL sample
<SfDataManager Url=https://localhost:7140/graphql GraphQLAdaptorOptions=@AdaptorOptions Adaptor="Adaptors.GraphQLAdaptor">
</SfDataManager>
@code {
private GraphQLAdaptorOptions AdaptorOptions { get; set; } = new GraphQLAdaptorOptions
{
ResolverName = “OrderDatas”;
}
}
Resolver function code in GraphQL service
public DataResult<T> OrderDatas(DataManagerRequest dataManager)
{
var result = GetOrders();
int count = result.Count();
...
...
if (dataManagerRequest.Aggregates != null) {
...
return new DataResult<T>() { Count = count, Result = result, Aggregates = aggregates };
}
return new DataResult<T>() { Count = count, Result = result };
}
public class DataResult<T> {
public int Count { get; set; }
public IEnumerable<T> Result { get; set; }
[GraphQLType(typeof(AnyType))]
public IDictionary<string, object> Aggregates { get; set; }
}