---
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: Sample Queries
layout: subsection
---

## <a id="section_w1y_b34_nwb"></a>Get Processing Worker

To access worker data of the currently logged in user, this sample query uses the `processingWorker` data source of the `worker` query.

```
query  {
worker( dataSource: { processingWorker : {} } ) {
  data {
    descriptor
    workdayID {
      id
    }
  }
}
}
```

Sample response:

```
{
"data": {
  "worker": {
    "data": [
      {
        "descriptor": "Logan McNeil",
        "workdayID": {
          "id": "3aa5550b7fe348b98d7b5741afc65534"
        }
      }
    ]
  }
}
}
```

## <a id="section_rdk_mv5_stb"></a>Get Worker by Workday ID

To access worker data by the worker ID, this sample query specifies the `workerID` in the `where` criteria of the `worker` query. It specifies the Workday ID in the <i>$workerId</i> query variable.

```
query getWorkerById($workerId: ID!){
worker(
  dataSource: {indexedAllWorkers: {
      filter: {
        indexedAllWorkersFilter: {}
      }
    }
  },
  where: {
    workdayID: {
      in: [
         {id: $workerId}
      ]
    }
  }
) {
  data{
    descriptor
    businessTitle
    workdayID{
      id
    }
    email_PrimaryWork
    employeeID
    supervisoryOrganization_PrimaryPosition{
      name
      location_Primary{
        locationName
      }
    }
  }
}
}
```

Query variable:

```
{
"workerId": "cc7fb31eecd544e9ae8e03653c63bfab"
}
```

Sample response:

```
{
"data": {
  "worker": {
    "data": [
      {
        "descriptor": "Maria Cardoza",
        "businessTitle": "Sr Director 1",
        "workdayID": {
          "id": "cc7fb31eecd544e9ae8e03653c63bfab"
        },
        "email_PrimaryWork": "mcardoza@workday.net",
        "employeeID": "21006",
        "supervisoryOrganization_PrimaryPosition": {
          "name": "HR Services",
          "location_Primary": {
            "locationName": "San Francisco"
          }
        }
      }
    ]
  }
}
}
```

## <a id="section_ily_22j_hwb"></a>Get Worker by Employee ID

To access worker data by the employee reference ID, this sample query specifies the `workerID` using the `Employee_ID` reference ID type in the `where` criteria. It specifies the employee ID in the <i>$workerId</i> query variable.

```
query getWorkerByEmployeeId($isActive: Boolean, $workerId: ID!) {
worker(
  dataSource: {indexedAllWorkers: {filter: {indexedAllWorkersFilter: {isActive: $isActive}}}},
  where: {workdayID: {in: [{id: $workerId, type: "Employee_ID"}]}}
) {
  data {
    descriptor
    workdayID {
      id
    }
    employeeID
    businessTitle
    email_PrimaryWork
    continuousServiceDate
  }
}
}
```

Query variables:

```
{
"isActive": true,
"workerId": "21001"
}
```

Sample response:

```
{
"data": {
  "worker": {
    "data": [
      {
        "descriptor": "Logan McNeil",
        "workdayID": {
          "id": "3aa5550b7fe348b98d7b5741afc65534"
        },
        "employeeID": "21001",
        "businessTitle": "Vice President, Human Resources",
        "email_PrimaryWork": "user@workday.net",
        "continuousServiceDate": "2000-01-01"
      }
    ]
  }
}
}
```

<b>Note:</b> In the PMD endpoint, you'll need to escape the double quotes in the `query` string. Example:

```
{
  "name" : "getWorkerByEmployeeId",
  "baseUrlType" : "workday-graph",
  "httpMethod" : "POST",
  "graphQuery" : {
    "query" : "query getWorkerByEmployeeId($isActive: Boolean, $workerId: ID!) {
        worker(
          dataSource: {indexedAllWorkers: {filter: {indexedAllWorkersFilter: {isActive: $isActive}}}},
          where: {workdayID: {in: [{id: $workerId, type: \"Employee_ID\"}]}}
        ) {
          data {
            descriptor
            workdayID {
              id
            }
            employeeID
            businessTitle
            email_PrimaryWork
            continuousServiceDate            
          }
        }
      }
    ",
    "variables" : {
      "isActive" : true,
      "workerId" : "21001"
    }
  },
  "failOnStatusCodes" : [ {
    "code" : 400
  } ]
}
```

## <a id="section_fvh_pv5_stb"></a>Get Active Workers

To get the active workers, this sample query specifies the `isActive` filter field of the `indexedAllWorkersFilter` data source filter.  It specifies the `isActive` field inside the <i>$dataSourceVariables</i> query variable.

