|
| 1 | +Get-GQL |
| 2 | +------- |
| 3 | + |
| 4 | +### Synopsis |
| 5 | +Gets a GraphQL query. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### Description |
| 10 | + |
| 11 | +Gets a GraphQL query and returns the results as a PowerShell object. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +### Examples |
| 16 | +Getting git sponsorship information from GitHub GraphQL. |
| 17 | +**To use this example, we'll need to provide `$MyPat` with a Personal Access Token.** |
| 18 | + |
| 19 | +```PowerShell |
| 20 | +Get-GQL -Query ./Examples/GitSponsors.gql -PersonalAccessToken $myPat |
| 21 | +``` |
| 22 | +We can decorate graph object results to customize them. |
| 23 | +Let's add a Sponsors property to the output object that returns the sponsor nodes. |
| 24 | + |
| 25 | +```PowerShell |
| 26 | +Update-TypeData -TypeName 'GitSponsors' -MemberName 'Sponsors' -MemberType ScriptProperty -Value { |
| 27 | + $this.viewer.sponsors.nodes |
| 28 | +} -Force |
| 29 | +
|
| 30 | +# And let's add a Sponsoring property to the output object that returns the sponsoring nodes. |
| 31 | +Update-TypeData -TypeName 'GitSponsors' -MemberName 'Sponsoring' -MemberType ScriptProperty -Value { |
| 32 | + $this.viewer.sponsoring.nodes |
| 33 | +} -Force |
| 34 | +
|
| 35 | +# And let's display sponsoring and sponsors by default |
| 36 | +Update-TypeData -TypeName 'GitSponsors' -DefaultDisplayPropertySet 'Sponsors','Sponsoring' -Force |
| 37 | +
|
| 38 | +# Now we can run the query and get the results. |
| 39 | +Get-GQL -Query ./Examples/GitSponsors.gql -PersonalAccessToken $myPat -PSTypeName 'GitSponsors' | |
| 40 | + Select-Object -Property Sponsors,Sponsoring |
| 41 | +``` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +### Parameters |
| 46 | +#### **Query** |
| 47 | +One or more queries to run. |
| 48 | + |
| 49 | +|Type |Required|Position|PipelineInput |Aliases | |
| 50 | +|------------|--------|--------|---------------------|--------| |
| 51 | +|`[String[]]`|false |1 |true (ByPropertyName)|FullName| |
| 52 | + |
| 53 | +#### **PersonalAccessToken** |
| 54 | +The Personal Access Token to use for the query. |
| 55 | + |
| 56 | +|Type |Required|Position|PipelineInput |Aliases | |
| 57 | +|----------|--------|--------|---------------------|-----------------------------| |
| 58 | +|`[String]`|false |2 |true (ByPropertyName)|Token<br/>PAT<br/>AccessToken| |
| 59 | + |
| 60 | +#### **GraphQLUri** |
| 61 | +The GraphQL endpoint to query. |
| 62 | + |
| 63 | +|Type |Required|Position|PipelineInput |Aliases| |
| 64 | +|-------|--------|--------|---------------------|-------| |
| 65 | +|`[Uri]`|false |3 |true (ByPropertyName)|uri | |
| 66 | + |
| 67 | +#### **Parameter** |
| 68 | +Any variables or parameters to provide to the query. |
| 69 | + |
| 70 | +|Type |Required|Position|PipelineInput |Aliases | |
| 71 | +|---------------|--------|--------|---------------------|-------------------------------------| |
| 72 | +|`[IDictionary]`|false |4 |true (ByPropertyName)|Parameters<br/>Variable<br/>Variables| |
| 73 | + |
| 74 | +#### **Header** |
| 75 | +Any additional headers to include in the request |
| 76 | + |
| 77 | +|Type |Required|Position|PipelineInput|Aliases| |
| 78 | +|---------------|--------|--------|-------------|-------| |
| 79 | +|`[IDictionary]`|false |5 |false |Headers| |
| 80 | + |
| 81 | +#### **PSTypeName** |
| 82 | +Adds PSTypeName(s) to use for the output object, making it a decorated object. |
| 83 | +By decorating an object with one or more typenames, we can: |
| 84 | +* Add additional properties and methods to the object |
| 85 | +* Format the output object any way we want |
| 86 | + |
| 87 | +|Type |Required|Position|PipelineInput|Aliases | |
| 88 | +|------------|--------|--------|-------------|---------------------------------------------------------------------------| |
| 89 | +|`[String[]]`|false |6 |false |Decorate<br/>Decoration<br/>PSTypeNames<br/>TypeName<br/>TypeNames<br/>Type| |
| 90 | + |
| 91 | +#### **WhatIf** |
| 92 | +-WhatIf is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. |
| 93 | +-WhatIf is used to see what would happen, or return operations without executing them |
| 94 | +#### **Confirm** |
| 95 | +-Confirm is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. |
| 96 | +-Confirm is used to -Confirm each operation. |
| 97 | + |
| 98 | +If you pass ```-Confirm:$false``` you will not be prompted. |
| 99 | + |
| 100 | +If the command sets a ```[ConfirmImpact("Medium")]``` which is lower than ```$confirmImpactPreference```, you will not be prompted unless -Confirm is passed. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +### Syntax |
| 105 | +```PowerShell |
| 106 | +Get-GQL [[-Query] <String[]>] [[-PersonalAccessToken] <String>] [[-GraphQLUri] <Uri>] [[-Parameter] <IDictionary>] [[-Header] <IDictionary>] [[-PSTypeName] <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>] |
| 107 | +``` |
0 commit comments