a8n: GraphQL API for draft campaigns
There are no commits yet
Push commits to the source branch or add previously merged commits to review them.
Created by: mrnugget
This adds the GraphQL API necessary for #7217. It implements the API as proposed in this comment with a few minor changes that I discussed with @eseliger, in order to make the client implementation easier.
The API flow for creating a Campaign
in draft mode (that is: without creating pull requests on the code host) is this:
Campaign
as a draft: createCampaign
with draft = true
:mutation CreateDraftCampaignWithPlan($input: CreateCampaignInput!) {
createCampaign(input: $input) {
id
name
description
publishedAt
changesetCreationStatus {
state
completedCount
pendingCount
errors
}
changesets {
totalCount
}
changesetPlans {
totalCount
nodes {
id
}
}
}
}
Variables:
{
"input":{
"namespace":"VXNlcjox",
"name":"This is a draft campaign",
"description":"This is another cool campaign before release",
"plan": "Q2FtcGFpZ25QbGFuOjUy",
"draft": true
}
}
Response:
{
"data": {
"createCampaign": {
"id": "Q2FtcGFpZ246OQ==",
"name": "This is a draft campaign",
"description": "This is another cool campaign before release",
"publishedAt": null,
"changesetCreationStatus": {
"state": "COMPLETED",
"completedCount": 0,
"pendingCount": 0,
"errors": []
},
"changesets": {
"totalCount": 0
},
"changesetPlans": {
"totalCount": 2,
"nodes": [
{
"id": "Q2hhbmdlc2V0UGxhbjoyNjU3"
},
{
"id": "Q2hhbmdlc2V0UGxhbjoyNjU4"
}
]
}
}
}
}
Note: We have 2
changesetPlans
and publishedAt
is null
.
changesetPlans
:mutation PublishChangesetPlan($id: ID!) {
publishChangesetPlan(changesetPlan: $id) {
alwaysNil
}
}
Variables:
{
"id":"Q2hhbmdlc2V0UGxhbjoyNjU3"
}
Response:
{
"data": {
"publishChangesetPlan": {
"alwaysNil": null
}
}
}
changesetPlan
has been turned into a changeset
:query CampaignStatus($id: ID!) {
node(id: $id) {
... on Campaign {
id
name
description
publishedAt
changesetCreationStatus {
state
completedCount
pendingCount
errors
}
changesets {
totalCount
}
changesetPlans {
totalCount
nodes {
id
}
}
}
}
}
Response:
{
"data": {
"node": {
"id": "Q2FtcGFpZ246OQ==",
"name": "This is a draft campaign",
"description": "This is another cool campaign before release",
"publishedAt": null,
"changesetCreationStatus": {
"state": "COMPLETED",
"completedCount": 1,
"pendingCount": 0,
"errors": []
},
"changesets": {
"totalCount": 1
},
"changesetPlans": {
"totalCount": 1,
"nodes": [
{
"id": "Q2hhbmdlc2V0UGxhbjoyNjU3"
}
]
}
}
}
}
mutation PublishCampaign($id: ID!) {
publishCampaign(campaign: $id) {
id
}
}
Response:
{
"data": {
"node": {
"id": "Q2FtcGFpZ246OQ=="
}
}
}
Response:
{
"data": {
"node": {
"id": "Q2FtcGFpZ246OQ==",
"name": "This is a draft campaign",
"description": "This is another cool campaign before release",
"publishedAt": "2019-12-19T08:45:14Z",
"changesetCreationStatus": {
"state": "COMPLETED",
"completedCount": 2,
"pendingCount": 0,
"errors": []
},
"changesets": {
"totalCount": 2
},
"changesetPlans": {
"totalCount": 0,
"nodes": []
}
}
}
}
Note we now have 2
changesets
and 0
changesetPlans
.
Push commits to the source branch or add previously merged commits to review them.