@@ -1908,15 +1908,19 @@ url
19081908project {
19091909 name
19101910}
1911- cards(first: 50, archivedStates: [NOT_ARCHIVED]) {
1911+ cards(first: 50, archivedStates: [NOT_ARCHIVED], after: $after ) {
19121912 nodes {
19131913 ${ projectCardFields }
19141914 }
1915+ pageInfo {
1916+ hasNextPage
1917+ endCursor
1918+ }
19151919}
19161920` . trim ( ) ;
19171921
19181922const GET_PROJECT_COLUMNS = `
1919- query($sourceColumnIds: [ID!]!, $targetColumnId: ID!) {
1923+ query($sourceColumnIds: [ID!]!, $targetColumnId: ID!, $after: String ) {
19201924 sourceColumns: nodes(ids: $sourceColumnIds) {
19211925 ... on ProjectColumn {
19221926 ${ projectColumnFields }
@@ -1930,6 +1934,16 @@ query($sourceColumnIds: [ID!]!, $targetColumnId: ID!) {
19301934}
19311935` . trim ( ) ;
19321936
1937+ const GET_SINGLE_PROJECT_COLUMN = `
1938+ query($id: ID!, $after: String) {
1939+ column: node(id: $id) {
1940+ ... on ProjectColumn {
1941+ ${ projectColumnFields }
1942+ }
1943+ }
1944+ }
1945+ ` . trim ( ) ;
1946+
19331947const ADD_PROJECT_CARD = `
19341948mutation addProjectCard($columnId: ID!, $contentId: ID, $note: String) {
19351949 addProjectCard(input: { projectColumnId: $columnId, contentId: $contentId, note: $note }) {
@@ -1964,6 +1978,7 @@ mutation deleteProjectCard($cardId: ID!) {
19641978
19651979module . exports = {
19661980 GET_PROJECT_COLUMNS ,
1981+ GET_SINGLE_PROJECT_COLUMN ,
19671982 ADD_PROJECT_CARD ,
19681983 MOVE_PROJECT_CARD ,
19691984 DELETE_PROJECT_CARD
@@ -5948,6 +5963,29 @@ ${columnReferences.join('\n')}
59485963` . trim ( ) ;
59495964}
59505965
5966+ // Paginate project cards from all columns if/as needed
5967+ async function paginateColumnCards ( api , columns ) {
5968+ for ( let i = 0 ; i < columns . length ; i += 1 ) {
5969+ const originalColumn = columns [ i ] ;
5970+
5971+ let currentColumn = originalColumn ;
5972+ while ( currentColumn . cards . pageInfo . hasNextPage ) {
5973+ core . info (
5974+ `paginating ${ currentColumn . project . name } :${ currentColumn . name } after ${ currentColumn . cards . pageInfo . endCursor } `
5975+ ) ;
5976+
5977+ // eslint-disable-next-line no-await-in-loop
5978+ const { column } = await api ( queries . GET_SINGLE_PROJECT_COLUMN , {
5979+ id : currentColumn . id ,
5980+ after : currentColumn . cards . pageInfo . endCursor
5981+ } ) ;
5982+
5983+ originalColumn . cards . nodes . push ( ...column . cards . nodes ) ;
5984+ currentColumn = column ;
5985+ }
5986+ }
5987+ }
5988+
59515989// Find a card in an array of cards based on it's linked content, or it's note.
59525990// Returns an array of [found card, index of found card]
59535991function findCard ( card , cards ) {
@@ -6018,14 +6056,16 @@ async function run() {
60186056 const sourceColumnIds = utils . getInputList ( core . getInput ( 'source_column_id' , { required : true } ) ) ;
60196057 const targetColumnId = core . getInput ( 'target_column_id' , { required : true } ) ;
60206058
6021- const response = await api ( queries . GET_PROJECT_COLUMNS , {
6059+ const { sourceColumns , targetColumn } = await api ( queries . GET_PROJECT_COLUMNS , {
60226060 sourceColumnIds,
60236061 targetColumnId
60246062 } ) ;
60256063
6064+ // paginate to gather all cards if needed
6065+ await paginateColumnCards ( api , [ ...sourceColumns , targetColumn ] ) ;
6066+
60266067 // apply user supplied filters to cards from the source column and mirror the
60276068 // target column based on the remaining filters
6028- const { sourceColumns, targetColumn } = response ;
60296069 const sourceCards = sourceColumns . flatMap ( column => {
60306070 return applyFilters ( column . cards . nodes , [ ...Object . values ( utils . filters ) ] ) ;
60316071 } ) ;
0 commit comments