Use the externalItems GraphQL query get a list of multiple CRM items.
Example A
The first sample code block illustrates a request to retrieve the first two contacts. The second code block illustrates the corresponding response with the requested data for each contact, including the cursor position.
| Request 1 | Response 1 |
|---|
{
externalItems(
namespace: "salesforce",
filter: {
type: "Contact"
}, first: 2
) {
edges {
cursor
node {
identity {
id
}
... on Contact {
name
email
}
}
}
}
}
| {
"data": {
"externalItems": {
"edges": [
{
"cursor": "MQ==",
"node": {
"identity": {
"id": "0034J000006RSvvQAG"
},
"name": "Rose Gonzalez",
"email": "rose@edge.com"
}
},
{
"cursor": "Mg==",
"node": {
"identity": {
"id": "0034J000006RSvwQAG"
},
"name": "Sean Forbes",
"email": "sean@edge.com"
}
}
]
}
}
}
|
Subsequent requests can be made for additional items, as the next example illustrates. This request includes passing a value for the after parameter, which in this case is the cursor position of the last item returned in the preceding response.
| Request 2 | Response 2 |
|---|
{
externalItems(
namespace: "salesforce",
filter: {
type: "Contact"
}, first: 2, after: "Mg=="
) {
edges {
cursor
node {
identity {
id
}
... on Contact {
name
email
}
}
}
}
}
| {
"data": {
"externalItems": {
"edges": [
{
"cursor": "Mw==",
"node": {
"identity": {
"id": "0034J000006RSvxQAG"
},
"name": "Jack Rogers",
"email": "jrogers@burlington.com"
}
},
{
"cursor": "NA==",
"node": {
"identity": {
"id": "0034J000006RSvyQAG"
},
"name": "Pat Stumuller",
"email": "pat@pyramid.net"
}
}
]
}
}
}
|
Example B
The first sample code block illustrates a request to retrieve all contacts belonging to a specific account. The second code block illustrates the corresponding response with the requested data for each contact.
| Request | Response |
|---|
{
externalItems(
namespace: "salesforce"
filter: {
context: {
type: "Account"
id: "0010O00001sSLauQAG"
}
type: "Contact"
}, first: 100) {
edges {
node {
... on Contact {
identity {
id
}
accountId
name
email
}
}
}
}
}
| {
"data": {
"externalItems": {
"edges": [
{
"node": {
"identity": {
"id": "0030O000024wcTMQAY"
},
"accountId": "0010O00001sSLauQAG",
"name": "Jack Rogers",
"email": "jrogers@burlington.com"
}
}
]
}
}
}
|