# ExecuteQuery

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Unknown

Source code: <https://github.com/FrendsPlatform/Frends.GraphQl/tree/main/Frends.GraphQl.ExecuteQuery>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                      | Description                                                                                                                                                                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query : `String`          | <p>GraphQl Query</p><p><br>Default: <code>-</code><br>Example: <code>query ($surname: String!) { users(surname: $surname) { id name } }</code></p>                                                                                  |
| Variables : `Variable[]`  | <p>GraphQl variables for query</p><p><br>Default: <code>-</code><br>Example: <code>\[{"key" : "surname", "value" : "Doe"}]</code></p>                                                                                               |
| OperationName : `String`  | <p>The name of the operation to execute. Required if the query contains multiple operations.</p><p><br>Default: <code>-</code><br>Example: <code>GetUser</code></p>                                                                 |
| Extensions : `Variable[]` | <p>Additional entries for protocol extensions. This is a map of additional metadata.</p><p><br>Default: <code>-</code><br>Example: <code>\[{"key" : "persistedQuery", "value" : {"version": 1, "sha256Hash": "abc123"}}]</code></p> |
| {% endtab %}              |                                                                                                                                                                                                                                     |

{% tab title="Parameter: Connection" %}

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| EndpointUrl : `String`            | <p>Url to GraphQl server.</p><p><br>Default: <code>-</code><br>Example: <code><http://localhost:4000></code></p>                                                                                                                                                                                                                                                           |
| Authentication : `Authentication` | <p>Method of authenticating a request</p><p>Possible values:</p><ul><li><code>None</code>:</li></ul><p>Method of authenticating a request</p><ul><li><code>Basic</code>:</li></ul><p>Method of authenticating a request</p><ul><li><code>OAuth</code>:</li></ul><p>Method of authenticating a request</p><p><br>Default: <code>-</code><br>Example: <code>OAuth</code></p> |
| Username : `String`               | <p>If Basic Authentication is selected, you should use a username</p><p><br>Default: <code>-</code><br>Example: <code>Username</code></p>                                                                                                                                                                                                                                  |
| 🗝Password : `String`             | <p>Password for the username</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                    |
| 🗝BearerToken : `String`          | <p>Bearer token to be used for request. Token will be added as an Authorization header.</p><p><br>Default: <code>-</code><br>Example: <code>Token123</code></p>                                                                                                                                                                                                            |
| Method : `Method`                 | <p>The HTTP Method to be used with the request.</p><p>Possible values:</p><ul><li><code>Get</code>:</li></ul><p>The HTTP Method to be used with the request.</p><ul><li><code>Post</code>:</li></ul><p>The HTTP Method to be used with the request.</p><p><br>Default: <code>1</code><br>Example: <code>GET</code></p>                                                     |
| Headers : `Header[]`              | <p>List of HTTP headers to be added to the request.</p><p><br>Default: <code>-</code><br>Example: <code>Name: Header, Value: HeaderValue</code></p>                                                                                                                                                                                                                        |
| {% endtab %}                      |                                                                                                                                                                                                                                                                                                                                                                            |

{% tab title="Parameter: Options" %}

| Name                                | Description                                                                                                                           |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| ThrowErrorOnFailure : `Boolean`     | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>false</code></p>                      |
| ErrorMessageOnFailure : `String`    | <p>Overrides the error message on failure.</p><p><br>Default: <code>-</code><br>Example: <code>Custom error message</code></p>        |
| ConnectionTimeoutSeconds : `Int32`  | <p>Timeout in seconds to be used for the connection and operation.</p><p><br>Default: <code>30</code><br>Example: <code>30</code></p> |
| AllowInvalidCertificate : `Boolean` | <p>Do not throw an exception on a certificate error.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>          |
| {% endtab %}                        |                                                                                                                                       |

{% tab title="Result: Result" %}

| Name                 | Description                                                                                                                                         |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`  | <p>Indicates if the task completed successfully.<br>Example: <code>true</code></p>                                                                  |
| Data : `JObject`     | <p>Content of the returned response<br>Example: <code>foobar,foobar</code></p>                                                                      |
| Headers : `Header[]` | <p>Array of response headers<br>Example: <code>Name: Header, Value: HeaderValue</code></p>                                                          |
| Error : `Error`      | <p>Error that occurred during task execution.<br>Example: <code>object { string Message, object { Exception exception } AdditionalInfo }</code></p> |
| {% endtab %}         |                                                                                                                                                     |

{% tab title="Changelog" %}

## Changelog

### \[2.0.0] - 2025-11-14

#### Changed

* **BREAKING**: Variable values now support complex types (objects, arrays) instead of only strings. Variables are properly serialized without double-serialization.
* GET method now uses JSON serialization for variables instead of manual string construction.
* GraphQL response errors are now properly detected. Result.Success is set to false when the response contains errors, and an exception is thrown when ThrowErrorOnFailure is enabled.

#### Added

* Support for operationName field to specify which operation to execute when a query contains multiple operations.
* Support for extensions field for protocol extensions and additional metadata.

### \[1.1.0] - 2025-07-31

#### Changed

* Make default error message empty by default

### \[1.0.0] - 2025-06-03

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
