---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, Workday Graph API, Graph API, GraphQL]
nav: wcp_docs
parent_url: /wcp_docs/
title: Graph Query Components
layout: subsection
---

<a id="section_N1005C_N10059_N10001"></a>
A Graph Query component contains a query (for reading data) or mutation (for writing data) using Workday Graph API. Use a Graph Query component to:

-   Simplify PMD endpoints that submit long or complex Graph API queries or mutations.
-   Reuse queries or mutations across multiple PMDs.


## <a id="section_ydg_z15_gxb"></a>Example

This sample Graph Query component contains `parameters` (sent from the PMD endpoint) and `variables` that use the given parameter.

```
{
    "id": "queryActiveWorkers",
    "parameters": ["active"],
    "query": "
        query getWorkers ($dataSourceVariables: Worker_DataSources!) {
          worker(dataSource: $dataSourceVariables) {
            data {
              workdayID {
                id
                type
              }
              businessTitle
            }
          }
        }
    ",
    "variables": {
        "dataSourceVariables": {
            "indexedAllWorkers": {
                "filter": {
                    "indexedAllWorkersFilter": {
                        "isActive": "<% active %>"
                    }
                }
            }
        }
    }
}
```

The sample PMD endpoint that references the Graph Query component:

```
"endPoints" : [ 
  {
    "name" : "getActiveWorkers",
    "baseUrlType" : "workday-graph",
    "httpMethod" : "POST",
    "graphQuery" : {
      "queryId" : "queryActiveWorkers",
      "parameters" : {
        "active" : true
      }
    }
  }
]
```

Depending on your use case, you can specify the `variables` either in the Graph Query component or in the PMD endpoint that references the `queryId`.

This next sample Graph Query contains a mutation with embedded `$` variables, but the component doesn't have `parameters` and `variables`.

```
{
    "id": "mutationChangeBusinessTitle",
    "query": "
        mutation updateBusinessTitle($jobChangeId: ID!, $businessTitle: String) {
          updateJobChangeBusinessTitle(
            businessTitleId: {id: $jobChangeId}
            input: {businessTitle: $businessTitle}
            jobChangeId: {id: $jobChangeId}
          ) {
            businessTitle
          }
        }
    "
}
```

In this case, the PMD endpoint specifies the mutation variables:

```
"outboundEndPoints" : [ 
  {
    "name" : "updateBusinessTitle",
    "baseUrlType" : "workday-graph",
    "authType" : "sso",
    "httpMethod" : "POST",
    "graphQuery" : {
      "queryId" : "mutationChangeBusinessTitle",
      "variables" : {
        "jobChangeId" : "<% initiateJobChange.data.initiateWorkerJobChange.workdayID.id %>",
        "businessTitle" : "<% newTitle.value %>"
      }
    }
  }
]
```

For more examples, see [Sample Graph Query Components in PMDs](/wcp_docs/yvb1682352201818.html).

## <a id="section_rtr_mb2_fxb"></a>Attributes

-   <b>id</b>

    Data type: string

    (Required) The unique ID of the Graph Query component. The `id` must match the `queryId` of the PMD endpoint that references this Graph Query component.

-   <b>parameters</b>

    Data type: List of strings

    An unordered list of parameter names. Use `parameters` to send values from PMD endpoint definitions to the `variables` within the Graph Query component.

    To reference a parameter in `variables`, use the PMD Scripting notation `<% %>`.

-   <b>query</b>

    Data type: string

    A static string containing the Graph API query or mutation.

    The `query` string can contain Graph API variables (with the `$` prefix character), but it can't contain PMD scripting and dynamic values. Specify the variable values in `variables`.

-   <b>variables</b>

    Data type: Map

    A map containing the query or mutation input variables.

    To reference the parameters, use the PMD Scripting notation `<% %>`.

    Although variables can use PMD Scripting, note that a Graph Query component is self-contained and can't reference any of the app variables. You can use only the PMD endpoint parameters to send dynamic values to the Graph Query component.



### Related Information

[Graph API Queries](/wcp_docs/qxq1671067079349.html)

[Graph API Mutations](/wcp_docs/kbu1671067116723.html)

[Graph API in Extend Pages](/wcp_docs/xfa1653188971557.html)

[Sample Graph Query Components in PMDs](/wcp_docs/yvb1682352201818.html)

