The importProject mutation can be used to import and overwrite an existing project in your embedded account. This is handy when you want to import projects to your 'production' account from 'staging'.
You can also override project configs while importing by passing configJson
in the mutation.
Required token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following arguments:
Argument | Required | Note |
---|---|---|
exportedProjectJson | Yes | Can be obtained either by exporting project json from UI or using the exportProject mutation (refer below) The JSON must be stringified. |
targetProjectId | Yes | obtained from the url of target Project page: https://app.tray.io/workspaces/{workspaceId}/projects/{projectId} |
configJson | No | Stringified JSON object to override the existing project's config. If passed, a complete list of all config must be provided, with entries matching the same data type as the incoming project. |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
Import Project
mutation {
importProject (input: {
exportedProjectJson: "{}",
targetProjectId: "944dxxx-xxx-xxx-xxx-xxx222eb99",
configJson: "{\"list_id\":\"udi38969hhb\",\"channel\":\"U17287188\"}"
}) {
clientMutationId
}
}
Import Project with clientMutationId
mutation {
importProject (input: {
exportedProjectJson: "{}",
targetProjectId: "944dxxx-xxx-xxx-xxx-xxx222eb99",
configJson: "{\"list_id\":\"udi38969hhb\",\"channel\":\"U17287188\"}",
clientMutationId: "some-mutation-id"
}) {
clientMutationId
}
}
It can return the following data:
Returned Data | Notes |
---|---|
clientMutationId | while this data is only relevant if using the Relay GraphQL client, it is actually required here as currently this mutation does not return any other data |
OK - The project is imported to the embedded org
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation ($exportedProjectJson: String!, $targetProjectId: ID!) {\n importProject (input: {\n exportedProjectJson: $exportedProjectJson,\n targetProjectId: $targetProjectId\n }) {\n clientMutationId\n }\n}", "variables": { "exportedProjectJson": "{}", "targetProjectId": "944dxxx-xxx-xxx-xxx-xxx222eb99", "configJson": "{\"list_id\":\"udi38969hhb\",\"channel\":\"U17287188\"}" } }'
{- "data": {
- "importProject": {
- "clientMutationId": null
}
}
}
The exportProject mutation can be used to export the projects from your embedded account.
This is handy when you want to import project to your 'production' account from 'staging'.
Required token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following arguments:
Argument | Required | Note |
---|---|---|
projectId | Yes | obtained from the url of the Project page: https://app.tray.io/workspaces/{workspaceId}/projects/{projectId} |
exportSolution | Yes | Boolean value. If set to true, the solution associated with the workflow is exported as part of the JSON structure. |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
Export Project
mutation {
exportProject (input: {
projectId: "944dxxx-xxx-xxx-xxx-xxx222eb99",
exportSolution: true
}) {
exportedProjectJson
}
}
It can return the following data:
Returned Data | Notes |
---|---|
exportedProjectJson | Stringified JSON of the project |
OK - The JSON string of the exported project is returned
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://tray.io/graphql \ -H 'Authorization: Bearer <MASTER_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "mutation ($projectId: ID!) {\n exportProject (input: {\n projectId: $projectId,\n exportSolution: true\n }) {\n exportedProjectJson\n }\n}", "variables": { "projectId": "944dxxx-xxx-xxx-xxx-xxx222eb99" } }'
{- "data": {
- "exportProject": {
- "exportedProjectJson": "{}"
}
}
}
The exportProjectConfig mutation can be used to export the configs of a project from your embedded account.
Required token | Notes |
---|---|
Master | Obtained from the Tray app UI. Refer this. |
The mutation accepts the following arguments:
Argument | Required | Note |
---|---|---|
projectId | Yes | obtained from the url of the Project page: https://app.tray.io/workspaces/{workspaceId}/projects/{projectId} |
clientMutationId | No | Only relevant if using the Relay GraphQL client |
Here is an example mutation:
Export Project
mutation {
exportProjectConfig (input: {
projectId: "944dxxx-xxx-xxx-xxx-xxx222eb99"
}) {
exportProjectConfigJson
}
}
It can return the following data:
Returned Data | Notes |
---|---|
exportProjectConfigJson | Stringified JSON of the project's config |
OK - The JSON string of the exported project is returned
Unauthorized
Forbidden
Internal Error
curl -i -X POST \ https://{{base_url}}/graphql \ --header 'Authorization: Bearer {{master_token}}' \ --header 'Content-Type: application/json' \ --data '{"query":"mutation ($projectId: ID!) {\n exportProjectConfig (input: {\n projectId: $projectId\n }) {\n exportProjectConfigJson\n }\n}","variables":{"projectId":"944dxxx-xxx-xxx-xxx-xxx222eb99"}}'
{- "data": {
- "exportProjectConfig": {
- "exportProjectConfigJson": "{\"batch_size\":10,\"alert_slack_channel\":\"U055BPQP188\",\"google_sheet_to_salesforce_mapping\":{\"test\":\"test\"},\"spreadsheet_id\":\"1jzs4wKHTWR984lxxxxxxxx_8vSo9Y\",\"worksheet_name\":\"abcd\",\"salesforce_record_type\":\"Lead\",\"interval\":30}"
}
}
}