```
query getActiveWorkers($dataSourceVariables: Worker_DataSources!, $limit: BigInt, $offset: BigInt) {
worker(
  dataSource: $dataSourceVariables,
  limit: $limit,
  offset: $offset
  orderBy: [{businessTitle: ASC}, {workdayID: ASC}]
) {
  data {
    descriptor
    workdayID {
      id
    }
    businessTitle
  }
  total
}
}
```

Query variables:

```
{
"dataSourceVariables": {
  "indexedAllWorkers": {
    "filter": {
      "indexedAllWorkersFilter": {
        "isActive": true
      }
    }
  }
},
"limit": 50,
"offset": 0
}
```

Sample response:

```
{
 "data": {
  "worker": {
    "data": [
      {
        "descriptor": "Nathan Moore",
        "workdayID": {
          "id": "3dcb259a412746e88d330f2ad0c0ec28"
        },
        "businessTitle": "Accounting Specialist - AP"
      },
      {
        "descriptor": "Ian Murray",
        "workdayID": {
          "id": "48d1f8e4402b419ea7e45322d8aae374"
        },
        "businessTitle": "Accounting Specialist - AP"
      },
      {
        "descriptor": "Wesley Kingston",
        "workdayID": {
          "id": "1876480fa11010d6501bfc3dad351f1d"
        },
        "businessTitle": "Accounting Specialist - AR"
      },
      . . .
    ],
    "total": 496
  }
}
}
```

## <a id="section_zdx_cvs_wvb"></a>Get Safety Incidents

To get safety incidents within a data range, this sample query specifies the dates in the `safetyIncidentsInDateRange` data source.  It specifies the start and end dates inside the <i>$safetyIncident_dataSource</i> query variable.

```
query getSafetyIncidents($safetyIncident_dataSource: SafetyIncident_DataSources!) {
safetyIncident(
  dataSource: $safetyIncident_dataSource
  orderBy: {incidentDateAndTime: DESC}
) {
  total
  data {
    descriptor
    safetyIncidentEvent {
      dateAndTimeCompleted
    }
    safetyIncidentHistory {
      total
    }
    safetyIncidentID
    workdayID {
      id
    }
    involvedParties {data {involvedPartyWorker{descriptor workdayID{id}}}}
  }
}
}
```

Query variables:

```
{
"safetyIncident_dataSource": {
  "safetyIncidentsInDateRange": {
    "startDate": "2020-01-01",
    "endDate": "2022-01-01"
  }
}
}
```

Sample response:

```
{
"data": {
  "safetyIncident": {
    "total": 2,
    "data": [
      {
        "descriptor": "CASE-00757 | New | 08/04/2020 | Sydney",
        "safetyIncidentEvent": {
          "dateAndTimeCompleted": "2020-08-06T02:22:49.941Z"
        },
        "safetyIncidentHistory": {
          "total": 1
        },
        "safetyIncidentID": "CASE-00757",
        "workdayID": {
          "id": "1b1d124feace0197096d30f75409f805"
        },
        "involvedParties": {
          "data": [
            {
              "involvedPartyWorker": {
                "descriptor": "Hannah Morton",
                "workdayID": {
                  "id": "93a069bf2ac61044fd7144c2c4152e8f"
                }
              }
            }
          ]
        }
      },
      {
        "descriptor": "CASE-00758 | Completed Investigation | 06/30/2020 | Auckland",
        "safetyIncidentEvent": {
          "dateAndTimeCompleted": "2020-08-06T02:35:51.711Z"
        },
        "safetyIncidentHistory": {
          "total": 2
        },
        "safetyIncidentID": "CASE-00758",
        "workdayID": {
          "id": "1b1d124feace01c07e25c6c055091006"
        },
        "involvedParties": {
          "data": [
            {
              "involvedPartyWorker": {
                "descriptor": "Lachlan Benbow",
                "workdayID": {
                  "id": "827151affb3f4914ab6494d1e3b78d58"
                }
              }
            }
          ]
        }
      }
    ]
  }
}
}
```

## <a id="section_ajh_rvs_wvb"></a>Get Worker and Safety Incidents

To get safety incidents for a specific worker, this sample query gets the `safetyIncidentEvents_InProgressOrCompleted` field from the `Worker` object. The `where` criteria specifies the Workday ID of the worker in the <i>$workerId</i> query variable.

