Table of Contents

Class GraphQLDataProvider

Namespace
combit.Reporting.DataProviders
Assembly
combit.ListLabel31.CrossPlatform.dll

Provides a data provider implementation for GraphQL APIs.

public sealed class GraphQLDataProvider : IDataProvider, ICanHandleUsedIdentifiers, ISupportsLogger, ICanHandleUsedRelations, ISupplyBaseTables, IDisposable
Inheritance
GraphQLDataProvider
Implements
Inherited Members

Examples

The following example demonstrates how to use the GraphQLDataProvider to export a report to PDF:

// Example 1: Basic connection to a GraphQL API
GraphQLDataProvider provider = new GraphQLDataProvider("https://api.example.com/graphql");

// Optional: Configure connection settings
provider.ConnectionTimeout = 60;
provider.MaximumEmbeddedFieldDepth = 3;

// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;

// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;

// Export the report to PDF.
listLabel.Export(exportConfiguration);

// Example 2: Connection with authentication
NetworkCredential credentials = new NetworkCredential("username", "password");
GraphQLDataProvider authProvider = new GraphQLDataProvider(
    "https://api.example.com/graphql",
    credentials);

// Example 3: Connection with custom headers (e.g., API key)
GraphQLDataProvider apiKeyProvider = new GraphQLDataProvider("https://api.example.com/graphql");
apiKeyProvider.Headers.Add("Authorization", "Bearer your_api_token_here");
apiKeyProvider.Headers.Add("X-API-Key", "your_api_key_here");

// Example 4: Using a local schema file for faster initialization
GraphQLDataProvider cachedProvider = new GraphQLDataProvider(
    "https://api.example.com/graphql",
    networkCredential: null,
    localMetadataFilePath: @"C:\Cache\schema.json");

// Example 5: Filtering to only queries (exclude object types)
GraphQLDataProvider queriesOnlyProvider = new GraphQLDataProvider("https://api.example.com/graphql");
queriesOnlyProvider.SupportedElementTypes = GraphQLElementType.Query;

// Example 6: Custom query and mutation type names (for non-standard schemas)
GraphQLDataProvider customProvider = new GraphQLDataProvider("https://api.example.com/graphql");
customProvider.QueriesTypeName = "QueryRoot";
customProvider.MutationsTypeName = "MutationRoot";
customProvider.QueryPrefix = "Query_"; // Prefix for query table names

Remarks

The GraphQLDataProvider class implements multiple interfaces including IDataProvider, ICanHandleUsedIdentifiers, ISupportsLogger, combit.Reporting.DataProviders.ISupportsParameters, ICanHandleUsedRelations, and ISupplyBaseTables to provide comprehensive GraphQL API connectivity. The provider automatically introspects the GraphQL schema to discover available types, queries, and their relationships, creating tables for both object types and queries. It supports query parameters with automatic parameter binding, allowing dynamic query execution based on report parameters. Network credentials and custom HTTP headers can be configured for authentication. The provider intelligently manages nested object relationships, handling foreign keys and collections up to a configurable depth. Schema caching is supported via local metadata files to improve performance. Query and object type filtering allows control over which data is exposed. This provider is ideal for reporting on data from modern APIs that use GraphQL, providing a seamless bridge between GraphQL's graph-based data model and List & Label's tabular reporting.

Constructors

GraphQLDataProvider(string, NetworkCredential, string?)

Initializes a new instance of the GraphQLDataProvider class with the specified URL, network credentials, and an optional schema.

public GraphQLDataProvider(string url, NetworkCredential networkCredential, string? schema = null)

Parameters

url string

The URL of the GraphQL endpoint.

networkCredential NetworkCredential

The network credentials for authentication.

schema string

The optional GraphQL schema as a string.

GraphQLDataProvider(string, NetworkCredential, string, string, string?)

Initializes a new instance of the GraphQLDataProvider class with the specified parameters.

public GraphQLDataProvider(string url, NetworkCredential networkCredential, string localMetadataFilePath, string queryPrefix = "Q_", string? schema = null)

Parameters

url string

The URL of the GraphQL endpoint.

networkCredential NetworkCredential

The network credentials for authentication.

localMetadataFilePath string

The local file path to a metadata file used for schema initialization.

queryPrefix string

The prefix used when naming queries.

schema string

The optional GraphQL schema as a string.

GraphQLDataProvider(string, string?)

Initializes a new instance of the GraphQLDataProvider class with the specified URL and an optional schema.

public GraphQLDataProvider(string url, string? schema = null)

Parameters

url string

The URL of the GraphQL endpoint.

schema string

The optional GraphQL schema as a string.

Properties

ConnectionTimeout

Gets or sets the connection timeout (in seconds) for GraphQL requests.

public int ConnectionTimeout { get; set; }

Property Value

int

Headers

Gets the HTTP request headers that will be used for GraphQL requests.

public HttpRequestHeaders Headers { get; }

Property Value

HttpRequestHeaders

MaximumEmbeddedFieldDepth

Gets or sets the maximum depth allowed for embedded fields.

public int MaximumEmbeddedFieldDepth { get; set; }

Property Value

int

MutationsTypeName

Gets or sets the type name for mutations.

public string MutationsTypeName { get; set; }

Property Value

string

NetworkCredential

Gets the network credentials used to access the GraphQL endpoint.

public NetworkCredential NetworkCredential { get; }

Property Value

NetworkCredential

QueriesTypeName

Gets or sets the type name for queries.

public string QueriesTypeName { get; set; }

Property Value

string

QueryPrefix

Gets or sets the prefix used for naming queries.

public string QueryPrefix { get; set; }

Property Value

string

Schema

Gets or sets the GraphQL schema.

public string Schema { get; set; }

Property Value

string

SupportedElementTypes

Gets or sets the supported GraphQL element types.

public GraphQLElementType SupportedElementTypes { get; set; }

Property Value

GraphQLElementType

Url

Gets or sets the URL of the GraphQL endpoint.

public string Url { get; set; }

Property Value

string

Methods

Dispose()

Releases all resources used by the GraphQLDataProvider.

public void Dispose()