Automate GraphQL Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access GraphQL data from PowerShell? This article demonstrates how to utilize the GraphQL Cmdlets for tasks like connecting to GraphQL data, automating operations, downloading data, and more.

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.
  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for GraphQL\lib\System.Data.CData.GraphQL.dll")
        
  2. 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()
    
  3. 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
    }
      

Ready to get started?

Download a free trial of the GraphQL Data Provider to get started:

 Download Now

Learn more:

GraphQL Icon GraphQL ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with GraphQL.