```
query getWorkerSafetyIncidentById($workerId: ID!, $limit: BigInt, $offset: BigInt){
worker(
  dataSource: {indexedAllWorkers: {
      filter: {
        indexedAllWorkersFilter: {}
      }
    }
  },
  where: {
    workdayID: {
      in: [
         {id: $workerId}
      ]
    }
  }
) {
  data{
    businessTitle
    workdayID{
      id
    }
    safetyIncidentEvents_InProgressOrCompleted {
      data {
        descriptor
        safetyIncident_Proposed{
          involvedParties(limit: $limit,offset: $offset) {
            data{
              caseNumber
            }
          }
        }
      }
    }
  }
}
}
```

Query variables:

```
{
"workerId": "827151affb3f4914ab6494d1e3b78d58",
"limit": 50,
"offset": 0
}
```

Sample response:

```
{
"data": {
  "worker": {
    "data": [
      {
        "businessTitle": "Customer Service Representative",
        "workdayID": {
          "id": "827151affb3f4914ab6494d1e3b78d58"
        },
        "safetyIncidentEvents_InProgressOrCompleted": {
          "data": [
            {
              "descriptor": "Report Safety Incident - Report Safety Incident Event - Previous CASE-00758 | New | 06/30/2020 | Auckland",
              "safetyIncident_Proposed": {
                "involvedParties": {
                  "data": [
                    {
                      "caseNumber": "NZT-9863"
                    }
                  ]
                }
              }
            },
            {
              "descriptor": "Edit Safety Incident - Edit Safety Incident Event - CASE-00758 | Completed Investigation | 06/30/2020 | Auckland",
              "safetyIncident_Proposed": {
                "involvedParties": {
                  "data": [
                    {
                      "caseNumber": "NZT-9863"
                    }
                  ]
                }
              }
            }
          ]
        }
      }
    ]
  }
}
}
```

## <a id="section_m4v_cmn_xvb"></a>Get Companies

This sample query gets all companies using the `companies` data source.

```
query getCompanies($company_dataSource: Company_DataSources!, $limit: BigInt, $offset: BigInt) {
company(dataSource: $company_dataSource, limit: $limit, offset: $offset) {
  data {
    descriptor
    workdayID {
      id
    }
  }
  total
}
}
```

Query variables:

```
{
"company_dataSource": {
  "companies": {}
},
"limit": 50,
"offset": 0
}
```

Sample response:

```
{
"data": {
  "company": {
    "data": [
      {
        "descriptor": "Global Modern Services, Inc. (USA)",
        "workdayID": {
          "id": "cb550da820584750aae8f807882fa79a"
        }
      },
      . . .
    ],
    "total": 47
  }
}
}
```

## <a id="section_wzr_t2x_15b"></a>Get Job Profiles

To get all job profiles, this sample query uses the `defaultFilter` of the `allActiveJobProfiles` data source.

```
query getJobProfiles($limit: BigInt, $offset: BigInt) {
jobProfile(
  dataSource: {allActiveJobProfiles: {filter: {defaultFilter: {}}}}
  limit: $limit
  offset: $offset
) {
  data {
    descriptor
    workdayID {
      id
    }
    managementLevel {
      descriptor
    }
    jobProfileSummary
  }
  total
}
}
```

Query variables:

```
{
"limit": 50,
"offset": 0
}
```

Sample response:

```
{
"data": {
  "jobProfile": {
    "data": [
      {
        "descriptor": "Apprentice Office Management",
        "workdayID": {
          "id": "f205e296dafa01ce882f64d32e7a1400"
        },
        "managementLevel": {
          "descriptor": "8 Individual Contributor"
        },
        "jobProfileSummary": "Responsible for various office task as well as the communication with internal and external stakeholders"
      },
      . . .
    ],
    "total": 162
  }
}
}
```

## <a id="section_efp_cfx_15b"></a>Get Charities (Model Business Objects)

This sample query gets <i>Charity</i> data, which is a model business object of a sample app named <i>charitableDonations_ycjtxv</i>. You'll need to first deploy your app to see your model business objects in the Graph API schema.

```

query charitableDonations_ycjtxv_Charity($charitableDonations_ycjtxv_Charity_dataSource: CharitableDonations_ycjtxv_Charity_DataSources!) {
charitableDonations_ycjtxv_Charity(
  dataSource: $charitableDonations_ycjtxv_Charity_dataSource
) {
  data {
    createdBy {
      descriptor
    }
    description
    descriptor
    matchDonations
    name
    workdayID {
      id
    }
    workdayMatched
  }
  total
}
}
```

Query variables:

```
{
"charitableDonations_ycjtxv_Charity_dataSource": {
  "charitableDonations_ycjtxv_charities": {}
}
}
```

Sample response:

