Automate GraphQL Integration Tasks from PowerShell
The CData ADO.NET Provider for GraphQL is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to GraphQL.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for GraphQL; this tutorial shows how to use the Provider to retrieve GraphQL data.
Once you have acquired the necessary connection properties, accessing GraphQL data in PowerShell can be enabled in three steps.
You must specify the URL of the GraphQL service. The driver supports two types of authentication:
- Basic: Set AuthScheme to Basic. You must specify the User and Password of the GraphQL service.
- OAuth 1.0 & 2.0: Take a look at the OAuth section in the Help documentation for detailed instructions.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for GraphQL\lib\System.Data.CData.GraphQL.dll") -
Connect to GraphQL:
$conn= New-Object System.Data.CData.GraphQL.GraphQLConnection("AuthScheme=Basic;User=username;Password=password;URL=https://mysite.com;InitiateOAuth=GETANDREFRESH;") $conn.Open() -
Instantiate the GraphQLDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, Email from Users" $da= New-Object System.Data.CData.GraphQL.GraphQLDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.name $_.email }