Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/lib/project-item-node-to-github-project-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function projectItemNodeToGitHubProjectItem(state, itemNode) {
const common = {
type: itemNode.type,
id: itemNode.id,
isArchived: itemNode.isArchived,
fields,
};

Expand Down Expand Up @@ -59,12 +60,13 @@ export function projectItemNodeToGitHubProjectItem(state, itemNode) {
content,
};
}
/* c8 ignore next 8 */
/* c8 ignore next 9 */

// fallback: no content properties are set. Currently that's in case of "REDACTED"
return {
type: itemNode.type,
id: itemNode.id,
isArchived: itemNode.isArchived,
fields,
content: {},
};
Expand Down
1 change: 1 addition & 0 deletions api/lib/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const queryItemFieldNodes = `
id
createdAt
type
isArchived
${queryContentNode}
fieldValues(first: 20) {
nodes {
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,31 @@ export type GitHubProjectItem<
type ProjectItem_Redacted<TFields> = {
type: "REDACTED";
id: string;
isArchived: boolean;
fields: TFields;
content: {};
};

type ProjectItem_DraftIssue<TFields> = {
type: "DRAFT_ISSUE";
id: string;
isArchived: boolean;
fields: TFields;
content: DraftIssueContent;
};

type ProjectItem_Issue<TFields> = {
type: "ISSUE";
id: string;
isArchived: boolean;
fields: TFields;
content: IssueContent;
};

type ProjectItem_PullRequest<TFields> = {
type: "PULL_REQUEST";
id: string;
isArchived: boolean;
fields: TFields;
content: PullRequestContent;
};
Expand Down
35 changes: 15 additions & 20 deletions test/recorded/api.items.add-draft-with-empty-fields/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Mon, 24 Oct 2022 17:25:56 GMT",
"date": "Sun, 29 Jan 2023 18:46:28 GMT",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"server": "GitHub.com",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
Expand All @@ -24,12 +24,12 @@
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-media-type": "github.v3; format=json",
"x-github-request-id": "E465:14B4:55BEBFD:5838335:6356CAA4",
"x-github-request-id": "E137:7B16:2E4984:307942:63D6BF04",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4963",
"x-ratelimit-reset": "1666635908",
"x-ratelimit-remaining": "4974",
"x-ratelimit-reset": "1675021300",
"x-ratelimit-resource": "graphql",
"x-ratelimit-used": "37",
"x-ratelimit-used": "26",
"x-xss-protection": "0"
},
"data": {
Expand Down Expand Up @@ -82,36 +82,31 @@
},
{
"id": "PVTF_5",
"dataType": "TRACKS",
"name": "Tracks"
},
{
"id": "PVTF_6",
"dataType": "REVIEWERS",
"name": "Reviewers"
},
{
"id": "PVTF_7",
"id": "PVTF_6",
"dataType": "REPOSITORY",
"name": "Repository"
},
{
"id": "PVTF_8",
"id": "PVTF_7",
"dataType": "MILESTONE",
"name": "Milestone"
},
{
"id": "PVTF_9",
"id": "PVTF_8",
"dataType": "TEXT",
"name": "Text"
},
{
"id": "PVTF_10",
"id": "PVTF_9",
"dataType": "NUMBER",
"name": "Number"
},
{
"id": "PVTF_11",
"id": "PVTF_10",
"dataType": "DATE",
"name": "Date"
},
Expand Down Expand Up @@ -185,7 +180,7 @@
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Mon, 24 Oct 2022 17:25:57 GMT",
"date": "Sun, 29 Jan 2023 18:46:29 GMT",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"server": "GitHub.com",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
Expand All @@ -194,12 +189,12 @@
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-media-type": "github.v3; format=json",
"x-github-request-id": "E466:97C9:2B847C:2CA160:6356CAA5",
"x-github-request-id": "E13A:34F7:3699A9:38CAF5:63D6BF05",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4962",
"x-ratelimit-reset": "1666635908",
"x-ratelimit-remaining": "4973",
"x-ratelimit-reset": "1675021300",
"x-ratelimit-resource": "graphql",
"x-ratelimit-used": "38",
"x-ratelimit-used": "27",
"x-xss-protection": "0"
},
"data": {
Expand Down
49 changes: 22 additions & 27 deletions test/recorded/api.items.add-draft-with-fields/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Mon, 24 Oct 2022 17:26:06 GMT",
"date": "Sun, 29 Jan 2023 18:46:36 GMT",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"server": "GitHub.com",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
Expand All @@ -24,12 +24,12 @@
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-media-type": "github.v3; format=json",
"x-github-request-id": "E46D:97C9:2B9226:2CAF81:6356CAAD",
"x-github-request-id": "E142:40DE:31DB9E:340BDE:63D6BF0C",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4957",
"x-ratelimit-reset": "1666635908",
"x-ratelimit-remaining": "4968",
"x-ratelimit-reset": "1675021300",
"x-ratelimit-resource": "graphql",
"x-ratelimit-used": "43",
"x-ratelimit-used": "32",
"x-xss-protection": "0"
},
"data": {
Expand Down Expand Up @@ -82,36 +82,31 @@
},
{
"id": "PVTF_5",
"dataType": "TRACKS",
"name": "Tracks"
},
{
"id": "PVTF_6",
"dataType": "REVIEWERS",
"name": "Reviewers"
},
{
"id": "PVTF_7",
"id": "PVTF_6",
"dataType": "REPOSITORY",
"name": "Repository"
},
{
"id": "PVTF_8",
"id": "PVTF_7",
"dataType": "MILESTONE",
"name": "Milestone"
},
{
"id": "PVTF_9",
"id": "PVTF_8",
"dataType": "TEXT",
"name": "Text"
},
{
"id": "PVTF_10",
"id": "PVTF_9",
"dataType": "NUMBER",
"name": "Number"
},
{
"id": "PVTF_11",
"id": "PVTF_10",
"dataType": "DATE",
"name": "Date"
},
Expand Down Expand Up @@ -186,7 +181,7 @@
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Mon, 24 Oct 2022 17:26:07 GMT",
"date": "Sun, 29 Jan 2023 18:46:37 GMT",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"server": "GitHub.com",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
Expand All @@ -195,12 +190,12 @@
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-media-type": "github.v3; format=json",
"x-github-request-id": "E46E:0A68:BF78655:C3C617E:6356CAAE",
"x-github-request-id": "E143:333C:3303DD:353438:63D6BF0D",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4956",
"x-ratelimit-reset": "1666635908",
"x-ratelimit-remaining": "4967",
"x-ratelimit-reset": "1675021300",
"x-ratelimit-resource": "graphql",
"x-ratelimit-used": "44",
"x-ratelimit-used": "33",
"x-xss-protection": "0"
},
"data": {
Expand Down Expand Up @@ -240,7 +235,7 @@
}
},
{
"query": "\n mutation setItemProperties($projectId: ID!, $itemId: ID!) {\n \n date: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLQw\", value: {date: \"2020-01-01\"}}) {\n projectV2Item { \n id\n createdAt\n type\n \n content {\n ... on DraftIssue {\n id\n title\n createdAt\n updatedAt\n author: creator {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n }\n ... on Issue {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n }\n ... on PullRequest {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n merged\n }\n }\n\n fieldValues(first: 20) {\n nodes {\n __typename\n ... on ProjectV2ItemFieldDateValue {\n date\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldIterationValue {\n title\n iterationId\n startDate\n duration\n field {\n ... on ProjectV2IterationField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldNumberValue {\n number\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldSingleSelectValue {\n optionId\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldTextValue {\n text\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n }\n }\n }\n }\n \n\n number: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLPk\", value: {number: 123}}) {\n clientMutationId\n }\n \n\n singleSelect: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTSSF_lADOBYMIeM4ADzd0zgCMLQ0\", value: {singleSelectOptionId: \"8a0f266e\"}}) {\n clientMutationId\n }\n \n\n status: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTSSF_lADOBYMIeM4ADzd0zgCMLM0\", value: {singleSelectOptionId: \"98236657\"}}) {\n clientMutationId\n }\n \n\n text: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLPg\", value: {text: \"Some text\"}}) {\n clientMutationId\n }\n \n\n title: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLMs\", value: {text: \"the hack?\"}}) {\n clientMutationId\n }\n \n }\n ",
"query": "\n mutation setItemProperties($projectId: ID!, $itemId: ID!) {\n \n date: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLQw\", value: {date: \"2020-01-01\"}}) {\n projectV2Item { \n id\n createdAt\n type\n \n content {\n ... on DraftIssue {\n id\n title\n createdAt\n updatedAt\n author: creator {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n }\n ... on Issue {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n }\n ... on PullRequest {\n \n id\n databaseId\n number\n title\n url\n createdAt\n author {\n login\n }\n assignees(first: 10) {\n nodes {\n login\n }\n }\n labels(first: 10) {\n nodes {\n name\n }\n }\n closed\n milestone {\n number\n title\n state\n }\n repository {\n name\n }\n\n merged\n }\n }\n\n fieldValues(first: 20) {\n nodes {\n __typename\n ... on ProjectV2ItemFieldDateValue {\n date\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldIterationValue {\n title\n iterationId\n startDate\n duration\n field {\n ... on ProjectV2IterationField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldNumberValue {\n number\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldSingleSelectValue {\n optionId\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n ... on ProjectV2ItemFieldTextValue {\n text\n field {\n ... on ProjectV2Field {\n id\n }\n }\n }\n }\n }\n }\n }\n \n\n number: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLPk\", value: {number: 123}}) {\n clientMutationId\n }\n \n\n singleSelect: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTSSF_lADOBYMIeM4ADzd0zgCMLQ0\", value: {singleSelectOptionId: \"8a0f266e\"}}) {\n clientMutationId\n }\n \n\n status: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTSSF_lADOBYMIeM4ADzd0zgCMLM0\", value: {singleSelectOptionId: \"98236657\"}}) {\n clientMutationId\n }\n \n\n text: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLPg\", value: {text: \"Some text\"}}) {\n clientMutationId\n }\n \n\n title: updateProjectV2ItemFieldValue(input: {projectId: $projectId, itemId: $itemId, fieldId: \"PVTF_lADOBYMIeM4ADzd0zgCMLMs\", value: {text: \"the hack?\"}}) {\n clientMutationId\n }\n \n }\n ",
"variables": {
"projectId": "PVT_1",
"itemId": "PVTI_1"
Expand All @@ -255,7 +250,7 @@
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'",
"content-type": "application/json; charset=utf-8",
"date": "Mon, 24 Oct 2022 17:26:09 GMT",
"date": "Sun, 29 Jan 2023 18:46:39 GMT",
"referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"server": "GitHub.com",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
Expand All @@ -264,12 +259,12 @@
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-media-type": "github.v3; format=json",
"x-github-request-id": "E46F:32CE:16D2EBF:17716ED:6356CAAF",
"x-github-request-id": "E144:34F7:36A0BA:38D268:63D6BF0E",
"x-ratelimit-limit": "5000",
"x-ratelimit-remaining": "4955",
"x-ratelimit-reset": "1666635908",
"x-ratelimit-remaining": "4966",
"x-ratelimit-reset": "1675021300",
"x-ratelimit-resource": "graphql",
"x-ratelimit-used": "45",
"x-ratelimit-used": "34",
"x-xss-protection": "0"
},
"data": {
Expand Down Expand Up @@ -304,7 +299,7 @@
"__typename": "ProjectV2ItemFieldDateValue",
"date": "2020-01-01",
"field": {
"id": "PVTF_11"
"id": "PVTF_10"
}
}
]
Expand Down
Loading