```
{
"data": {
  "charitableDonations_ycjtxv_Charity": {
    "data": [
      {
        "createdBy": {
          "descriptor": "Logan McNeil"
        },
        "description": "<p>East Bay SPCA</p>",
        "descriptor": "EBSPCA",
        "matchDonations": true,
        "name": "EBSPCA",
        "workdayID": {
          "id": "ec4628d60eb39000275d46b6001a0000"
        },
        "workdayMatched": false
      }
    ],
    "total": 1
  }
}
}
```

## <a id="section_arv_ytj_jwb"></a>Get Large Objects by Worker (Model Business Objects)

This sample query gets <i>ArticleAbstracts</i> data, which is a large model business object of a sample app named <i>largeObject_abc</i>. You'll need to first deploy your app to see your model business objects in the Graph API schema.

```
query largeObject_abc_ArticleAbstracts(
          $largeObject_abc_ArticleAbstracts_dataSource: LargeObject_abc_ArticleAbstractsDataSources!,
          $largeObject_abc_ArticleAbstracts_limit: BigInt,
          $largeObject_abc_ArticleAbstracts_offset: BigInt) {
      largeObject_abc_ArticleAbstracts(
          dataSource: $largeObject_abc_ArticleAbstracts_dataSource,
          limit: $largeObject_abc_ArticleAbstracts_limit,
          offset: $largeObject_abc_ArticleAbstracts_offset ) {
        data {
          abstract
          abstractID
          authors
          categories
          changeForGraph
          comments
          descriptor
          license
          submitter
          title
          updateDate
          workdayID {
            id
          }
        }
        total
     }
 }
```

Query variables:

```
{
  "largeObject_abc_ArticleAbstracts_dataSource": {
    "largeObject_abc_articleAbstracts": {
    }
  },
  "largeObject_abc_ArticleAbstracts_limit": 100,
  "largeObject_abc_ArticleAbstracts_offset": 0
}
```

## <a id="section_1"></a>Get Model Attachments

This sample query gets the downloadIDs of <i>Logos</i>, used as model attachments in a sample Extend app. To download the logos, call the Attachments REST API with the downloadID.

```
query myApp_Logo($myApp_Logo_dataSource: MyApp_Logo_DataSources!, $myApp_Logo_where: MyApp_Logo_Criteria) {
 myApp_Logo(
   dataSource: $myApp_Logo_dataSource
   where: $myApp_Logo_where
 ) {
   data {
     contentType
     descriptor
     downloadID
   }
 }
}
 
```

Query variables:

```
{
 "myApp_Logo_dataSource": {
   "myApp_logos": {}
 },
 "myApp_Logo_where": {
   "workdayID": {
     "in": [
       {
         "id": "b7d09523f06c810015d3ae3d4f110000",
         "type": "WID"
       },
       {
         "id": "b7d09523f06c810015d3ad08374d0001",
         "type": "WID"
       }
     ]
   }
 }
}
 
```

Sample response:

```
{
 "data": {
   "myApp_Logo": {
     "data": [
       {
         "contentType": "image/jpeg",
         "descriptor": "dogCat2.jpg",
         "downloadID": "VjBSRFF6RXVNSUVBRVFBQURQclFNeXN1UmltbFhjcnVSZ0FBakFBV0FURUFFTzVSeEJwd1puNmVhME1ydU1wNG9vc0FBQUFTcjVpM0JSUktxd1dQVVlCN3AwR05qeWRYaHdGeDJLUHY5WXNrYXYrbHNhNE5XdzVDUW0zL1Z4K3BJWkM4RVdkVG5hUDJMaklBV0dGYmFneVFBdllBNnlDZFN2bTBVNVk9"
       },
       {
         "contentType": "image/gif",
         "descriptor": "dogs-babysitter.gif",
         "downloadID": "VjBSRFF6RXVNSUVBRVFBQURCdUlPTDYvQnFtcXRWWmpGQUFBakFBV0FURUFFTHo3M0N5Zit2ZVJpRUk3VTN0bDRaa0FBQURWQThHRlhNemN3ejNBMFdVSVpIa3phTUZ6UCt5QVZLcW0wM25QNE43T2lBa0tBT3ByTTBtTTFpQnU0Q1VGUkhSa1RBd3hxS2VWV1Y1dWtLNVpkdE9xYTNJMVYvTlo0MFU9"
       }
     ]
   }
 }
}
 
```

To download the file attachments, call the Attachments REST API with the download ID. Example:

```
GET https://api.workday.com/attachments/v1/graphql/{downloadID}
```

where `{downloadID}` is a `downloadID` value from the sample response.

### Related Information

[Query Filters](/wcp_docs/GUID-1a496a09-dbf2-4958-9d1f-12bea23b8855-enHYPHENus.html)

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

